diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2023-12-04 19:17:06 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2023-12-04 19:17:06 +0100 |
commit | c27035a029cdcbfb854ea0760fd083b5d8870c6d (patch) | |
tree | 5774bbab92e471ebac547e726286cb70b4d3c49b /xlib.py | |
parent | 78a31a0768b0c2b6232514e5ffbfd26c7901c4b0 (diff) |
Use of orderedDict in order to give higher priority to custom layer
Diffstat (limited to 'xlib.py')
-rw-r--r-- | xlib.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -54,12 +54,17 @@ class Listener(Thread): self.active_window = window_name
found = False
- for pattern, code in self.mapping.items():
+
+ # Create a reveverse dictionnary for getting the users added first
+ # In python, the elements in a dictionnary are sorted by insertion
+ # order, so we get the user added first here
+ for pattern in reversed(self.mapping):
# Ignore the default layout
if pattern == "default":
continue
- if not (pattern in window_name or pattern in class_name):
+ if not (pattern.lstrip() in window_name or pattern.lstrip() in class_name):
continue
+ code = self.mapping[pattern]
# We found something. At this point, even if we do not update
# the layer (because it is the same as the previous) we do not
# switch back to the default layer.
|