Add native per-program hook exclusions
Parse --exclude-hook-program in the helper, gate foreground hooks and dialog reading by program, and forward the list to the 32-bit hook host. Emit the flags from the Orca extension and cover the matching, validation, and manager behavior with regression tests.
This commit is contained in:
1 parent
0db42de77e
commit
78b70e1ab9
11 files changed
+278
-8
No files matched your search
@@ -16,7 +16,8 @@ from orca import debug, presentation_manager, typing_echo_presenter
|
||||
from orca.extension import Extension
|
||||
from orca.extension_preferences import ExtensionPreference
|
||||
|
||||
from .manager import HelperManager, controller_only_arguments, extra_helper_arguments
|
||||
from .manager import (HelperManager, controller_only_arguments,
|
||||
excluded_hook_arguments, extra_helper_arguments)
|
||||
from .presenter import WineEvent, WineEventPresenter
|
||||
from .review import DialogReader, gio_capture
|
||||
from .service import INTERFACE, OBJECT_PATH, WineAccessInterface
|
||||
@@ -75,7 +76,8 @@ class WineAccess(Extension):
|
||||
|
||||
always = self.settings.get("controller-only", False)
|
||||
listed = self.settings.get("controller-only-programs", [])
|
||||
return controller_only_arguments(programs, listed, always is True)
|
||||
return [*excluded_hook_arguments(listed),
|
||||
*controller_only_arguments(programs, listed, always is True)]
|
||||
|
||||
# Extension lifecycle
|
||||
|
||||
|
||||
@@ -104,6 +104,27 @@ def controller_only_arguments(programs: set[str], listed,
|
||||
return []
|
||||
|
||||
|
||||
def excluded_hook_arguments(listed) -> list[str]:
|
||||
"""--exclude-hook-program flags for the listed executable names.
|
||||
|
||||
The helper itself enforces these from its first foreground poll, so a
|
||||
listed program's thread is never hooked even in the passes before
|
||||
discovery sees it and the whole-prefix controller-only restart lands.
|
||||
Validation mirrors Cthulhu's settings rules: bare executable names
|
||||
only, passed lower-case, at most as many as the helper stores.
|
||||
"""
|
||||
|
||||
if not isinstance(listed, (list, tuple)):
|
||||
return []
|
||||
arguments: list[str] = []
|
||||
names = sorted(name for name in listed if isinstance(name, str))
|
||||
for name in names[:256]:
|
||||
if (name and len(name) <= 255 and name.strip() == name
|
||||
and not any(char in name for char in "\0\r\n/\\")):
|
||||
arguments += ["--exclude-hook-program", name.lower()]
|
||||
return arguments
|
||||
|
||||
|
||||
def find_helper() -> str | None:
|
||||
for path in helper_candidates():
|
||||
if os.access(path, os.X_OK):
|
||||
|
||||
Reference in new issue
Block a user