Advertisement

checking Mouse Click in the Linux without events

Started by December 13, 2010 10:46 AM
1 comment, last by Null and Void 13 years, 11 months ago
hi

how can i check mouse clicks in the Linux without using events?

my windows code for doing it is:
bool Mouse::isKeyDown(int key) const{	return ((GetKeyState(key) & 0x80) > 0);}
Moving to Everything Unix.

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

Advertisement
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);}

This topic is closed to new replies.

Advertisement