From c27035a029cdcbfb854ea0760fd083b5d8870c6d Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 4 Dec 2023 19:17:06 +0100 Subject: Use of orderedDict in order to give higher priority to custom layer --- xlib.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'xlib.py') diff --git a/xlib.py b/xlib.py index bc2032c..4577e96 100644 --- a/xlib.py +++ b/xlib.py @@ -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. -- cgit v1.2.3