feat(nix): the minimizing scenario, and Platform.minimize

A minimized window leaves its room to the others, and a restored one
takes it back. Platform.minimize is new: the title bar button on KDE;
activate restores. core-e2e passes 213 checks on KDE.
This commit is contained in:
LGUG2Z committed 2026-10-30 12:03:00 -07:00
1 parent 4835907b2e
commit 4471cc01a8
7 files changed
+91 -1

No files matched your search

@@ -151,6 +151,10 @@ class Platform(Protocol):
"""Closes the window, as its close button would."""
...
def minimize(self, client: Client) -> None:
"""Minimizes the window, as its title bar button would. `activate` restores it."""
...
def work_area(self) -> Rect:
"""The area of the first display that windows may take."""
...
@@ -0,0 +1,40 @@
"""A window that is minimized leaves its room to the others, and takes it back when restored."""
from komorebi_vm.core.checks import Checks
from komorebi_vm.core.platform import Client, Platform
from komorebi_vm.core.scenarios.layouts import tiled
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
"""Minimizes the first of `clients`, which are tiled windows of the first workspace in a
container each, with more than two of them, and restores it."""
target = clients[0]
others = clients[1:]
def area(c: Client) -> int:
window = platform.os_window(c)
return window.frame.w * window.frame.h if window is not None else 0
before = sum(area(c) for c in others)
platform.minimize(target)
checks.check(
f"with {target.title} minimized the others take more room between them",
platform.wait_for(lambda: sum(area(c) for c in others) > before, timeout=20),
)
frames = [w.frame for c in others if (w := platform.os_window(c)) is not None]
checks.check(
"... inside the work area and not on each other",
all(f.inside(platform.work_area()) for f in frames)
and not any(a.overlaps(b) for i, a in enumerate(frames) for b in frames[i + 1 :]),
)
platform.activate(target)
checks.check(
f"restored, {target.title} and the others are tiled where the layout says",
platform.wait_for(lambda: tiled(platform, clients), timeout=20),
)
frames = [w.frame for c in clients if (w := platform.os_window(c)) is not None]
checks.check(
"... and not on each other",
not any(a.overlaps(b) for i, a in enumerate(frames) for b in frames[i + 1 :]),
)
@@ -125,6 +125,9 @@ class KdePlatform:
def work_area(self) -> Rect:
return Rect(0, 0, *self.size)
def minimize(self, client: Client) -> None:
self.kde.minimize(self.kde.wid(client.title))
def activate(self, client: Client) -> None:
self.kde.activate(self.kde.wid(client.title))
+17 -1
View File
@@ -80,6 +80,7 @@ class FakePlatform:
self.display_of: dict[str, int] = {}
self.forgets_displays = False
self.floats: list[str] = []
self.minimized: list[str] = []
self.running = True
self.placement: Any = None
self.moves = moves
@@ -222,6 +223,9 @@ class FakePlatform:
if client.title in self.floats:
self.floats.remove(client.title)
return
if client.title in self.minimized:
self.minimized.remove(client.title)
return
if client.title in self.unmanaged:
self.unmanaged.remove(client.title)
return
@@ -247,7 +251,7 @@ class FakePlatform:
return self._find(title)[1]
def hidden(self, client: Client) -> bool:
if client.title in self.floats:
if client.title in self.floats or client.title in self.minimized:
return False
if client.title in self.unmanaged:
return False
@@ -258,7 +262,17 @@ class FakePlatform:
def work_area(self) -> Rect:
return Rect(0, 0, 1920, 1080)
def minimize(self, client: Client) -> None:
self._find_remove(client.title)
self.minimized.append(client.title)
self.focuses[self.current] = max(0, min(self.focus, len(self.containers) - 1))
self._relayout()
def activate(self, client: Client) -> None:
if client.title in self.minimized:
self.minimized.remove(client.title)
self.containers.append([client.title])
self._relayout()
self.current, self.focus = self._find(client.title)
stack = self.containers[self.focus]
stack.insert(0, stack.pop(stack.index(client.title)))
@@ -267,6 +281,8 @@ class FakePlatform:
return Image.new("RGB", (4, 4))
def os_window(self, client: Client) -> OsWindow | None:
if client.title in self.minimized:
return OsWindow(client.title, Rect(0, 0, 0, 0), focused=False)
if client.title in self.floats:
return OsWindow(client.title, Rect(300, 300, 600, 400), focused=False)
if client.title in self.unmanaged:
@@ -11,6 +11,7 @@ from komorebi_vm.core.scenarios import (
hotplug,
layouts,
lifecycle,
minimizing,
monocle,
moving,
placement,
@@ -183,6 +184,27 @@ def test_a_float_that_stays_in_the_tiling_fails_floating() -> None:
assert checks.failed > 0
def test_a_daemon_that_is_right_passes_minimizing() -> None:
platform = FakePlatform()
checks = Checks()
clients = opened(platform, checks)
minimizing.run(platform, checks, clients)
assert checks.failed == 0, checks.failures
assert checks.passed > 3
def test_a_daemon_that_keeps_the_room_of_a_minimized_window_fails_minimizing() -> None:
class Keeping(FakePlatform):
def _relayout(self) -> None:
pass
platform = Keeping()
checks = Checks()
clients = opened(platform, checks)
minimizing.run(platform, checks, clients)
assert checks.failed > 0
def test_a_command_the_port_lacks_is_skipped_by_name() -> None:
platform = FakePlatform()
checks = Checks()
+3
View File
@@ -69,6 +69,9 @@ class FakePlatform:
def komorebic(self, *args: str) -> str:
return ""
def minimize(self, client: Client) -> None:
pass
def activate(self, client: Client) -> None:
pass
+2
View File
@@ -21,6 +21,7 @@ from komorebi_vm.core.scenarios import (
focus,
layouts,
lifecycle,
minimizing,
monocle,
moving,
placement,
@@ -452,6 +453,7 @@ checks.check(
)
layouts.run(platform, checks, neutral)
floating.run(platform, checks, neutral)
minimizing.run(platform, checks, neutral)
monocle.run(platform, checks, neutral)
workspaces.run(platform, checks, neutral)
# the third window is on workspace 1 now: the first is closed, and the second takes its room