LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Xevent ButtonReleaseMask in Xlib not working? (https://www.linuxquestions.org/questions/programming-9/xevent-buttonreleasemask-in-xlib-not-working-913049/)

kalleanka 11-11-2011 12:03 PM

Xevent ButtonReleaseMask in Xlib not working?
 
Hi,

I cant get the event for releasing mouse button (num 5) to work. Entering window (num 7) works and but I get nothing clicking the mouse buttons. I wrote this small program to test. What am I missing?

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>

int main(int argc, char **argv)
{
    Display *d;
    Window w;
    XEvent e;
    int s;
               
    d = XOpenDisplay(NULL);
    if (d == NULL)
    {
        fprintf(stderr, "Cannot open display\n");
        exit(1);
    }
    s = DefaultScreen(d);
    w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 200, 200, 1, BlackPixel(d, s), WhitePixel(d, s));
                   
    XSelectInput(d, w, ButtonReleaseMask|EnterWindowMask );
    XMapWindow(d, w);
 
    while (1)
    {
        XNextEvent(d, &e);
        printf("event: %d\n", e.type);
        if (e.type == ButtonRelease) {
            printf( "clicked.\n");
        }
    }
    return 0;
}


kalleanka 11-11-2011 12:10 PM

This is really irritating. I have been sitting all day to find this bug in my main program. And now i added ButtonPressMask and then it works. Totally illogical.


XSelectInput(d, w, ButtonPressMask|ButtonReleaseMask|EnterWindowMask );



Not even my mistake but a bug in Xlib.


All times are GMT -5. The time now is 02:05 PM.