mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-20 15:41:38 +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.
84 lines
3.1 KiB
Python
84 lines
3.1 KiB
Python
# How long a retile takes to reach the windows of a real KWin, measured on the session bus: from
|
|
# the moment the daemon answers the bridge's held call with a batch of new frames, to the last
|
|
# frame KWin reports for one of the windows it moved, the client's answer included. Every number
|
|
# here comes from KWin and real clients; the Rust tests cannot measure it. The output is large, so
|
|
# that ten windows in komorebi's default layout all have room.
|
|
from komorebi_vm import Checks, Kde, daemon, latency
|
|
|
|
W, H = 3840, 2160
|
|
WINDOWS = 10
|
|
ROUNDS = 10
|
|
BUS_LOG = "/tmp/komorebi-bus.log"
|
|
|
|
start_all()
|
|
machine.wait_for_unit("multi-user.target")
|
|
machine.wait_for_unit("user@1000.service")
|
|
|
|
checks = Checks()
|
|
kde = Kde.headless(machine, "main", size=(W, H), scale=SCALE)
|
|
kde.start_komorebi()
|
|
checks.check(
|
|
"the daemon loaded its script into KWin",
|
|
kde.wait_for(lambda: "loaded the KWin bridge script" in kde.komorebi_log(), timeout=30),
|
|
)
|
|
kde.monitor_bridge(BUS_LOG)
|
|
|
|
titles = [f"w{n}" for n in range(1, WINDOWS + 1)]
|
|
for title in titles:
|
|
kde.spawn(f"foot -T {title} sleep 3000")
|
|
kde.wait_for(lambda title=title: kde.wid(title) != "", timeout=30)
|
|
|
|
|
|
def shown() -> int:
|
|
return sum(1 for e in daemon.events(kde.komorebi_log()) if e.kind == "Show")
|
|
|
|
|
|
checks.check(f"the daemon tiles all {WINDOWS}", kde.wait_for(lambda: shown() >= WINDOWS))
|
|
|
|
|
|
def measured() -> list[latency.Round]:
|
|
return latency.rounds(machine.succeed(f"cat {BUS_LOG}"))
|
|
|
|
|
|
def settled_after(count: int) -> bool:
|
|
"""A round after the first `count` is over: its windows all reported, and then 0.3 s passed."""
|
|
done = measured()
|
|
if len(done) <= count or done[-1].seconds is None:
|
|
return False
|
|
now = float(machine.succeed("date +%s.%N"))
|
|
return now - (done[-1].sent + done[-1].seconds) > 0.3
|
|
|
|
|
|
kde.wait_for(lambda: settled_after(0), timeout=10)
|
|
start = len(measured())
|
|
|
|
# each round takes one window out of the layout and puts it back: two retiles
|
|
for title in titles[:ROUNDS]:
|
|
wid = kde.wid(title)
|
|
count = len(measured())
|
|
kde.minimize(wid)
|
|
kde.wait_for(lambda count=count: settled_after(count), timeout=10)
|
|
count = len(measured())
|
|
kde.activate(wid)
|
|
kde.wait_for(lambda count=count: settled_after(count), timeout=10)
|
|
|
|
# the rounds before `start` tiled the windows as they opened
|
|
rounds = measured()[start:]
|
|
settled = [r.seconds * 1000 for r in rounds if r.seconds is not None]
|
|
moved = sum(r.windows for r in rounds) / max(1, len(rounds))
|
|
print(f" {len(rounds)} retiles, {moved:.1f} windows moved by each on average, scale {SCALE}")
|
|
if settled:
|
|
p50, p95 = latency.percentile(settled, 0.5), latency.percentile(settled, 0.95)
|
|
print(f" from the batch to the last frame: p50 {p50:.1f} ms, p95 {p95:.1f} ms,")
|
|
print(f" max {max(settled):.1f} ms, min {min(settled):.1f} ms")
|
|
checks.check(f"{2 * ROUNDS} retiles were measured", len(rounds) == 2 * ROUNDS)
|
|
checks.check("every window of every retile reported its frame", len(settled) == len(rounds))
|
|
checks.check(
|
|
"a retile reaches the windows within 100 ms (times the machine's scale), at p95",
|
|
bool(settled) and latency.percentile(settled, 0.95) <= 100 * SCALE,
|
|
)
|
|
|
|
kde.stop_komorebi()
|
|
kde.stop()
|
|
checks.finish()
|