开发者

How do I properly intercept and forward mouse events with Xlib?

开发者 https://www.devze.com 2023-03-02 00:06 出处:网络
I\'m working on a simple Xlib program where I want to intercept all mouse events (motion, button pressing, button releasing).I might want to do something with this data at some point, but right now, I

I'm working on a simple Xlib program where I want to intercept all mouse events (motion, button pressing, button releasing). I might want to do something with this data at some point, but right now, I just want to properly "forwar开发者_JAVA技巧d" these mouse events to the proper windows (as if I wasn't intercepting them at all).

At the moment, my general approach is as follows:

  • Grab the pointer for the root window with XGrabPointer()
  • Upon receiving the event, find the child window the pointer is over with XQueryPointer()
  • Forward the event to the child window with XSendEvent()

There are some more details, but that is the basic idea. I've been testing my program on Ubuntu Linux, and it seems to work in many scenarios (for instance, clicking on minimize, maximize, and close buttons works properly). However, it doesn't work in all scenarios, such as clicking on menu bar items.

In summary, I basically just want to be able to intercept mouse events and then forward them to the appropriate windows as if I hadn't intercepted them at all. What is the proper way to do this with Xlib?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号