Hopefully fix some wayland keyboard stuff.

This commit is contained in:
Storm Dragon
2026-04-08 03:37:50 -04:00
parent 2d9790de88
commit eeb7bd046f
6 changed files with 124 additions and 12 deletions
+2 -2
View File
@@ -172,7 +172,8 @@ class LearnModePresenter:
and event.getHandler() is None:
cthulhu_state.activeScript.phoneticSpellCurrentItem(event.event_string)
if event.event_string == "Escape":
key_name = event.keyval_name or event.event_string
if key_name == "Escape":
self.quit(script=None, event=event)
return True
@@ -404,4 +405,3 @@ def getPresenter():
_presenter = LearnModePresenter(cthulhu.cthulhuApp)
return _presenter
+12 -10
View File
@@ -23,6 +23,7 @@ class ByeCthulhu(Plugin):
super().__init__(*args, **kwargs)
logger.info("ByeCthulhu plugin initialized")
self._signal_handler_id = None
self._is_connected = False
@cthulhu_hookimpl
def activate(self, plugin=None):
@@ -33,13 +34,14 @@ class ByeCthulhu(Plugin):
logger.info("Activating ByeCthulhu plugin")
try:
# Connect to the stop-application-completed signal
signal_manager = self.app.getSignalManager()
self._signal_handler_id = signal_manager.connectSignal(
"stop-application-completed",
self.process,
"default" # Add profile parameter
)
if not self._is_connected:
signal_manager = self.app.getSignalManager()
self._signal_handler_id = signal_manager.connectSignal(
"stop-application-completed",
self.process,
"default" # Add profile parameter
)
self._is_connected = True
except Exception as e:
logger.error(f"Error activating ByeCthulhu plugin: {e}")
@@ -52,14 +54,14 @@ class ByeCthulhu(Plugin):
logger.info("Deactivating ByeCthulhu plugin")
try:
# Disconnect signal if we have an ID
if self._signal_handler_id is not None:
if self._is_connected and self._signal_handler_id is not None:
signal_manager = self.app.getSignalManager()
# Use disconnectSignalByFunction instead since disconnectSignal doesn't exist
signal_manager.disconnectSignalByFunction(
self.process
)
self._signal_handler_id = None
self._is_connected = False
except Exception as e:
logger.error(f"Error deactivating ByeCthulhu plugin: {e}")
@@ -72,4 +74,4 @@ class ByeCthulhu(Plugin):
state.activeScript.presentationInterrupt()
state.activeScript.presentMessage(messages.STOP_CTHULHU, resetStyles=False)
except Exception as e:
logger.error(f"Error in ByeCthulhu process: {e}")
logger.error(f"Error in ByeCthulhu process: {e}")
+4
View File
@@ -597,6 +597,10 @@ class Script(script.Script):
""" Removes this script's AT-SPI key grabs. """
msg = "DEFAULT: removing key grabs"
debug.printMessage(debug.LEVEL_INFO, msg, True)
if cthulhu_state.device is None:
self.grab_ids = []
self._modifierGrabIds = []
return
for id in self.grab_ids:
cthulhu.removeKeyGrab(id)
self.grab_ids = []