mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-23 17:04:19 +01:00
feat(kwin): sleep, wake and lock
While the screen is locked or the machine is asleep, KWin sends its clients no frame callbacks, so nothing komorebi asked for in that time is done: a window that something else moved stays where it was moved, and the monitors can come back in another order or at another size. Nothing told komorebi it had happened, and it kept the layout it had until the next event. kwin::power now watches for the two ends of it: logind's PrepareForSleep on the system bus, which only logind may send, and the lock screen's ActiveChanged on the session bus. When the machine wakes (2.5 seconds after it, while the outputs are found one after another) or the screen is unlocked (0.6 seconds after it, once the lock screen has gone), the monitor reconciliator gets a Wake and calls wake_up: it reconciles the monitors as for an unplug, reads their sizes, follows the windows to the monitors they are on and tiles every monitor, unless the window manager is paused. Going to sleep and locking do nothing, and a machine with no system bus or a session with no lock screen runs without them. The lock screen is a window of KWin's that the bridge already does not report as an application window, so it has no tile. The bridge also compares KWin's active window with the one it last announced once a second, because the window that is active again after an unlock is not always announced. vm-lock-sleep locks and unlocks a real Plasma session and checks that the windows come back to their tiles; a real suspend cannot be tested in the QEMU guest, only the signal wiring, which tests/power.rs covers on private buses. vm-lock-sleep waits for the panel's room before it opens the windows, so that they are tiled once, and compares the window that was moved with the tile the daemon has for it when it looks, give or take a cell of the terminal's font, and not with the frames read earlier: the room can come while the screen is locked, and the tiles read before are then not the ones. The wait is not a check, because a session on a machine as slow as TCG may never take the room.
This commit is contained in:
1 parent
40eec2f6be
commit
0210ec285a
17 files changed
+913
-26
No files matched your search
+30
-4
@@ -126,8 +126,16 @@ the windows and outputs it finds, and from then on every window that opens, clos
|
||||
focus, is minimized or brought back, moves or changes size, the start and the end of every drag
|
||||
of a window by the user, and every change of the outputs (one that changes resolution or scale,
|
||||
and the room a panel leaves). KWin has no signal for that room, so the script looks at the
|
||||
outputs again when a dock window opens, closes or moves, and once a second. The daemon waits up
|
||||
to 10 seconds for the first report and does not start without it.
|
||||
outputs again when a dock window opens, closes or moves, and once a second; it also compares
|
||||
KWin's active window with the one it last reported once a second. The daemon waits up to 10
|
||||
seconds for the first report and does not start without it.
|
||||
|
||||
It also watches for the machine waking up and the screen being unlocked, with two signals that
|
||||
are not KWin's ([D-Bus](#d-bus)): logind's `PrepareForSleep` on the system bus, and the lock
|
||||
screen's `ActiveChanged` on the session bus. Either one makes it look at the monitors and at
|
||||
where every window is again, after a delay (2.5 seconds after a wake, 0.6 after an unlock). Where
|
||||
there is no system bus, as in a container, it logs that it is not watching for sleep, and
|
||||
carries on.
|
||||
|
||||
Before it loads the script, it turns on KWin's per-output virtual desktops in the user's
|
||||
`kwinrc` (`[Windows] PerOutputVirtualDesktops=true`), unless they are on, and asks KWin to
|
||||
@@ -191,8 +199,9 @@ directory keeps the user's value), or the session ends.
|
||||
|
||||
### A headless KWin
|
||||
|
||||
`kwin_wayland --virtual` behaves like the KWin of a session for everything komorebi does:
|
||||
the VM tests run the daemon against one, on a private session bus of its own. It cannot draw
|
||||
`kwin_wayland --virtual` behaves like the KWin of a session for everything komorebi does but
|
||||
the lock screen, which it has none of (`vm-lock-sleep` runs in a Plasma session): the VM tests
|
||||
run the daemon against one, on a private session bus of its own. It cannot draw
|
||||
(see [Rendering](#rendering-in-virtual-machines-and-over-rdp)), so nothing that depends on
|
||||
pixels can be tested against it. Started with `--no-global-shortcuts`, as the VM tests start
|
||||
it, KWin does not own `org.kde.kglobalaccel`, and the pointer does not follow the focus; the
|
||||
@@ -238,6 +247,16 @@ What komorebi calls:
|
||||
| `org.kde.KWin` | `/VirtualDesktopManager` | `org.kde.KWin.VirtualDesktopManager` | the properties `desktops` and `count`, `createDesktop(us)`, `setDesktopName(ss)`, `removeDesktop(s)` | when a workspace has no desktop, and at start; `createDesktop` also for the parking desktop, the first time a window is hidden, and `removeDesktop` for it when komorebi stops and for one a killed run left |
|
||||
| `org.kde.plasmashell` | `/PlasmaShell` | `org.kde.PlasmaShell` | `evaluateScript(s) -> s`, `wallpaper(u) -> a{sv}`, `setWallpaper(sa{sv}u)` | when a workspace with a wallpaper comes into view ([The Plasma shell](#the-plasma-shell)) |
|
||||
|
||||
What komorebi listens to, for the machine sleeping and the screen being locked:
|
||||
|
||||
| Bus | Sender | Interface | Signal | Meaning |
|
||||
|---|---|---|---|---|
|
||||
| system | `org.freedesktop.login1` | `org.freedesktop.login1.Manager` | `PrepareForSleep(b)` | the machine is going to sleep (true) or has woken up (false) |
|
||||
| session | any | `org.freedesktop.ScreenSaver` | `ActiveChanged(b)` | the lock screen came up (true) or went away (false) |
|
||||
|
||||
Only logind is believed about sleep. The lock screen's signal is taken from any sender on the
|
||||
session bus.
|
||||
|
||||
The property `desktops` is introspected as `a(iss)`, a position, an id and a name for each
|
||||
desktop, and the value on the wire is `a(uss)`: komorebi reads it as that. It is read uncached,
|
||||
since a read right after `createDesktop` has to see the new desktop.
|
||||
@@ -448,6 +467,13 @@ with two outputs of 1920x1080:
|
||||
it was on. KWin raises `outputChanged` for it, which `vm-hotplug` shows by moving windows with
|
||||
`kdotool windowmove`, as a shortcut or the window menu would.
|
||||
|
||||
## Sleep and lock
|
||||
|
||||
At time of writing (2026-10-27), a real suspend and resume is not tested: the QEMU guests the VM
|
||||
tests run in have no way to wake from one. The signals are tested on private buses
|
||||
(`komorebi/tests/power.rs`), and the lock screen against a real KWin in a Plasma session
|
||||
(`vm-lock-sleep`, which locks and unlocks with `loginctl lock-session` and `unlock-session`).
|
||||
|
||||
## How long a retile takes
|
||||
|
||||
Measured by the VM test `vm-latency` at time of writing (2026-10-27), in a headless KWin 6.8.1
|
||||
|
||||
Reference in new issue
Block a user