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.app = app
|
||||||
self._gestureBindings = {}
|
self._gestureBindings = {}
|
||||||
|
|
||||||
def registerGestureByString(self, function, name, gestureString,
|
def registerGestureByString(self, function, name, gestureString, inputEventType='default', normalizer='cthulhu', learnModeEnabled=True, contextName=None):
|
||||||
inputEventType='default', normalizer='cthulhu',
|
|
||||||
learnModeEnabled=True, contextName=None):
|
|
||||||
"""Register a gesture by string.
|
"""Register a gesture by string.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
@ -95,7 +93,12 @@ class APIHelper:
|
|||||||
self.description = description
|
self.description = description
|
||||||
|
|
||||||
def __call__(self, script, inputEvent):
|
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)
|
handler = GestureHandler(function, name)
|
||||||
|
|
||||||
@ -108,6 +111,8 @@ class APIHelper:
|
|||||||
keybindings.defaultModifierMask,
|
keybindings.defaultModifierMask,
|
||||||
modifiers,
|
modifiers,
|
||||||
handler)
|
handler)
|
||||||
|
|
||||||
|
# Add the binding to the active script
|
||||||
bindings.add(binding)
|
bindings.add(binding)
|
||||||
|
|
||||||
# Store binding for later reference
|
# Store binding for later reference
|
||||||
@ -115,6 +120,13 @@ class APIHelper:
|
|||||||
self._gestureBindings[contextName] = []
|
self._gestureBindings[contextName] = []
|
||||||
self._gestureBindings[contextName].append(binding)
|
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 binding
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@ -132,10 +144,17 @@ class APIHelper:
|
|||||||
bindings = cthulhu_state.activeScript.getKeyBindings()
|
bindings = cthulhu_state.activeScript.getKeyBindings()
|
||||||
bindings.remove(binding)
|
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 contextName in self._gestureBindings:
|
||||||
if binding in self._gestureBindings[contextName]:
|
if binding in self._gestureBindings[contextName]:
|
||||||
self._gestureBindings[contextName].remove(binding)
|
self._gestureBindings[contextName].remove(binding)
|
||||||
|
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
|
@ -23,5 +23,5 @@
|
|||||||
# Fork of Orca Screen Reader (GNOME)
|
# Fork of Orca Screen Reader (GNOME)
|
||||||
# Original source: https://gitlab.gnome.org/GNOME/orca
|
# Original source: https://gitlab.gnome.org/GNOME/orca
|
||||||
|
|
||||||
version = "2025.04.11"
|
version = "2025.04.14"
|
||||||
codeName = "testing"
|
codeName = "testing"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user