Fixed a bug with sleep mode, was not suspending review keys for sleeping applications.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Storm Dragon <storm_dragon@stormux.org>
|
# Maintainer: Storm Dragon <storm_dragon@stormux.org>
|
||||||
|
|
||||||
pkgname=cthulhu
|
pkgname=cthulhu
|
||||||
pkgver=2026.01.26
|
pkgver=2026.02.16
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Desktop-agnostic screen reader with plugin system, forked from Orca"
|
pkgdesc="Desktop-agnostic screen reader with plugin system, forked from Orca"
|
||||||
url="https://git.stormux.org/storm/cthulhu"
|
url="https://git.stormux.org/storm/cthulhu"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
project('cthulhu',
|
project('cthulhu',
|
||||||
version: '2026.01.26-master',
|
version: '2026.02.16-testing',
|
||||||
meson_version: '>= 1.0.0',
|
meson_version: '>= 1.0.0',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -23,5 +23,5 @@
|
|||||||
# Forked from Orca screen reader.
|
# Forked from Orca screen reader.
|
||||||
# Cthulhu project: https://git.stormux.org/storm/cthulhu
|
# Cthulhu project: https://git.stormux.org/storm/cthulhu
|
||||||
|
|
||||||
version = "2026.01.26"
|
version = "2026.02.16"
|
||||||
codeName = "master"
|
codeName = "testing"
|
||||||
|
|||||||
@@ -844,6 +844,11 @@ class KeyboardEvent(InputEvent):
|
|||||||
"shouldConsume: No handler found",
|
"shouldConsume: No handler found",
|
||||||
reason="no-handler", timestamp=True)
|
reason="no-handler", timestamp=True)
|
||||||
|
|
||||||
|
if self._isSleepModeActive():
|
||||||
|
if self._isSleepModeToggleHandler():
|
||||||
|
return True, 'Sleep mode toggle command'
|
||||||
|
return False, 'Sleep mode active'
|
||||||
|
|
||||||
self._script.updateKeyboardEventState(self, self._handler)
|
self._script.updateKeyboardEventState(self, self._handler)
|
||||||
scriptConsumes = self._script.shouldConsumeKeyboardEvent(self, self._handler)
|
scriptConsumes = self._script.shouldConsumeKeyboardEvent(self, self._handler)
|
||||||
if globalHandlerUsed:
|
if globalHandlerUsed:
|
||||||
@@ -881,6 +886,35 @@ class KeyboardEvent(InputEvent):
|
|||||||
return None
|
return None
|
||||||
return global_bindings.getInputHandler(self)
|
return global_bindings.getInputHandler(self)
|
||||||
|
|
||||||
|
def _isSleepModeActive(self):
|
||||||
|
"""Returns True if the script for this event is in sleep mode."""
|
||||||
|
|
||||||
|
if not self._script:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if "scripts.sleepmode" in self._script.__module__:
|
||||||
|
return True
|
||||||
|
|
||||||
|
app = getattr(self._script, "app", None)
|
||||||
|
if app is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
from . import sleep_mode_manager
|
||||||
|
manager = sleep_mode_manager.getManager()
|
||||||
|
return bool(manager and manager.isActiveForApp(app))
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _isSleepModeToggleHandler(self):
|
||||||
|
"""Returns True if the resolved handler toggles sleep mode."""
|
||||||
|
|
||||||
|
if not self._handler or not self._handler.function:
|
||||||
|
return False
|
||||||
|
|
||||||
|
functionName = getattr(self._handler.function, "__name__", "")
|
||||||
|
return "toggleSleepMode" in functionName
|
||||||
|
|
||||||
def didConsume(self):
|
def didConsume(self):
|
||||||
"""Returns True if this event was consumed."""
|
"""Returns True if this event was consumed."""
|
||||||
|
|
||||||
|
|||||||
@@ -282,6 +282,15 @@ class ScriptManager:
|
|||||||
Returns an instance of a Script.
|
Returns an instance of a Script.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if app:
|
||||||
|
try:
|
||||||
|
from . import sleep_mode_manager
|
||||||
|
sleepModeManager = sleep_mode_manager.getManager()
|
||||||
|
if sleepModeManager and sleepModeManager.isActiveForApp(app):
|
||||||
|
return self.get_or_create_sleep_mode_script(app)
|
||||||
|
except Exception as error:
|
||||||
|
_log_tokens(["Could not check sleep mode for", app, ":", error], "sleep-mode-check-failed")
|
||||||
|
|
||||||
customScript = None
|
customScript = None
|
||||||
appScript = None
|
appScript = None
|
||||||
toolkitScript = None
|
toolkitScript = None
|
||||||
|
|||||||
@@ -75,9 +75,6 @@ class Script(default.Script):
|
|||||||
"""Called when this script is deactivated."""
|
"""Called when this script is deactivated."""
|
||||||
|
|
||||||
debug.printMessage(debug.LEVEL_INFO, "SLEEP MODE SCRIPT: Deactivating", True)
|
debug.printMessage(debug.LEVEL_INFO, "SLEEP MODE SCRIPT: Deactivating", True)
|
||||||
|
|
||||||
# Restore key grabs
|
|
||||||
self.addKeyGrabs()
|
|
||||||
cthulhu_modifier_manager.getManager().refreshCthulhuModifiers("Exiting sleep mode.")
|
cthulhu_modifier_manager.getManager().refreshCthulhuModifiers("Exiting sleep mode.")
|
||||||
|
|
||||||
super().deactivate()
|
super().deactivate()
|
||||||
@@ -86,18 +83,23 @@ class Script(default.Script):
|
|||||||
"""Remove key grabs except for sleep mode toggle."""
|
"""Remove key grabs except for sleep mode toggle."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# First remove all grabs inherited from default activation,
|
||||||
|
# including modifier grabs.
|
||||||
|
super().removeKeyGrabs()
|
||||||
|
|
||||||
self.grab_ids = []
|
self.grab_ids = []
|
||||||
for keyBinding in self.keyBindings:
|
for keyBinding in self.keyBindings.keyBindings:
|
||||||
if hasattr(keyBinding, 'handler') and hasattr(keyBinding.handler, 'function'):
|
if hasattr(keyBinding, 'handler') and hasattr(keyBinding.handler, 'function'):
|
||||||
if hasattr(keyBinding.handler.function, '__name__'):
|
if hasattr(keyBinding.handler.function, '__name__'):
|
||||||
if 'toggleSleepMode' in keyBinding.handler.function.__name__:
|
if 'toggleSleepMode' in keyBinding.handler.function.__name__:
|
||||||
# Keep sleep mode toggle
|
# Keep sleep mode toggle
|
||||||
try:
|
try:
|
||||||
import cthulhu
|
import cthulhu
|
||||||
grab_id = cthulhu.addKeyGrab(keyBinding)
|
grabIds = cthulhu.addKeyGrab(keyBinding)
|
||||||
if grab_id:
|
if grabIds:
|
||||||
self.grab_ids.append(grab_id)
|
for grabId in grabIds:
|
||||||
debug.printMessage(debug.LEVEL_INFO, f"SLEEP MODE: Kept sleep toggle key grab: {grab_id}", True)
|
self.grab_ids.append(grabId)
|
||||||
|
debug.printMessage(debug.LEVEL_INFO, f"SLEEP MODE: Kept sleep toggle key grab: {grabId}", True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug.printMessage(debug.LEVEL_INFO, f"SLEEP MODE: Error keeping key grab: {e}", True)
|
debug.printMessage(debug.LEVEL_INFO, f"SLEEP MODE: Error keeping key grab: {e}", True)
|
||||||
else:
|
else:
|
||||||
@@ -106,27 +108,6 @@ class Script(default.Script):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug.printMessage(debug.LEVEL_INFO, f"SLEEP MODE: Error in removeKeyGrabs: {e}", True)
|
debug.printMessage(debug.LEVEL_INFO, f"SLEEP MODE: Error in removeKeyGrabs: {e}", True)
|
||||||
|
|
||||||
def addKeyGrabs(self):
|
|
||||||
"""Add back all key grabs."""
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Remove our limited grabs first
|
|
||||||
if hasattr(self, 'grab_ids'):
|
|
||||||
import cthulhu
|
|
||||||
for grab_id in self.grab_ids:
|
|
||||||
try:
|
|
||||||
cthulhu.removeKeyGrab(grab_id)
|
|
||||||
debug.printMessage(debug.LEVEL_INFO, f"SLEEP MODE: Removed key grab: {grab_id}", True)
|
|
||||||
except Exception as e:
|
|
||||||
debug.printMessage(debug.LEVEL_INFO, f"SLEEP MODE: Error removing key grab {grab_id}: {e}", True)
|
|
||||||
self.grab_ids = []
|
|
||||||
|
|
||||||
# Let the parent class restore all grabs
|
|
||||||
super().addKeyGrabs()
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
debug.printMessage(debug.LEVEL_INFO, f"SLEEP MODE: Error in addKeyGrabs: {e}", True)
|
|
||||||
|
|
||||||
# Block common event handlers as an additional layer of protection
|
# Block common event handlers as an additional layer of protection
|
||||||
def onCaretMoved(self, event):
|
def onCaretMoved(self, event):
|
||||||
"""Block caret movement events."""
|
"""Block caret movement events."""
|
||||||
|
|||||||
Reference in New Issue
Block a user