Another attempt at fixing plugin keyboard shortcuts.
This commit is contained in:
parent
0580dda131
commit
0347b7feea
@ -47,9 +47,7 @@ class APIHelper:
|
||||
self.app = app
|
||||
self._gestureBindings = {}
|
||||
|
||||
def registerGestureByString(self, function, name, gestureString,
|
||||
inputEventType='default', normalizer='cthulhu',
|
||||
learnModeEnabled=True, contextName=None):
|
||||
def registerGestureByString(self, function, name, gestureString, inputEventType='default', normalizer='cthulhu', learnModeEnabled=True, contextName=None):
|
||||
"""Register a gesture by string.
|
||||
|
||||
Arguments:
|
||||
@ -95,7 +93,12 @@ class APIHelper:
|
||||
self.description = description
|
||||
|
||||
def __call__(self, script, inputEvent):
|
||||
return self.function(script, inputEvent)
|
||||
try:
|
||||
return function(script, inputEvent)
|
||||
except Exception as e:
|
||||
import logging
|
||||
logging.getLogger(__name__).error(f"Error in keybinding handler: {e}")
|
||||
return True
|
||||
|
||||
handler = GestureHandler(function, name)
|
||||
|
||||
@ -108,6 +111,8 @@ class APIHelper:
|
||||
keybindings.defaultModifierMask,
|
||||
modifiers,
|
||||
handler)
|
||||
|
||||
# Add the binding to the active script
|
||||
bindings.add(binding)
|
||||
|
||||
# Store binding for later reference
|
||||
@ -115,6 +120,13 @@ class APIHelper:
|
||||
self._gestureBindings[contextName] = []
|
||||
self._gestureBindings[contextName].append(binding)
|
||||
|
||||
# Register key grab at the system level
|
||||
grab_ids = self.app.addKeyGrab(binding)
|
||||
|
||||
# For later removal
|
||||
if grab_ids:
|
||||
binding._grab_ids = grab_ids
|
||||
|
||||
return binding
|
||||
|
||||
return None
|
||||
@ -132,10 +144,17 @@ class APIHelper:
|
||||
bindings = cthulhu_state.activeScript.getKeyBindings()
|
||||
bindings.remove(binding)
|
||||
|
||||
# Remove from our tracking
|
||||
# Remove key grab at system level
|
||||
if hasattr(binding, '_grab_ids'):
|
||||
for grab_id in binding._grab_ids:
|
||||
self.app.removeKeyGrab(grab_id)
|
||||
|
||||
# Remove from tracking
|
||||
if contextName in self._gestureBindings:
|
||||
if binding in self._gestureBindings[contextName]:
|
||||
self._gestureBindings[contextName].remove(binding)
|
||||
|
||||
|
||||
import gi
|
||||
import importlib
|
||||
import os
|
||||
|
@ -23,5 +23,5 @@
|
||||
# Fork of Orca Screen Reader (GNOME)
|
||||
# Original source: https://gitlab.gnome.org/GNOME/orca
|
||||
|
||||
version = "2025.04.11"
|
||||
version = "2025.04.14"
|
||||
codeName = "testing"
|
||||
|
Loading…
x
Reference in New Issue
Block a user