summarylogtreecommitdiffstats
path: root/modifiers.patch
blob: c70f9b85bf09a91e1c560fd898d89a4fb034cdea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From bc580120f9e8e8cfea0b68d9a3cf2af670a7f2f2 Mon Sep 17 00:00:00 2001
From: Ben Reaves <rbreaves@gmail.com>
Date: Fri, 1 May 2020 16:33:53 -0500
Subject: [PATCH] - Persistent modifiers on partial release of modifier combo.
 Fixes #74

---
 xkeysnail/output.py    | 6 +++++-
 xkeysnail/transform.py | 6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/xkeysnail/output.py b/xkeysnail/output.py
index 4605ab3..a7f2a95 100644
--- a/xkeysnail/output.py
+++ b/xkeysnail/output.py
@@ -76,12 +76,16 @@ def send_combo(combo):
     for modifier in missing_modifiers:
         modifier_key = modifier.get_key()
         send_key_action(modifier_key, Action.PRESS)
-        pressed_modifier_keys.append(modifier_key)
 
     send_key_action(combo.key, Action.PRESS)
 
     send_key_action(combo.key, Action.RELEASE)
 
+    # Release modifiers that are not physically held - ONLY
+    for modifier in missing_modifiers:
+        modifier_key = modifier.get_key()
+        send_key_action(modifier_key, Action.RELEASE)
+
     for modifier in reversed(released_modifiers_keys):
         send_key_action(modifier, Action.PRESS)
 
diff --git a/xkeysnail/transform.py b/xkeysnail/transform.py
index 76ca6f2..e3ad6fd 100644
--- a/xkeysnail/transform.py
+++ b/xkeysnail/transform.py
@@ -427,8 +427,10 @@ def on_key(key, action, wm_class=None, quiet=False):
         # is released
         if str(key) != "Key.LEFT_SHIFT" and str(key) != "Key.RIGHT_SHIFT":
             for output_key in output_mods:
-                update_pressed_modifier_keys(output_key, action)
-                send_key_action(output_key, action)
+                # Release modifiers that are not physically held - ONLY
+                if not is_pressed(output_key):
+                    update_pressed_modifier_keys(output_key, action)
+                    send_key_action(output_key, action)
     elif not action.is_pressed():
         if is_pressed(key):
             send_key_action(key, action)
-- 
2.26.2