Undermining XGrabKeyboard

Sebastian seppschrot at gmx.de
Tue Mar 4 09:19:36 PST 2008

On Tue, 2008-03-04 at 08:27 -0800, Octavio Alvarez wrote:
> In xorg.conf:
> Section "ServerFlags"
>   Option "AllowDeactivateGrabs" "On"
>   Option "AllowClosedownGrabs" "On"
> EndSection
> This should allow you to release grabs with Ctrl+Alt+* and Ctrl+Alt+/.


thanks, but this seems to work only if the grabbing application is
"well-behaving" anyway. (i.e. has working event processing loop)

It fails when a application runs havok like this cruft here:
WARNING: It may lock up your windowing system for at least 6 seconds. I
removed the event loop on purpose so that it has the safety net of
returning after 6 seconds. 

#include <X11/Xlib.h>
int main() 
  Display *disp;
  Window win;
  XEvent e;
  int screen; 

  win=XCreateSimpleWindow(disp, RootWindow(disp, screen), 10, 10, 100,
100, 1, BlackPixel(disp, screen), WhitePixel(disp, screen));
  XSelectInput(disp, win, ExposureMask | KeyPressMask);
  XMapWindow(disp, win);
  XNextEvent(disp, &e);
  XGrabKeyboard(disp, win, True, GrabModeSync, GrabModeSync,
  return 0;

More information about the xorg mailing list