how to get button press event on window manager ?

石仔 406643764 at
Tue Apr 10 16:01:02 UTC 2018

Hi all.I would like to be able to raise the clicked window to the top of the stack on my window manager. But it fail because only one client can SelectInput on Button events at one time. How can I realize my goal? Here is my code :

#include <X11/Xlib.h>
int main(void)
    Display *display=XOpenDisplay(NULL);
    XSelectInput(display, DefaultRootWindow(display), SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|OwnerGrabButtonMask);
    XEvent event;
        XNextEvent(display, &event);
            case ButtonPress :
                XRaiseWindow(display, event.xbutton.window);
                XSetInputFocus(display, event.xbutton.window, RevertToPointerRoot, CurrentTime);
            case ConfigureRequest :
                /* ... */
            case MapRequest :
                XMapWindow(display, event.xmaprequest.window);
    return 0;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the xorg mailing list