How do you read KeyPress and ButtonPress events on the root window in X11/Xlib?

Viewed 179

I am writing a C program that draws to the root window. (This part works)

I now need to accept keyboard and mouse input on the root window (clicking and keypresses on the root window). I tried this:

XSelectInput(display, rootWindow, KeyPressMask);
XNextEvent(display, &event)

but a KeyPress never comes. I also tried using ButtonPressMask but this creates an error:

X Error of failed request:  BadAccess

Is it possible to do this without having to hook into all input? I have seen this idea on stack overflow: Detect modifier key release in X11 root window but it hooks into all input as far as I can tell.

I am using i3wm, so I have nothing as my default root window. (incase this helps)

0 Answers
Related