Another another attempt to fix the plugin keybindings.
This commit is contained in:
parent
a21f1aa13b
commit
314aa18a1b
@ -113,6 +113,13 @@ class EventManager:
|
|||||||
self._processNewKeyboardEvent)
|
self._processNewKeyboardEvent)
|
||||||
self.newKeyHandlingActive = True
|
self.newKeyHandlingActive = True
|
||||||
|
|
||||||
|
# Notify plugin system that device is now available for keybinding registration
|
||||||
|
from . import cthulhu
|
||||||
|
if hasattr(cthulhu, 'cthulhuApp') and cthulhu.cthulhuApp:
|
||||||
|
plugin_manager = cthulhu.cthulhuApp.getPluginSystemManager()
|
||||||
|
if plugin_manager:
|
||||||
|
plugin_manager.register_plugin_keybindings_with_active_script()
|
||||||
|
|
||||||
def activateLegacyKeyHandling(self):
|
def activateLegacyKeyHandling(self):
|
||||||
if not self.legacyKeyHandlingActive:
|
if not self.legacyKeyHandlingActive:
|
||||||
self.registerKeystrokeListener(self._processKeyboardEvent)
|
self.registerKeystrokeListener(self._processKeyboardEvent)
|
||||||
|
@ -185,11 +185,17 @@ class PluginSystemManager:
|
|||||||
# Check if binding already exists to avoid duplicates
|
# Check if binding already exists to avoid duplicates
|
||||||
if not active_script.getKeyBindings().hasKeyBinding(binding, "keysNoMask"):
|
if not active_script.getKeyBindings().hasKeyBinding(binding, "keysNoMask"):
|
||||||
active_script.getKeyBindings().add(binding)
|
active_script.getKeyBindings().add(binding)
|
||||||
|
# Force recalculation of keycode if it wasn't set when device was None
|
||||||
|
if not binding.keycode and binding.keysymstring:
|
||||||
|
from . import keybindings
|
||||||
|
binding.keycode = keybindings.getKeycode(binding.keysymstring)
|
||||||
# Register key grab at system level - this was missing!
|
# Register key grab at system level - this was missing!
|
||||||
from . import cthulhu
|
from . import cthulhu
|
||||||
grab_ids = cthulhu.addKeyGrab(binding)
|
grab_ids = cthulhu.addKeyGrab(binding)
|
||||||
if grab_ids:
|
if grab_ids:
|
||||||
binding._grab_ids = grab_ids
|
binding._grab_ids = grab_ids
|
||||||
|
else:
|
||||||
|
logger.warning(f"Failed to create key grab for {binding.keysymstring} - device may not be available")
|
||||||
|
|
||||||
def _on_settings_changed(self, app=None):
|
def _on_settings_changed(self, app=None):
|
||||||
"""Re-register all plugin keybindings when settings change."""
|
"""Re-register all plugin keybindings when settings change."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user