Grab your keyboard with the Qt application on Linux

I am trying to capture all keyboard events for a working type remote client. I donโ€™t want things like ALT-Tab to get to the Gnome3 / KDE / Openbox / etc desktop ... I want my application to receive all these events and other applications so as not to get the event.

Now I am doing something like this:

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

which apparently works fine with ALT-Tab, but Openbox has a bunch of keyboard shortcuts defined for Show Desktop (ALT-CTRL-END) and Reset X (CTRL-ALT-R) that get in 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 tried this in addition to my code above and it does not work.

I also noticed that Remmina uses gdk_device_grab, but since my application is not a GTK application, I cannot call it. Can anyone help?

+6
source share

Source: https://habr.com/ru/post/914393/


All Articles