X11 - Unable to move window after XGrabKeyboard

After calling XGrabKeyboard() my application captures and displays all keystrokes / releases, including GUI and PrintScreen keys. However, the user can no longer move the application window. So far this is happening on Fedora 17 and Ubuntu 12.04.

How can I let the user move the application while under the influence of XGrabKeyboard() ?

The following is sample code for my Qt application:

 bool KeyboardStatus::x11Event(XEvent *event) { switch (event->type) { case FocusIn: XGrabKeyboard(x11Info().display(), winId(), false, GrabModeAsync, GrabModeAsync, CurrentTime); break; case FocusOut: XUngrabKeyboard(x11Info().display(), CurrentTime); break; case KeyPress: // Display which key was pressed to user return true; case KeyRelease: // Display which key was released to user return true; } return false; } 

Taking a grab expression from an event handler does not solve the problem. Here is an example project that illustrates the problem: TestGrab.zip

+5
source share
2 answers

I tried this in KDE, FVWM, and GNOME (just using Xlib), and only the problem with this GNOME window manager.

I thought it was possible to fix this by selecting the ConfigureNotify event, but it does not get fired when I try to move the window.

+1
source

I had a similar problem with XFCE on Cygwin. The problem here was the insufficient input passed to XSelectInput. Adding FocusChangeMask to KeyPressMask | KeyReleaseMask solved the problem.

Once again, this helped me solve a similar problem on xfce / cygwin.

+1
source

All Articles