simulate_keypress should pass event to window #4605
Replies: 3 comments
-
Is this relevant: #3113 |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, the I'm trying to set up a keymap akin to StumpWM or screen/tmux, where actions are mostly behind a single prefix key, and one of the actions behind the prefix key is to pass through the prefix keystroke to underlying. This means the key that does the action has to be different from the key that is actually pressed. Basically my use case is:
except with a simulate_keypress API that passes the key to the focused window. |
Beta Was this translation helpful? Give feedback.
-
I just wish qtile can interoperate with keyd https://github.com/rvaiya/keyd/blob/master/scripts/keyd-application-mapper |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently simulate_keypress only passes the keypress through qtile itself, handling keybinds and such. This is quite limiting. Leaving aside general scripting issues, one particular application I want is the ability to "pass through" a key that is bound in Qtile to the current window. Currently this is impossible, which means that Qtile keybinds must all be on keys that no application uses for its own shortcuts (or else you are unable to use those shortcuts). Compare this to StumpWM or screen/tmux, all of which freely bind keys that might be used by underlying applications, but compensate by providing a command to pass those keys through when desired.
The documentation recommends using an external binary like
xdotool
for this. However,xdotool
is not reliably usable for this purpose. Ifxdotool
is used to send a key event corresponding to an existing keybind, the key event will unreliably go either to the targeted window, or to Qtile which grabs the key. To avoid this, the key would need to be ungrabbed and regrabbed, as the X11 backend does for its Xtest events. However, this is not an externally exposed API, and so this can't be done from outside Qtile.The
handle_KeyPress
method in the X11 backend has the following comment:This seems like a weak reason to leave out this functionality. The handle_KeyPress method is already manually forwarding key events on to the focused window, via the Xtest extension. Handling modifiers properly for simulated keys would require only a small extension to this code, and would allow for important new functionality that is currently not available.
I intend to submit a pull request for this issue soon. Questions I'm not clear on:
simulate_keypress
command really should send the event to the window by default, but this would break backward compatibility. One option would be to add an option parameterforward_to_window
, or similar, which defaults to False, in order to control this behavior. It might also be useful to expose a similar command on the Window object, which forwards a key directly to that window (presumably ignoring Qtile keybindings). There's a question of how to distinguish the new behavior, of sending key events to windows, from the old simulate_keypress behavior of exercising the Qtile keybinds.Beta Was this translation helpful? Give feedback.
All reactions