feat(wm): a monitor changes size

When an output gets another resolution or scale, or a panel starts, grows or
hides, the work area the layout fills is not the one komorebi tiled in, and
nothing moved the windows until something else tiled them again.

The bridge now sends the outputs, with their geometry and the work area of the
desktop each shows, when KWin says they changed, when a dock window opens,
closes or moves, and once a second, because KWin has no signal for the room a
panel leaves. The table turns a monitor whose size or work area changed into a
monitor notification. It is not a window event, since it is about no window: it
goes to the monitor reconciliator, a thread that takes the window manager's lock
as the threads of events and messages do, reads the size and work area of every
monitor again and tiles the workspace in front of the focused monitor. Another
monitor's windows keep their tiles until a retile. Every subscriber is notified
of it, whether or not the state changed.

vm-hotplug starts with the scale of one of two outputs changing under a running
daemon. The VM library gets kde.outputs, which lists, disables, enables and
scales outputs, for the commits that unplug and plug them.
This commit is contained in:
LGUG2Z committed 2026-10-28 07:20:57 -07:00
1 parent c03e5d2970
commit c8dc92a236
27 files changed
+1044 -75

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
# Monitors that change
komorebi follows the outputs KWin has. There is nothing to configure and no command to run: this
page says what komorebi does when a monitor changes.
## A monitor changes size
A monitor changes size when its resolution or its scale changes (in System Settings, under
Display & Monitor, or with `kscreen-doctor output.<name>.scale.1.5`), and when a panel changes
the room the windows have on it: a panel that starts, grows, moves or is hidden. komorebi reads
the size and the work area of every monitor again, and tiles the workspace in front on the
focused monitor in the area it now has.
The windows of the other monitors keep their tiles until something tiles them again.
[`komorebic retile`](../cli/retile.md) does it for every monitor.
KWin has no signal for the room a panel leaves, so komorebi looks at it when a panel opens,
closes or moves, and once a second. A panel that is laid out a moment after komorebi starts is
found within a second.
A monitor that is unplugged or plugged in is not followed: komorebi keeps the monitors it
started with until it is started again.
## Following it from a program
A [subscriber](subscribing-to-notifications.md) is sent a notification each time komorebi has
read the monitors again, whether or not anything changed in the state. Its `event` is
`{"Resize":0}`, where the number is the id of the monitor that changed, or 0 when KWin does not
say which.
+13 -10
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) and each message it takes on its socket,
the daemon sends every subscriber a notification: the event or the message, and the state
of the window manager after it.
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.
## Subscribing
@@ -34,11 +34,13 @@ object. The first notification a subscriber receives is the one of its subscript
A notification has two fields:
- `event`: the event or the message. An event is a window event, with the signal it came
from and the window, such as
- `event`: the event, the message or the change of the monitors. An event is a window event,
with the signal it came from and the window, such as
`{"type":"Show","content":[{"type":"KWin","content":"WindowAdded"},{"id":...}]}`. A
message is written the way a client writes it on the daemon's socket, such as
`{"type":"Retile"}`.
`{"type":"Retile"}`. A change of the monitors is the name of the change with its content,
such as `{"Resize":0}`: the id of the monitor that changed, or 0 when KWin does not say
which. [Changing monitors](changing-monitors.md) says when each is sent.
- `state`: the state of the window manager after it, with the same fields as what
[`komorebic state`](../cli/state.md) prints, on one line.
@@ -49,10 +51,11 @@ sent.
A subscriber can ask to be sent a notification only when the event or the message changed
the state, with the `filter_state_changes` option. It is still sent the notification of a
window that is shown, of every new subscription, so it receives the state as soon as it
subscribes, of a theme, which changes the colors of the borders and nothing in the state,
and of every reload of `komorebi.json`. `komorebic subscribe-socket` has no option for it; a
program writes the message on the daemon's socket itself:
window that is shown, of every change of the monitors, of every new subscription, so it
receives the state as soon as it subscribes, of a theme, which changes the colors of the
borders and nothing in the state, and of every reload of `komorebi.json`.
`komorebic subscribe-socket` has no option for it; a program writes the message
on the daemon's socket itself:
```sh
printf '%s' '{"type":"AddSubscriberSocketWithOptions","content":["bar.sock",{"filter_state_changes":true}]}' |