Sign in to follow this  

checking Mouse Click in the Linux without events

Recommended Posts

Something like this in Xlib (although, avoiding events is hardly the proper "X" way):

Display *display;
Window window;

bool Mouse::isKeyDown(int key) const
const unsigned int masks[5] = { Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask };
Window root, child;
int root_x, root_y, child_x, child_y;
unsigned int mask;

if(key < 0 || key >= sizeof(masks)/sizeof(masks[0]))
return false;

XQueryPointer(display, window, &root, &child, &root_x, &root_y, &child_x, &child_y, &mask);

return ((mask & masks[key]) > 0);

Share this post

Link to post
Share on other sites
Sign in to follow this