linux 下如何实现无论鼠标单击哪里 都能获得鼠标的位置信息

发布于 2022-08-30 18:09:35 字数 2 浏览 8 评论 3

如题

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小梨窩很甜 2022-09-05 12:42:20

利用GdkEventButton:
typedef struct {
  GdkEventType type;
  GdkWindow *window;
  gint8 send_event;
  guint32 time;
  gdouble x;
  gdouble y;
  gdouble *axes;
  guint state;
  guint button;
  GdkDevice *device;
  gdouble x_root, y_root;
} GdkEventButton;
GdkEventType type;
        the type of the event (GDK_BUTTON_PRESS, GDK_2BUTTON_PRESS, GDK_3BUTTON_PRESS or GDK_BUTTON_RELEASE).

GdkWindow *window;
        the window which received the event.

gint8 send_event;
        TRUE if the event was sent explicitly (e.g. using XSendEvent).

guint32 time;
        the time of the event in milliseconds.

gdouble x;
        the x coordinate of the pointer relative to the window.

gdouble y;
        the y coordinate of the pointer relative to the window.

gdouble *axes;
        x, y translated to the axes of device, or NULL if device is the mouse.

guint state;
        a bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See GdkModifierType.

guint button;
        the button which was pressed or released, numbered from 1 to 5. Normally button 1 is the left mouse button, 2 is the middle button, and 3 is the right button. On 2-button mice, the middle button can often be simulated by pressing both mouse buttons together.

GdkDevice *device;
        the device where the event originated.

gdouble x_root;
        the x coordinate of the pointer relative to the root of the screen.

gdouble y_root;
        the y coordinate of the pointer relative to the root of the screen.

具体的查reference,gtk+2.0 tutorial 和gtk+-demo

白昼 2022-09-01 20:51:46

回复 2# cstdio

    图形编程我不太会 不知道可不可以给写个小demo

山有枢 2022-08-30 20:43:16

回复 1# kanhfshiys

如果是qt的话那很简单
QPoint QCursor::pos ()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文