mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-02 05:04:19 +01:00
With the commands of the Backend trait carried out, the daemon tiles a real KWin. A command looks up the UUID KWin knows the window by, is queued as JSON for the bridge, and returns; the held Poll call is answered with the queue, one millisecond after the first command, so that a retile reaches KWin as one batch. The bridge sets the frame, activates, raises, minimizes, restores or closes the window, and reports what it could not do. set_rect records the frame it asked for in the table, so the window manager sees it at once, and the geometry event that follows says what the client made of it. A KWin script cannot move the pointer, so the pointer follows the focus through KWin's own "Move Mouse to Focus" action, invoked over kglobalaccel once KWin reports the window active. The commands are typed in bridge.js, and the declarations of KWin's API let the bridge set a window's frame, its minimized state and the active window, raise and close it, and nothing else. The session the tests of both sides share grows a second batch: the backend's tests check that set_rect, focus, raise, minimize, unminimize and close send it, and the bridge's tests answer the bridge with it and check what KWin is asked to do, down to the command for a window that has closed, which comes back as failed. The bridge's tests also cover findWindow's fallback to KWin's list, a frame set as a plain object, and a command KWin throws on. Three VM suites check it against a real KWin. vm-core-e2e (from the spike's m2-e2e, the sections that need no komorebic) compares what the daemon asked for, read from its debug log, with what KWin has, read with kdotool: three windows inside the screen, not overlapping, sharing it, the same focused window on both sides, and the same again after a minimize, a restore and a close. vm-client-geometry (slow) has eight real clients answer the frames komorebi asks for: Qt programs and xterm take them exactly, foot sizes itself to whole cells, GTK 4 programs and Firefox keep to their minimum sizes. vm-latency (slow) times retiles from a recording of the session bus: on HVF, from the daemon's answer to the last frame KWin reports, p50 17.3 ms, p95 27.7 ms. vm-kwin-events no longer checks that nothing moves. The VM library gives session commands the test user's home and data directories rather than root's, which a GTK client was refused. The bridge's second request for a position after a resize, which matters for windows off the screen, comes with the scrolling layout.
53 lines
2.0 KiB
Python
53 lines
2.0 KiB
Python
from komorebi_vm import Rect, daemon
|
|
from komorebi_vm.daemon import Event
|
|
|
|
LOG = """\
|
|
2026-10-27T12:00:00.000001Z INFO komorebi::kwin: loaded the KWin bridge script (script id 0)
|
|
2026-10-27T12:00:01.000001Z DEBUG komorebi::kwin::state: KWin activated window 2 (alpha)
|
|
2026-10-27T12:00:01.000002Z INFO handle_event: komorebi::process_event: processing event: \
|
|
Show for window 2 with notification WindowAdded
|
|
2026-10-27T12:00:01.000003Z INFO handle_event: komorebi::process_event: processing event: \
|
|
FocusChange for window 2 with notification WindowActivated
|
|
2026-10-27T12:00:02.000001Z DEBUG komorebi::kwin::state: KWin activated window 1 (a (b) c)
|
|
"""
|
|
|
|
|
|
def test_events_are_read_in_the_order_they_were_handled() -> None:
|
|
assert daemon.events(LOG) == [
|
|
Event("Show", 2, "WindowAdded"),
|
|
Event("FocusChange", 2, "WindowActivated"),
|
|
]
|
|
|
|
|
|
def test_window_ids_are_found_by_title_also_one_with_parentheses() -> None:
|
|
assert daemon.window_ids(LOG) == {"alpha": 2, "a (b) c": 1}
|
|
|
|
|
|
def test_an_empty_log_has_nothing_in_it() -> None:
|
|
assert daemon.events("") == []
|
|
assert daemon.window_ids("") == {}
|
|
|
|
|
|
def test_requests_are_the_last_frame_asked_for_each_window() -> None:
|
|
log = (
|
|
"DEBUG komorebi::kwin: asking for window 2 to be at "
|
|
"Rect { left: 10, top: 10, right: 1900, bottom: 1060 }\n"
|
|
"DEBUG komorebi::kwin: asking for window 3 to be at "
|
|
"Rect { left: -5, top: 0, right: 940, bottom: 1060 }\n"
|
|
"DEBUG komorebi::kwin: asking for window 2 to be at "
|
|
"Rect { left: 10, top: 10, right: 940, bottom: 1060 }\n"
|
|
)
|
|
|
|
assert daemon.requests(log) == {2: Rect(10, 10, 940, 1060), 3: Rect(-5, 0, 940, 1060)}
|
|
|
|
|
|
def test_asked_finds_the_frame_by_the_title_of_the_window() -> None:
|
|
log = LOG + (
|
|
"DEBUG komorebi::kwin: asking for window 2 to be at "
|
|
"Rect { left: 10, top: 10, right: 940, bottom: 1060 }\n"
|
|
)
|
|
|
|
assert daemon.asked(log, "alpha") == Rect(10, 10, 940, 1060)
|
|
assert daemon.asked(log, "a (b) c") is None
|
|
assert daemon.asked(log, "nobody") is None
|