From 7663e204bba2b4a1d578a365d982add369db652b Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Fri, 16 Sep 2022 07:57:49 -0400 Subject: [PATCH] rules: don't check modifiers for KeyPress actions that are not clicks --- docs/rules.md | 8 +++++--- lib/logitech_receiver/diversion.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/rules.md b/docs/rules.md index 5a37cdbd..b45b265d 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -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 diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py index 2af37ed3..d1b5a7d1 100644 --- a/lib/logitech_receiver/diversion.py +++ b/lib/logitech_receiver/diversion.py @@ -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)