From 39dca0574a4aea19d8b063b630f4094ed00e2cba Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 19 Apr 2025 15:39:43 -0400 Subject: [PATCH] Improve key detection in registerGestureByString --- src/cthulhu/cthulhu.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/cthulhu/cthulhu.py b/src/cthulhu/cthulhu.py index e22e693..d927d69 100644 --- a/src/cthulhu/cthulhu.py +++ b/src/cthulhu/cthulhu.py @@ -60,19 +60,16 @@ class APIHelper: from . import keybindings key_parts = key.lower().split("+") - # Determine appropriate modifier mask + # Start with the base Cthulhu modifier modifiers = keybindings.CTHULHU_MODIFIER_MASK # Extract the final key (without modifiers) final_key = key_parts[-1] - # Check for additional modifiers + # Check for additional modifiers and combine them properly if "shift" in key_parts: + # Use the pre-defined combined mask rather than trying to OR them modifiers = keybindings.CTHULHU_SHIFT_MODIFIER_MASK - elif "ctrl" in key_parts or "control" in key_parts: - modifiers = keybindings.CTHULHU_CTRL_MODIFIER_MASK - elif "alt" in key_parts: - modifiers = keybindings.CTHULHU_ALT_MODIFIER_MASK # Create a keybinding handler class GestureHandler: @@ -104,8 +101,8 @@ class APIHelper: bindings.add(binding) # Store binding for later reference - if contextName not in self._gestureBindings: - self._gestureBindings[contextName] = [] + if contextName not in self._gestureBindings: + self._gestureBindings[contextName] = [] self._gestureBindings[contextName].append(binding) # Register key grab at the system level