From 1c701333ad32cf4e0737a301db90c9d593a28662 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 12:37:12 -0700 Subject: [PATCH] fix(nix): focus_follows_mouse names no implementation and no compositor The scenario toggled with --implementation windows on both ports, and its settle time said it was KWin's 200 ms. The default of the command is each port's own implementation, so the flag goes, and the settle is a named wait that is longer than what either port needs. --- .../core/scenarios/focus_follows_mouse.py | 15 ++++++++++---- nix/tests/vm/lib/tests/test_focus_moving.py | 20 +++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/nix/tests/vm/lib/komorebi_vm/core/scenarios/focus_follows_mouse.py b/nix/tests/vm/lib/komorebi_vm/core/scenarios/focus_follows_mouse.py index aca4d4f1..b2324d99 100644 --- a/nix/tests/vm/lib/komorebi_vm/core/scenarios/focus_follows_mouse.py +++ b/nix/tests/vm/lib/komorebi_vm/core/scenarios/focus_follows_mouse.py @@ -16,10 +16,16 @@ def _focused(platform: Platform, client: Client) -> bool: return window is not None and window.focused +# how long a setting is given to be taken up before the pointer is moved. A port may read it a +# moment after it is written, or follow the pointer after a delay of its own: this is more than +# either, and it is scaled for the host like every wait +SETTLE = 1 + + def _settle(platform: Platform) -> None: - """Gives a platform the time to take up a setting: KWin reads its focus policy about 200 ms - after it is written, and a pointer that is moved before that is moved under the old one.""" - platform.wait_for(lambda: False, timeout=1) + """Gives the platform the time to take up a setting: a pointer that is moved before is moved + under the old one.""" + platform.wait_for(lambda: False, timeout=SETTLE) def run(platform: Platform, checks: Checks, first: Client, second: Client) -> None: @@ -56,7 +62,8 @@ def run(platform: Platform, checks: Checks, first: Client, second: Client) -> No platform.wait_for(lambda: platform.state().focused_title() == first.title, timeout=10), ) - platform.komorebic("toggle-focus-follows-mouse", "--implementation", "windows") + # no `--implementation`: each port has one, and the command's default is it + platform.komorebic("toggle-focus-follows-mouse") _settle(platform) platform.pointer.move(*b) checks.check( diff --git a/nix/tests/vm/lib/tests/test_focus_moving.py b/nix/tests/vm/lib/tests/test_focus_moving.py index 5dd492e9..303c04ae 100644 --- a/nix/tests/vm/lib/tests/test_focus_moving.py +++ b/nix/tests/vm/lib/tests/test_focus_moving.py @@ -864,3 +864,23 @@ def test_a_second_display_of_another_size_passes_hotplug() -> None: hotplug.run(platform, checks, clients) assert platform.displays()[1] == Rect(1920, 0, 1280, 800) assert checks.failed == 0, checks.failures + + +def test_focus_follows_mouse_is_driven_without_naming_an_implementation() -> None: + """The implementation is a port's own: the scenario leaves it to the command's default.""" + + class Records(FakePlatform): + def __init__(self) -> None: + super().__init__() + self.said: list[tuple[str, ...]] = [] + + def komorebic(self, *args: str) -> str: + self.said.append(args) + return super().komorebic(*args) + + platform = Records() + checks = Checks() + clients = opened(platform, checks) + focus_follows_mouse.run(platform, checks, clients[0], clients[2]) + assert checks.failed == 0, checks.failures + assert not [a for a in platform.said if "--implementation" in a]