mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-17 14:21:22 +01:00
fix(nix): a window that is gone is not in view, and what hidden means
Platform.hidden is false for a window the system does not have, so the workspace scenarios that counted the windows that are not hidden took a window that was lost for one that was shown. They count the windows the system has (support.in_view). The docstring says what each port answers true for beyond a window the daemon put away, and that a scenario that asks for one to be put away asks the daemon too.
This commit is contained in:
1 parent
5f33e11fa5
commit
f012abf6ba
6 files changed
+54
-25
No files matched your search
@@ -150,10 +150,15 @@ class Platform(Protocol):
|
||||
|
||||
def hidden(self, client: Client) -> bool:
|
||||
"""The window exists but is out of sight because the daemon put it away: the other windows
|
||||
of a stack, the windows of another workspace, those behind a monocle.
|
||||
of a stack, the windows of a workspace that is not the one its display shows, those
|
||||
behind a monocle.
|
||||
|
||||
That is a window parked on a desktop of its own on KDE, and cloaked on Windows. A window
|
||||
the user minimized is not hidden in this sense.
|
||||
It is false for a window the system does not have, for one the user minimized, and for one
|
||||
that floats. A scenario that asks for a window to be put away also asks the daemon where
|
||||
it is (`state()`), because a port may answer true for any window that is not on the
|
||||
screen, whoever took it off: on KDE that is one on a virtual desktop that is not shown,
|
||||
on Windows a cloaked one, which includes the windows of another virtual desktop. A scenario
|
||||
that asks for windows to be in view counts those the system has (`support.in_view`).
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
@@ -16,6 +16,18 @@ def os_focused(platform: Platform, clients: list[Client]) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def in_view(platform: Platform, clients: list[Client]) -> list[str]:
|
||||
"""The titles of the windows of `clients` that are on the screen: the operating system has
|
||||
them, and the daemon has not put them away. Sorted.
|
||||
|
||||
A window the system does not have is not in view, though `Platform.hidden` says no for it
|
||||
too: a window that is gone must not count as one that is shown.
|
||||
"""
|
||||
return sorted(
|
||||
c.title for c in clients if platform.os_window(c) is not None and not platform.hidden(c)
|
||||
)
|
||||
|
||||
|
||||
def positions(platform: Platform, clients: list[Client]) -> dict[str, tuple[int, int]]:
|
||||
"""Where the operating system has each window, by title.
|
||||
|
||||
|
||||
@@ -4,11 +4,7 @@ away."""
|
||||
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
|
||||
|
||||
|
||||
def _in_view(platform: Platform, clients: list[Client]) -> list[str]:
|
||||
return sorted(c.title for c in clients if not platform.hidden(c))
|
||||
from komorebi_vm.core.scenarios.support import focus_agrees, in_view
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
@@ -24,7 +20,7 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
platform.komorebic("move-to-workspace", "1")
|
||||
checks.check(
|
||||
"after 'move-to-workspace 1' the window is there, in view, and the others are put away",
|
||||
platform.wait_for(lambda: _in_view(platform, clients) == [target.title], timeout=20),
|
||||
platform.wait_for(lambda: in_view(platform, clients) == [target.title], timeout=20),
|
||||
)
|
||||
checks.check(
|
||||
"... the daemon has it on workspace 1",
|
||||
@@ -38,18 +34,18 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
platform.komorebic("focus-last-workspace")
|
||||
checks.check(
|
||||
"'focus-last-workspace' brings the others back and puts the window away",
|
||||
platform.wait_for(lambda: _in_view(platform, clients) == rest, timeout=20),
|
||||
platform.wait_for(lambda: in_view(platform, clients) == rest, timeout=20),
|
||||
)
|
||||
platform.komorebic("focus-last-workspace")
|
||||
checks.check(
|
||||
"... and again, it goes back to the window",
|
||||
platform.wait_for(lambda: _in_view(platform, clients) == [target.title], timeout=20),
|
||||
platform.wait_for(lambda: in_view(platform, clients) == [target.title], timeout=20),
|
||||
)
|
||||
|
||||
platform.komorebic("move-to-workspace", "0")
|
||||
checks.check(
|
||||
"'move-to-workspace 0' has every window in view again",
|
||||
platform.wait_for(lambda: _in_view(platform, clients) == everyone, timeout=20),
|
||||
platform.wait_for(lambda: in_view(platform, clients) == everyone, timeout=20),
|
||||
)
|
||||
checks.check(
|
||||
"... tiled where the layout says",
|
||||
|
||||
@@ -3,11 +3,7 @@ others away."""
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
from komorebi_vm.core.scenarios.support import focus_agrees, os_focused
|
||||
|
||||
|
||||
def _in_view(platform: Platform, clients: list[Client]) -> list[str]:
|
||||
return sorted(c.title for c in clients if not platform.hidden(c))
|
||||
from komorebi_vm.core.scenarios.support import focus_agrees, in_view, os_focused
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
@@ -21,7 +17,7 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
platform.activate(last)
|
||||
platform.wait_for(lambda: focus_agrees(platform, clients, last.title))
|
||||
checks.check(
|
||||
"every window is in view", _in_view(platform, clients) == sorted(c.title for c in clients)
|
||||
"every window is in view", in_view(platform, clients) == sorted(c.title for c in clients)
|
||||
)
|
||||
|
||||
platform.komorebic("send-to-workspace", "1")
|
||||
@@ -35,15 +31,15 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
)
|
||||
checks.check(
|
||||
"... and the others are still in view",
|
||||
platform.wait_for(lambda: _in_view(platform, clients) == rest),
|
||||
platform.wait_for(lambda: in_view(platform, clients) == rest),
|
||||
)
|
||||
|
||||
platform.komorebic("focus-workspace", "1")
|
||||
platform.wait_for(lambda: _in_view(platform, clients) == [last.title])
|
||||
print(f" in view after the switch: {_in_view(platform, clients)}")
|
||||
platform.wait_for(lambda: in_view(platform, clients) == [last.title])
|
||||
print(f" in view after the switch: {in_view(platform, clients)}")
|
||||
checks.check(
|
||||
"after 'focus-workspace 1' only the window sent there is in view",
|
||||
platform.wait_for(lambda: _in_view(platform, clients) == [last.title]),
|
||||
platform.wait_for(lambda: in_view(platform, clients) == [last.title]),
|
||||
)
|
||||
checks.check(
|
||||
"... it has the focus, and the daemon agrees",
|
||||
@@ -53,7 +49,7 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
platform.komorebic("focus-workspace", "0")
|
||||
checks.check(
|
||||
"after 'focus-workspace 0' the others are in view and the one sent away is put away",
|
||||
platform.wait_for(lambda: _in_view(platform, clients) == rest),
|
||||
platform.wait_for(lambda: in_view(platform, clients) == rest),
|
||||
)
|
||||
checks.check(
|
||||
"... and one of them has the focus",
|
||||
|
||||
@@ -116,7 +116,10 @@ class KdePlatform:
|
||||
"""The window is on the parking desktop, or on a desktop that is not the one in view.
|
||||
|
||||
KDE keeps the windows of a workspace on a virtual desktop of its own and parks the ones a
|
||||
stack or a monocle puts away, so both are out of sight.
|
||||
stack or a monocle puts away, so both are out of sight. That is every window that is on a
|
||||
desktop that is not shown, whoever put it there: this is the quirk
|
||||
`Platform.hidden` warns of. With more than one output, the desktop in view is that of
|
||||
the output KWin considers active, so only the windows of the first are certain.
|
||||
"""
|
||||
wid = self.kde.wid(client.title)
|
||||
if wid == "":
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.geometry import Rect
|
||||
from komorebi_vm.core.platform import OsWindow
|
||||
from komorebi_vm.core.platform import Client, OsWindow
|
||||
from komorebi_vm.core.scenarios import (
|
||||
closing,
|
||||
commands,
|
||||
@@ -72,6 +72,23 @@ def test_a_move_that_loses_the_focus_fails() -> None:
|
||||
assert any("keeps the focus" in f for f in checks.failures)
|
||||
|
||||
|
||||
def test_a_window_that_is_gone_is_not_in_view_for_workspaces() -> None:
|
||||
"""`hidden` is false for a window the system does not have, which is not one that is shown."""
|
||||
|
||||
class Vanishes(FakePlatform):
|
||||
def os_window(self, client: Client) -> OsWindow | None:
|
||||
return None if client.title == "win1" else super().os_window(client)
|
||||
|
||||
def hidden(self, client: Client) -> bool:
|
||||
return False if client.title == "win1" else super().hidden(client)
|
||||
|
||||
platform = Vanishes()
|
||||
checks = Checks()
|
||||
clients = opened(platform, checks)
|
||||
workspaces.run(platform, checks, clients)
|
||||
assert any("in view" in f for f in checks.failures)
|
||||
|
||||
|
||||
def test_a_daemon_that_is_right_passes_stacks() -> None:
|
||||
platform = FakePlatform()
|
||||
checks = Checks()
|
||||
|
||||
Reference in new issue
Block a user