Another another attempt to fix the plugin keybindings.

This commit is contained in:
Storm Dragon 2025-06-05 03:42:02 -04:00
parent a21f1aa13b
commit 314aa18a1b
2 changed files with 13 additions and 0 deletions

View File

@ -112,6 +112,13 @@ class EventManager:
cthulhu_state.device.key_watcher = cthulhu_state.device.add_key_watcher(
self._processNewKeyboardEvent)
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):
if not self.legacyKeyHandlingActive:

View File

@ -185,11 +185,17 @@ class PluginSystemManager:
# Check if binding already exists to avoid duplicates
if not active_script.getKeyBindings().hasKeyBinding(binding, "keysNoMask"):
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!
from . import cthulhu
grab_ids = cthulhu.addKeyGrab(binding)
if 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):
"""Re-register all plugin keybindings when settings change."""