mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-19 15:18:40 +01:00
feat(nix): the maximizing scenario
toggle-maximize gives a window the work area, with the others where they were and the daemon naming it as the maximized window; toggled again, every window is tiled where the layout says. core-e2e passes 225 checks on KDE.
This commit is contained in:
1 parent
d4d356c70e
commit
f1ea111fd0
4 files changed
+87
-1
No files matched your search
@@ -0,0 +1,53 @@
|
||||
"""A maximized window has the work area, with the others left where they are behind it."""
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
from komorebi_vm.core.scenarios.layouts import tiled
|
||||
from komorebi_vm.core.scenarios.support import focus_agrees, positions
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
"""Toggles maximize on the last of `clients`, which are tiled windows of the first workspace,
|
||||
each in a container of its own, and toggles it off again."""
|
||||
target = clients[-1]
|
||||
others = [c for c in clients if c != target]
|
||||
platform.activate(target)
|
||||
platform.wait_for(lambda: focus_agrees(platform, clients, target.title))
|
||||
area = platform.work_area()
|
||||
behind = positions(platform, others)
|
||||
|
||||
def fills() -> bool:
|
||||
window = platform.os_window(target)
|
||||
return (
|
||||
window is not None
|
||||
and window.frame.w >= area.w - platform.tolerance
|
||||
and window.frame.h >= area.h - platform.tolerance
|
||||
)
|
||||
|
||||
def maximized() -> str | None:
|
||||
window = platform.state().workspace().maximized
|
||||
return window.title if window else None
|
||||
|
||||
platform.komorebic("toggle-maximize")
|
||||
checks.check(
|
||||
f"after 'toggle-maximize' {target.title} fills the work area",
|
||||
platform.wait_for(fills, timeout=20),
|
||||
)
|
||||
checks.check(
|
||||
"... and the daemon has it as the maximized window",
|
||||
platform.wait_for(lambda: maximized() == target.title, timeout=20),
|
||||
)
|
||||
checks.check(
|
||||
"... the others stay where they were",
|
||||
positions(platform, others) == behind,
|
||||
)
|
||||
|
||||
platform.komorebic("toggle-maximize")
|
||||
checks.check(
|
||||
"toggled again, the daemon has no maximized window",
|
||||
platform.wait_for(lambda: maximized() is None, timeout=20),
|
||||
)
|
||||
checks.check(
|
||||
"... and every window is tiled where the layout says",
|
||||
platform.wait_for(lambda: tiled(platform, clients), timeout=20),
|
||||
)
|
||||
@@ -80,6 +80,7 @@ class FakePlatform:
|
||||
self.display_of: dict[str, int] = {}
|
||||
self.forgets_displays = False
|
||||
self.floats: list[str] = []
|
||||
self.maximized: str | None = None
|
||||
self.workspace_padding = 0
|
||||
self.container_padding = 0
|
||||
self.minimized: list[str] = []
|
||||
@@ -287,6 +288,8 @@ class FakePlatform:
|
||||
return Image.new("RGB", (4, 4))
|
||||
|
||||
def os_window(self, client: Client) -> OsWindow | None:
|
||||
if client.title == self.maximized:
|
||||
return OsWindow(client.title, Rect(0, 0, 1920, 1080), focused=True)
|
||||
if client.title in self.minimized:
|
||||
return OsWindow(client.title, Rect(0, 0, 0, 0), focused=False)
|
||||
if client.title in self.floats:
|
||||
@@ -394,6 +397,8 @@ class FakePlatform:
|
||||
case ("focused-workspace-container-padding", size):
|
||||
self.container_padding = int(size)
|
||||
self._relayout()
|
||||
case ("toggle-maximize",):
|
||||
self.maximized = None if self.maximized else self.containers[self.focus][0]
|
||||
case ("toggle-float",):
|
||||
if self.floats:
|
||||
self.containers.insert(self.focus, [self.floats.pop()])
|
||||
@@ -455,7 +460,11 @@ class FakePlatform:
|
||||
"focused": focus,
|
||||
},
|
||||
"monocle_container": monocle,
|
||||
"maximized_window": None,
|
||||
"maximized_window": (
|
||||
window(self.maximized, Rect(0, 0, 1920, 1080))
|
||||
if current and self.maximized
|
||||
else None
|
||||
),
|
||||
"floating_windows": {
|
||||
"elements": [window(t, Rect(300, 300, 600, 400)) for t in floats],
|
||||
"focused": 0,
|
||||
|
||||
@@ -11,6 +11,7 @@ from komorebi_vm.core.scenarios import (
|
||||
hotplug,
|
||||
layouts,
|
||||
lifecycle,
|
||||
maximizing,
|
||||
minimizing,
|
||||
monocle,
|
||||
moving,
|
||||
@@ -227,6 +228,27 @@ def test_a_daemon_that_ignores_the_padding_fails_padding() -> None:
|
||||
assert checks.failed > 0
|
||||
|
||||
|
||||
def test_a_daemon_that_is_right_passes_maximizing() -> None:
|
||||
platform = FakePlatform()
|
||||
checks = Checks()
|
||||
clients = opened(platform, checks)
|
||||
maximizing.run(platform, checks, clients)
|
||||
assert checks.failed == 0, checks.failures
|
||||
assert checks.passed > 4
|
||||
|
||||
|
||||
def test_a_daemon_that_does_not_maximize_fails_maximizing() -> None:
|
||||
class Stubborn(FakePlatform):
|
||||
def komorebic(self, *args: str) -> str:
|
||||
return "" if args == ("toggle-maximize",) else super().komorebic(*args)
|
||||
|
||||
platform = Stubborn()
|
||||
checks = Checks()
|
||||
clients = opened(platform, checks)
|
||||
maximizing.run(platform, checks, clients)
|
||||
assert checks.failed > 0
|
||||
|
||||
|
||||
def test_a_command_the_port_lacks_is_skipped_by_name() -> None:
|
||||
platform = FakePlatform()
|
||||
checks = Checks()
|
||||
|
||||
@@ -21,6 +21,7 @@ from komorebi_vm.core.scenarios import (
|
||||
focus,
|
||||
layouts,
|
||||
lifecycle,
|
||||
maximizing,
|
||||
minimizing,
|
||||
monocle,
|
||||
moving,
|
||||
@@ -455,6 +456,7 @@ checks.check(
|
||||
layouts.run(platform, checks, neutral)
|
||||
floating.run(platform, checks, neutral)
|
||||
minimizing.run(platform, checks, neutral)
|
||||
maximizing.run(platform, checks, neutral)
|
||||
padding.run(platform, checks, neutral)
|
||||
monocle.run(platform, checks, neutral)
|
||||
workspaces.run(platform, checks, neutral)
|
||||
|
||||
Reference in new issue
Block a user