summarylogtreecommitdiffstats
path: root/revert.patch
blob: 0cd8bfbe87eebc5bc43e49d4761e587277b59a68 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
From 66ab9e6505df39783fe95142097a8516ed14c2cf Mon Sep 17 00:00:00 2001
From: Len Trigg <lenbok@gmail.com>
Date: Fri, 22 May 2020 10:36:33 +1200
Subject: [PATCH] Revert "Merge pull request #71 from rbreaves/master"

Fixes #74, #80, #81

This reverts commit e3dceddf045a1bb98b8e4016e4fa7b001f14736f, reversing
changes made to 123432bb038f35a8a26a6967fbf5c559edd48708.
---
 xkeysnail/output.py    | 19 +++++--------------
 xkeysnail/transform.py | 20 +-------------------
 2 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/xkeysnail/output.py b/xkeysnail/output.py
index 4605ab3..d8f01f9 100644
--- a/xkeysnail/output.py
+++ b/xkeysnail/output.py
@@ -12,9 +12,6 @@ _uinput = UInput()
 _pressed_modifier_keys = set()
 _pressed_keys = set()
 
-def output_modifier_key():
-    return _pressed_modifier_keys
-
 def update_modifier_key_pressed(key, action):
     if key in Modifier.get_all_keys():
         if action.is_pressed():
@@ -60,17 +57,8 @@ def send_combo(combo):
                 missing_modifiers.remove(modifier)
 
     for modifier_key in extra_modifier_keys:
-        # Do not release new modifier
-        # until original modifier is released
-        # unless no modifier is the new mapping
-        if len(combo.modifiers) > 0:
-            for modifier in combo.modifiers:
-                if modifier_key != str(modifier.get_key()):
-                    send_key_action(modifier_key, Action.RELEASE)
-                    released_modifiers_keys.append(modifier_key)
-        else:
-            send_key_action(modifier_key, Action.RELEASE)
-            released_modifiers_keys.append(modifier_key)
+        send_key_action(modifier_key, Action.RELEASE)
+        released_modifiers_keys.append(modifier_key)
 
     pressed_modifier_keys = []
     for modifier in missing_modifiers:
@@ -82,6 +70,9 @@ def send_combo(combo):
 
     send_key_action(combo.key, Action.RELEASE)
 
+    for modifier in reversed(pressed_modifier_keys):
+        send_key_action(modifier, 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..e1dfea2 100644
--- a/xkeysnail/transform.py
+++ b/xkeysnail/transform.py
@@ -4,7 +4,7 @@ import itertools
 from time import time
 from inspect import signature
 from .key import Action, Combo, Key, Modifier
-from .output import send_combo, send_key_action, send_key, is_pressed, output_modifier_key
+from .output import send_combo, send_key_action, send_key, is_pressed
 
 __author__ = 'zh'
 
@@ -12,7 +12,6 @@ __author__ = 'zh'
 
 import Xlib.display
 
-_release_combo = False
 
 def get_active_window_wm_class(display=Xlib.display.Display()):
     """Get active window's WM_CLASS"""
@@ -418,31 +417,14 @@ def on_event(event, device_name, quiet):
 
 
 def on_key(key, action, wm_class=None, quiet=False):
-    global _release_combo
-    output_mods = output_modifier_key().copy()
     if key in Modifier.get_all_keys():
         update_pressed_modifier_keys(key, action)
         send_key_action(key, action)
-        # Release mapped modifier only when physical mod
-        # 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)
     elif not action.is_pressed():
         if is_pressed(key):
             send_key_action(key, action)
-        # Unset modifiers used in nested mode_maps
-        elif _release_combo and len(output_mods) > 0:
-            _release_combo = False
-            for output_key in output_mods:
-                update_pressed_modifier_keys(output_key, action)
-                send_key_action(output_key, action)
     else:
         transform_key(key, action, wm_class=wm_class, quiet=quiet)
-    # Will unset mode maps modifiers on next combo
-    if _mode_maps != None:
-        _release_combo = True
 
 
 def transform_key(key, action, wm_class=None, quiet=False):
-- 
2.27.0