6

I'm trying to grab all keyboard events for a remote desktop-type client. I don't want things like ALT-Tab to get caught by the Gnome3/KDE/Openbox/etc... desktop, I want my application to get all these events and other applications to not get the event.

I'm doing something like this currently:

grabKeyboard() // qt function
Display *display = XOpenDisplay(NULL);
XGrabKeyboard(display, winId(), True, GrabModeAsync, GrabModeAsync, CurrentTime);

which actually seems to work fine with ALT-Tab, but in Openbox there are a bunch of keyboard shortcuts defined to "Show desktop" (ALT-CTRL-END) and "Reset X" (CTRL-ALT-R) that are getting caught by Openbox. I noticed that FreeRDP does something like this:

int input_mask =
            KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
            VisibilityChangeMask | FocusChangeMask | StructureNotifyMask |
            PointerMotionMask | ExposureMask | PropertyChangeMask;
XSelectInput(display, winId(), input_mask);

I've tried that in addition to my code above and it doesn't work.

I also noticed that Remmina uses gdk_device_grab but since my app isn't a GTK application I can't call that. Can anyone help?

NG_
  • 6,895
  • 7
  • 45
  • 67
dgrant
  • 1,417
  • 3
  • 16
  • 23
  • 1
    You could have a look the code at open source desktop virtualization software (e.g. VirtualBox). They will certainly be catching as much as possible. – Stefan Majewsky Jan 10 '13 at 21:25

0 Answers0