rules: don't check modifiers for KeyPress actions that are not clicks

This commit is contained in:
Peter F. Patel-Schneider 2022-09-16 07:57:49 -04:00
parent 500ae07363
commit 7663e204bb
2 changed files with 7 additions and 5 deletions

View File

@ -187,9 +187,11 @@ then Solaar will add keypresses to produce that keysymbol,
e.g., simulating a left shift keypress to get "A" instead of "a".
If a key symbol is not available in the current keymap or needs other shift-like keys,
then Solaar cannot simulate it.
If Solaar can determine the current key modifiers (shift, control, etc.)
any key symbols that correspond to these modifier keys are not pressed,
so if the shift key is currently down on a keyboard Solaar will not bother to simulate a shift key.
Under X11 Solaar can determine the current key modifiers (shift, control, etc.).
Any key symbols that correspond to these modifier keys are not depressed and released when clicking.
So if the shift key is currently down on a keyboard Solaar will not bother to simulate a shift key.
Under Wayland this check cannot be done so the net result of a `KeyPress` action that is not a `depress` or a `release`
and that contains modifier keys might be to release the modifier keys.
Simulating input in Linux is complex.
Solaar has to try to determine which keyboard key corresponds to which input character as it cannot directly

View File

@ -925,14 +925,14 @@ class KeyPress(Action):
(keycode, level) = self.keysym_to_keycode(k, modifiers)
if keycode is None:
_log.warn('rule KeyPress key symbol not currently available %s', self)
elif self.needed(keycode, modifiers):
elif self.action != self.CLICK or self.needed(keycode, modifiers): # only check needed when clicking
self.mods(level, modifiers, _KEY_PRESS)
simulate_key(keycode, _KEY_PRESS)
def keyUp(self, keysyms, modifiers):
for k in keysyms:
(keycode, level) = self.keysym_to_keycode(k, modifiers)
if keycode and self.needed(keycode, modifiers):
if keycode and (self.action != self.CLICK or self.needed(keycode, modifiers)): # only check needed when clicking
simulate_key(keycode, _KEY_RELEASE)
self.mods(level, modifiers, _KEY_RELEASE)