feat(wm): follow a window moved to another output

A window can be moved to another output by something other than komorebi: a KWin
shortcut that sends it to the next screen, the window menu, an application.
komorebi had it in a container of the old monitor, whose tile is on a screen the
window is not on, so it sat untiled where it landed.

The bridge now reports a window's output changing, with the frame the window has
by then, since the signal and the frame arrive in no fixed order, and the table
makes it an OutputChange event. The window manager handles it with
WindowManager::follow_windows_to_their_monitors: every container whose focused
window, and every floating window, is on another monitor than the one it has it
on moves whole to the workspace of the same number on the monitor that holds the
middle of its frame, and the monitors that changed are tiled. Every window is
looked at, not only the one in the event, and a move komorebi made itself is in
its state already and finds nothing to do.

Nothing is followed while the user drags a window: the end of the drag decides
where that window goes, so the method returns at once while a move or a resize
by the user is going on.

KWin also moves windows for a moment after outputs come and go, so the monitor
reconciliator looks again 1.5 seconds after each notification, where it used to
trust what it found at once. vm-hotplug sends windows over with kdotool as well
as with komorebic.
This commit is contained in:
LGUG2Z committed 2026-10-28 07:20:57 -07:00
1 parent f530318cee
commit 40eec2f6be
18 files changed
+825 -62

No files matched your search

+21
View File
@@ -18,6 +18,22 @@ KWin has no signal for the room a panel leaves, so komorebi looks at it when a p
closes or moves, and once a second. A panel that is laid out a moment after komorebi starts is
found within a second.
## A window is moved to another monitor
A window moves to another monitor when something other than komorebi moves it: a KWin shortcut
that sends the window to the next screen, the window menu, a drag with the pointer, or an
application. KWin tells komorebi, which finds every container and floating window that is on
another monitor than the one it has it on, and moves it to the workspace with the same number on
the monitor it is on. The monitors that windows moved between are tiled again.
A window is on the monitor whose area has the middle of its frame. A container is on the monitor
of the window that has the focus in it. A move komorebi made itself, with
[`komorebic move-to-monitor`](../cli/move-to-monitor.md) for one, is in komorebi's state already,
and finds nothing to do.
While the user drags a window with the pointer, komorebi moves nothing: where the window goes is
decided when they let go of it ([moving windows by dragging](moving-windows.md#by-dragging)).
## A monitor is unplugged
KWin takes the windows of an output that goes (it is unplugged, or disabled with
@@ -28,6 +44,11 @@ the workspaces that changed are tiled again. A [stack](stacking-windows.md) goes
monocle window and a maximized window come as tiles of their own, and the windows the monocle hid
are shown again.
A moment after an output goes or comes back (1.5 seconds), komorebi looks at where every window
is once more, because KWin moves windows about for a while after the outputs change: the windows
it took to the monitor that is left may go back to the output that is plugged in again, and a
change of resolution or scale changes where the middle of a window is.
komorebi keeps the monitor that went, with its workspaces, layouts, paddings and offsets, for
when it comes back, and forgets the [workspace rules](workspace-rules.md) of its workspaces until
then. When no output is left at all, komorebi does nothing.
+3 -3
View File
@@ -2,9 +2,9 @@
A program such as a status bar, a widget or a script can follow what komorebi does by
subscribing to its notifications. After each event the window manager handles (a window
was shown, closed, focused, minimized or restored), each message it takes on its socket and
each change of the monitors, the daemon sends every subscriber a notification: the event, the
message or the change, and the state of the window manager after it.
was shown, closed, focused, minimized, restored or moved to another output), each message it
takes on its socket and each change of the monitors, the daemon sends every subscriber a
notification: the event, the message or the change, and the state of the window manager after it.
## Subscribing