Search code examples
gccxlib

Look up specific button (ButtonPress Events in Xlib)


I'm looking for a similar function as XLookupKeysym(XKeyEvent*,int) for the ButtonPress events, so i can check what button was pressed. With XGrabButton(...) i'm getting notifications on every ButtonPress event.

How do I check for a specific button (e.g XK_Pointer_Button1) if it's pressed?


Solution

  • Ok, found what I wanted:

    ...
    switch(&Event.type):
       case ButtonPress:
          if(Event.xbutton.button == Button1)
             ...
    

    Seems to be that I've mistaken XK_Pointer_Button1 with that Button1 I used above. It's defined in X.h, not in keysymdef.h.

    If found the answer here: getting mouseclick coordinates with Xlib