diff --git a/docs/dev/BEHAVIOUR.md b/docs/dev/BEHAVIOUR.md index 760cc0e2..685b1a09 100644 --- a/docs/dev/BEHAVIOUR.md +++ b/docs/dev/BEHAVIOUR.md @@ -35,7 +35,8 @@ runs, and goes stale when the code changes. | `workspaces` | `send-to-workspace` and `focus-workspace` put windows away and bring them back | pass | pass | | `closing` | a closed window leaves the state, and the others take its room | pass | pass | | `resize` | dragging the edge two tiles share moves it by what the pointer moved | pass | **fails**, cause found | -| `commands` | every layout, and about 216 commands, leave the daemon healthy | pass, none skipped | not run | +| `commands` | every layout, and about 216 commands, leave the daemon healthy | pass, none skipped | not run, see below | +| `commands.unknown_monitor` | a window sent to a monitor that does not exist stays managed | **fails** | **fails** | | `rules` | initial, permanent and ignore rules by title | see below | not run | | `hotplug` | an unplugged display takes its windows to the other, a plugged one is a monitor | pass | not run | @@ -45,6 +46,19 @@ and the cause is not known. ## What they have found +**A window sent to a monitor that does not exist is lost, on both ports.** After +`komorebic send-to-monitor 7` (or `move-to-monitor 7`) on a desktop with one monitor, the daemon +stops managing the focused window and leaves it on the screen with nothing tiling it. On kfw this +was seen on a Windows guest: three windows managed and present, then two managed and three +present, with the command exiting 0 and printing nothing. On kfde `core-e2e` failed the scenario's +check on a real KWin, and the windows after it. kfde's code shows how: +`WindowManager::move_container_to_monitor` takes the focused container out of its workspace with +`remove_focused_container()` and only then looks the monitor up, with an error for one that is not +there, so the container is gone when the error is returned. This is not fixed, on either port. The +scenario is `commands.unknown_monitor`, which a suite can call; it is not in `core-e2e` while it +would fail there. The sweep of `commands` is not affected on kfde, which has two outputs, and on +kfw the sweep now plugs in a second display first. + **`resize` on kfw.** Dragging the edge between two tiles by 30, 60 and 120 pixels moved it by 27, 53 and 96 on kfw's master, and by 27, 51 and 106 on its animation branch (`0c9acdf4`), where kfde moves it by exactly the pointer's distance. The pointer is not the cause: the same drag of the diff --git a/nix/tests/vm/lib/komorebi_vm/core/scenarios/commands.py b/nix/tests/vm/lib/komorebi_vm/core/scenarios/commands.py index 96e04caa..55dae21e 100644 --- a/nix/tests/vm/lib/komorebi_vm/core/scenarios/commands.py +++ b/nix/tests/vm/lib/komorebi_vm/core/scenarios/commands.py @@ -353,3 +353,20 @@ def prints(platform: Platform, checks: Checks) -> None: checks.skip(f"komorebic {line}", "the port has no such command") continue checks.check(f"komorebic {line}", status == 0) + + +def unknown_monitor(platform: Platform, checks: Checks, clients: list[Client]) -> None: + """Sends the focused window to a monitor that does not exist, and checks that no window is lost. + + A port may refuse the command or ignore it, but a window that was managed has to stay managed: + a daemon that stops managing it leaves it on the screen with nothing tiling it. The platform + has fewer than seven displays. + """ + managed = platform.state().managed() + for command in ("send-to-monitor", "move-to-monitor"): + platform.komorebic_status(command, "7") + platform.wait_for(lambda: unhealthy(platform, clients) is None, timeout=5) + checks.check( + f"after {command} 7, which no display has, the daemon still manages every window", + platform.state().managed() == managed and unhealthy(platform, clients) is None, + ) diff --git a/nix/tests/vm/lib/tests/fake_platform.py b/nix/tests/vm/lib/tests/fake_platform.py index 8a6c4e5f..4068e225 100644 --- a/nix/tests/vm/lib/tests/fake_platform.py +++ b/nix/tests/vm/lib/tests/fake_platform.py @@ -241,6 +241,8 @@ class FakePlatform: self.spaces[int(number)].append([window]) case ("change-layout", _): pass + case ("send-to-monitor", _): + pass case ("move-to-monitor", number): if int(number) < self.display_count: self.display_of[self.containers[self.focus][0]] = int(number) diff --git a/nix/tests/vm/lib/tests/test_focus_moving.py b/nix/tests/vm/lib/tests/test_focus_moving.py index fa58aa83..0d2d008f 100644 --- a/nix/tests/vm/lib/tests/test_focus_moving.py +++ b/nix/tests/vm/lib/tests/test_focus_moving.py @@ -212,3 +212,26 @@ def test_the_sweep_plugs_in_a_second_display_when_there_is_only_one() -> None: commands.sweep(platform, checks, clients, config="unused", commands=("focus right",)) assert platform.display_count == 2 assert checks.failed == 0, checks.failures + + +def test_a_daemon_that_loses_a_window_sent_to_no_monitor_fails() -> None: + class Loses(FakePlatform): + def komorebic_status(self, *args: str) -> tuple[int, str]: + if args[:1] == ("send-to-monitor",): + self.containers[self.focus].clear() + return 0, "" + return super().komorebic_status(*args) + + platform = Loses() + checks = Checks() + clients = opened(platform, checks) + commands.unknown_monitor(platform, checks, clients) + assert any("send-to-monitor 7" in f for f in checks.failures) + + +def test_a_daemon_that_ignores_a_monitor_that_does_not_exist_passes() -> None: + platform = FakePlatform() + checks = Checks() + clients = opened(platform, checks) + commands.unknown_monitor(platform, checks, clients) + assert checks.failed == 0, checks.failures