🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

X11, get mouse button state

Started by
5 comments, last by xDan 14 years, 1 month ago
Hi, Does anyone know how I can query the current mouse button states in X11? I can use XQueryKeymap for keys. I don't want to rely on events.
Advertisement
Moving over to the Everything Unix forum.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Ok, never mind, with further research I'm pretty sure it doesn't exist. I'll just have to use events. Bah.
Events are the way to go. Although saying that, you could read the information from "/dev/input/mice"
Ok. The reason I wanted this, is because key or mouse input events do not seem to be received when the window does not have the focus. Is there any way to change it so they are always received?

...

Imagine I use a key or mouse button in my game for movement. I hold down the button to trigger movement, then alt+tab away. Then the I raise the button, and the mouse button up or key up event will not be received by my app, and when I return to it, the character moves off into the distance by itself, since it still thinks the button is held down.

I can partially solve this by nullifying my record of key states when the focus is returned, but that's not ideal. As it means triggering a fake key/button up event when there might not have been one.

The phrase to look for here is a "passive grab" using XGrabButton. Basically you say "I own this mouse button, tell me about stuff even if it's not on my window".

When it's released you'll get an event. Please remember to ungrab the button when it's released.


Thanks. I'll have a look at it.

This topic is closed to new replies.

Advertisement