mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-29 20:02:46 +01:00
feat(kwin): a border color for each kind of window
The stock KDE Rounded Corners has one color for the active window and one for the others, and komorebi colors a window by what it is to the layout: the focused window, the others, a locked container that does not have the focus, a floating window that has it, a stack, a monocle. komorebi's build of the effect takes a color for each window over D-Bus. After every event and message the border manager works out the kind of each window and tells the backend, which sends the effect what changed, and tells it that no window has a color when borders are off. Without that build the borders are the look's two colors, and the backend says so once. komorebic gets border-colour. The fake desktop keeps the colors it was told, and gets window_commands, which leaves the look out of the list of what the window manager asked for. vm-features reads the colors of the kinds of window in a real session. The colors of a stack and of a monocled window are read from the fake and, in vm-features, from the pixels. The border_colours key of komorebi.json is not here: its colors are written as the Colour of komorebi-themes, which the themes (49) bring, and 49 adds the key. The maximize check of vm-features, which was the whole suite, reads a pixel a quarter of the way into the window and not the middle one: komorebi puts the pointer in the middle of the window it focuses, and a screenshot has the arrow on it, white. It read the arrow on most runs once the border effect was loaded. vm-features waits for the panel's room too, where it starts the daemon for its sections B to E: the border colors of section C are read from the pixels around a window, which the panel can cover.
This commit is contained in:
1 parent
2c35e4bb6f
commit
22c14ba5be
35 files changed
+1282
-66
No files matched your search
@@ -0,0 +1,24 @@
|
||||
```text
|
||||
Set the color for a window border kind
|
||||
|
||||
Usage: border-colour [OPTIONS] <R> <G> <B>
|
||||
|
||||
Arguments:
|
||||
<R>
|
||||
Red
|
||||
|
||||
<G>
|
||||
Green
|
||||
|
||||
<B>
|
||||
Blue
|
||||
|
||||
Options:
|
||||
-w, --window-kind <WINDOW_KIND>
|
||||
[default: single]
|
||||
[possible values: single, stack, monocle, unfocused, unfocused-locked, floating]
|
||||
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
@@ -778,6 +778,15 @@ the two colors. [`border_manager::current_look`] makes the [`Look`] of them, and
|
||||
after every retile. A backend remembers the look it applied last and does nothing when it is asked
|
||||
for the same again, so nothing reaches KWin unless a setting changed.
|
||||
|
||||
What a window is to the layout decides the color of its border: the focused window of the focused
|
||||
container on the focused monitor is `Single`, or `Stack` when its container has more than one
|
||||
window, the focused window of every other container is `Unfocused` or, when the container is
|
||||
locked, `UnfocusedLocked`, and a floating window is `Floating` while it has the focus and
|
||||
`Unfocused` otherwise ([`border_manager::window_kinds`]). After every event and every message
|
||||
[`border_manager::update_colours`] tells the backend the color of each window's border
|
||||
([`Backend::set_border_colours`]), or that none has one when borders are off, and the backend sends
|
||||
nothing it sent last time. `BorderColour` sets the color of one kind.
|
||||
|
||||
A drawn border takes room. While [`BORDER_DRAWN`] is set, [`Monitor::update_workspace_globals`]
|
||||
gives the workspace the width and the offset of the border, and [`Workspace::update`] takes both
|
||||
off every side of every tile, so the border falls in the gap and not on the window next to it.
|
||||
@@ -791,7 +800,11 @@ into the user's `kwinrc`, group `[Round-Corners]`, through [`Kwinrc`]; loads the
|
||||
(`reconfigureEffect`), since KWin hands an effect the copy of `kwinrc` it read when it started. A
|
||||
look without a border unloads the effect, if komorebi loaded it, and puts the user's settings
|
||||
back. `shutdown` does the same. An effect KWin did not find when it started is reported once and
|
||||
komorebi goes on without it, with `apply_look` answering false.
|
||||
komorebi goes on without it, with `apply_look` answering false. The stock effect has one color for
|
||||
the active window and one for the others; komorebi's build of it takes a color for each window,
|
||||
over D-Bus, by the UUID KWin knows the window by. `set_border_colours` answers false, and logs it
|
||||
once, when the effect is the stock one: every border is then the focused or the unfocused color of
|
||||
the look.
|
||||
[PLATFORM.md](PLATFORM.md#kwin-effects) has the effect, its settings and what was measured.
|
||||
|
||||
## The NixOS module
|
||||
@@ -1029,6 +1042,8 @@ the fake. The window manager is its only caller, through [`backend`]. The contra
|
||||
| A border takes room around the windows only while the compositor draws it | framework path: [`border_manager::send_notification`] keeps the backend's answer in [`BORDER_DRAWN`], which [`Monitor::update_workspace_globals`] reads | `a_border_the_compositor_draws_takes_room_around_each_window_and_none_is_taken_without_one`, `a_look_is_a_command_once_and_says_whether_borders_are_drawn` | none |
|
||||
| The compositor is asked for the look after every event, every message and every retile, and only a changed look reaches it | framework path: [`WindowManager::process_event`], [`WindowManager::process_command`] and [`WindowManager::retile_all`] call [`border_manager::send_notification`], and a backend compares with the look it applied last | `the_border_messages_set_the_border_and_the_compositor_is_asked_for_it`, `a_look_is_a_command_once_and_says_whether_borders_are_drawn` | the same look applied twice by the KWin backend is not tested |
|
||||
| No outline is drawn inside a window, and a border is never thicker than the effect can draw | framework path: [`kwin::effects`](../../komorebi/src/kwin/effects.rs) sets every inner outline to 0 and clamps the width to 20 | `the_border_is_the_outer_outline_and_nothing_is_drawn_inside_the_window`, `a_border_thicker_than_the_effect_can_draw_is_the_thickest_it_can`, `vm-look` | none |
|
||||
| Every window has the border color of what it is to the layout, and a window whose kind changes has the new one at once | framework path: [`border_manager::update_colours`] is called after every event and every message, from [`border_manager::window_kinds`], and the backend sends the colors it did not send last time | `the_focused_window_has_the_focus_colour_and_the_others_do_not`, `a_locked_container_that_is_not_focused_is_marked`, `a_stack_has_its_own_colour_when_it_has_the_focus`, `a_monocled_window_has_the_monocle_colour`, `a_floating_window_has_the_floating_colour_while_it_has_the_focus`, `border_colours_are_a_command_only_when_they_change`, `vm-features` (section C) | the stock effect: two colors for every window |
|
||||
| With borders off no window has a color | framework path: [`border_manager::update_colours`] tells the backend an empty list when `BORDER_ENABLED` is false | `with_borders_off_no_window_has_a_colour` | none |
|
||||
| The effect komorebi loaded is unloaded, and the user's settings of it are put back, when komorebi stops using it or exits | framework path: the effect's state unloads what komorebi loaded, and [`Kwinrc`] puts the group back | `one_group_can_be_put_back_while_the_others_stay_changed`, `vm-look` | `SIGKILL`: the next run puts the settings back when it stops |
|
||||
| Queries never block on the compositor | convention only | none | the KWin backend's `cursor_pos` waits up to 250 ms |
|
||||
| Only the backend module reaches the compositor | convention only | none | none |
|
||||
@@ -1149,14 +1164,21 @@ A window is shown, and ends up on a tile:
|
||||
- [`nix/tests/vm/suites/kwin-restart`](../../nix/tests/vm/suites/kwin-restart/test.py): KWin
|
||||
restarting under the daemon.
|
||||
- [`nix/kde-rounded-corners.nix`](../../nix/kde-rounded-corners.nix): the build of the KWin
|
||||
effect that draws an outline around each window, and
|
||||
effect that draws an outline around each window, with
|
||||
[`komorebi-border-colours.patch`](../../nix/kde-rounded-corners/komorebi-border-colours.patch),
|
||||
which lets komorebi give each window a color; and
|
||||
[`nix/tests/effects.nix`](../../nix/tests/effects.nix), the checks of the files each effect
|
||||
package installs.
|
||||
- [`komorebi/tests/borders.rs`](../../komorebi/tests/borders.rs) and
|
||||
[`komorebi/tests/border_commands.rs`](../../komorebi/tests/border_commands.rs): the room a drawn
|
||||
border takes, and the messages that set the border, against the fake;
|
||||
[`komorebi/tests/border_colours.rs`](../../komorebi/tests/border_colours.rs) and
|
||||
[`komorebi/tests/borders_off.rs`](../../komorebi/tests/borders_off.rs), the color of each
|
||||
window's border, and none with borders off;
|
||||
[`nix/tests/vm/suites/look`](../../nix/tests/vm/suites/look/test.py), the border in a real
|
||||
Plasma session, read from the pixels of a screenshot.
|
||||
Plasma session, read from the pixels of a screenshot, and
|
||||
[`nix/tests/vm/suites/features`](../../nix/tests/vm/suites/features/test.py), the colors of the
|
||||
kinds of window.
|
||||
- [`komorebi/tests/wm_events.rs`](../../komorebi/tests/wm_events.rs): the window manager
|
||||
driven end to end against the fake.
|
||||
- [`komorebi/tests/socket.rs`](../../komorebi/tests/socket.rs): the daemon over its socket,
|
||||
@@ -1240,6 +1262,9 @@ A window is shown, and ends up on a tile:
|
||||
[`border_manager::current_look`]: ../../komorebi/src/border_manager/mod.rs
|
||||
[`border_manager::send_notification`]: ../../komorebi/src/border_manager/mod.rs
|
||||
[`BORDER_DRAWN`]: ../../komorebi/src/border_manager/mod.rs
|
||||
[`Backend::set_border_colours`]: ../../komorebi/src/backend/mod.rs
|
||||
[`border_manager::window_kinds`]: ../../komorebi/src/border_manager/mod.rs
|
||||
[`border_manager::update_colours`]: ../../komorebi/src/border_manager/mod.rs
|
||||
[`WindowManager::retile_all`]: ../../komorebi/src/window_manager.rs
|
||||
[`Ring`]: ../../komorebi/src/ring.rs
|
||||
[`Monitor`]: ../../komorebi/src/monitor.rs
|
||||
|
||||
@@ -425,3 +425,23 @@ Because KWin keeps the copy of `kwinrc` it read when it started, and an effect r
|
||||
from that copy, also one loaded a moment ago. Writing the file and loading the effect leaves the
|
||||
effect with the settings the file had at the start of the session. `reconfigureEffect` makes it
|
||||
read them again, so komorebi calls it every time, after loading too.
|
||||
|
||||
## Why does the border effect take a color for each window?
|
||||
|
||||
Because komorebi colors a window by what it is to the layout (the focused window of each monitor,
|
||||
a stack, a monocle, a floating window, a locked container), and the stock effect knows only "the
|
||||
active window" and "the others". komorebi's build of KDE Rounded Corners takes a color for each
|
||||
window over D-Bus, through KWin's name ([PLATFORM.md](PLATFORM.md#the-patches)). Without that
|
||||
build every kind falls back to the two colors of the look, and komorebi says so once in its log.
|
||||
|
||||
## Why are the effects patched?
|
||||
|
||||
Because the stock effects lack what komorebi needs of them. Each patch leaves the effect
|
||||
working without komorebi, with the settings the stock effect has:
|
||||
|
||||
| Effect | Patched for | Why |
|
||||
|---|---|---|
|
||||
| KDE Rounded Corners | a color for each window, set over D-Bus; drawing a window again when its opacity changes | komorebi colors a window by what it is to the layout (the focused window of each monitor, a stack, a monocle, a floating window, a locked container), and the stock effect has one color for the active window and one for the others. It also draws a window from a texture that has the window's opacity in it, made again only when the contents change or the window is resized, so a change of opacity alone would not show |
|
||||
|
||||
The patches are derivative works of the effects and are under the effects' license, the GNU
|
||||
General Public License version 3 ([PLATFORM.md](PLATFORM.md#the-patches)).
|
||||
+29
-1
@@ -227,6 +227,7 @@ What komorebi calls:
|
||||
| `org.freedesktop.DBus` | `/org/freedesktop/DBus` | `org.freedesktop.DBus` | `AddMatch(s)`, for the signal `NameOwnerChanged` | at start, to see KWin leave the bus and come back |
|
||||
| `org.kde.kglobalaccel` | `/component/kwin` | `org.kde.kglobalaccel.Component` | `invokeShortcut(s)`, with `MoveMouseToFocus` | when the pointer follows the focus |
|
||||
| `org.kde.KWin` | `/Effects` | `org.kde.kwin.Effects` | `isEffectSupported(s)`, `isEffectLoaded(s)`, `loadEffect(s)`, `unloadEffect(s)`, `reconfigureEffect(s)`, with `kwin4_effect_shapecorners` | when the look changes (the border is turned on, off or changed), and at exit |
|
||||
| `org.kde.KWin` | `/org/komorebi/BorderColours` | `org.komorebi.BorderColours1` | `SetColours(asau)`: the UUID of each window and its color, `0xRRGGBB` | when the color of a window's border changes; the object is komorebi's build of the border effect ([The patches](#the-patches)) |
|
||||
| `org.kde.KWin` | `/KWin` | `org.kde.KWin` | `reconfigure()` | after komorebi changed `kwinrc`, at start and at exit |
|
||||
| `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 |
|
||||
|
||||
@@ -401,7 +402,8 @@ The spikes measured the channel alone, with twenty windows in each batch, at 16,
|
||||
## KWin effects
|
||||
|
||||
An effect is a plugin of KWin's compositor that changes how windows are drawn. The flake
|
||||
builds the effects komorebi drives as packages of their own, from source:
|
||||
builds the effects komorebi drives as packages of their own, from source, with komorebi's
|
||||
patches (see [The patches](#the-patches)):
|
||||
|
||||
| Package | Effect | Plugin id | Installed as |
|
||||
|---|---|---|---|
|
||||
@@ -461,6 +463,32 @@ that way, also for an effect loaded a moment before. A screenshot of a session s
|
||||
in the pixels just outside the frame the window has in KWin, on all four sides, in the focused
|
||||
and unfocused colors, and not inside the frame.
|
||||
|
||||
### The patches
|
||||
|
||||
Each patch is a derivative work of the effect it changes, and is under the same license, the
|
||||
GNU General Public License version 3; its header states the license and describes the
|
||||
change. The check of each package asserts that its patch is in the build.
|
||||
|
||||
[`komorebi-border-colours.patch`](../../nix/kde-rounded-corners/komorebi-border-colours.patch),
|
||||
for KDE Rounded Corners, makes two changes:
|
||||
|
||||
- **A color for each window.** The stock effect has one outline color for the active window
|
||||
and one for the others. The patched effect exports an object through KWin's name, which
|
||||
takes a color for each window:
|
||||
|
||||
| Name | Object | Interface | Member |
|
||||
|---|---|---|---|
|
||||
| `org.kde.KWin` | `/org/komorebi/BorderColours` | `org.komorebi.BorderColours1` | `SetColours(asau)` |
|
||||
|
||||
`SetColours` replaces the colors of every window at once: the windows' UUIDs as KWin writes
|
||||
them (with or without braces), and `0xRRGGBB` values in the same order. A window it does not
|
||||
name gets the colors of the settings for the active and the other windows. The object is
|
||||
registered when the effect is loaded, and removed with every color when it is unloaded.
|
||||
- **A window is drawn again when its opacity changes.** The effect draws a window from a
|
||||
texture that has the window's opacity in it, and makes the texture again only when the
|
||||
contents change or the window is resized, so a change of opacity alone would not show. The
|
||||
patched effect redirects the window again when its opacity changes.
|
||||
|
||||
## Rendering in virtual machines and over RDP
|
||||
|
||||
At time of writing (2026-10-27):
|
||||
|
||||
@@ -148,6 +148,9 @@ the run.
|
||||
- `effect_supported(name)` and `effect_loaded(name)` ask KWin whether an effect is
|
||||
installed (KWin found it when it started) and loaded, and `unload_effect(name)`
|
||||
unloads one, whoever loaded it.
|
||||
- `colored_window(title, color)` opens a terminal that is one color all over, and
|
||||
waits for KWin to have it, and `close_colored_windows()` closes them: a test
|
||||
reads the color of a pixel of a screenshot, and wants nothing else there.
|
||||
- `pixels` reads a screenshot: `pixels.pixel(image, x, y)` is the color of a
|
||||
pixel, `pixels.near(a, b)` compares two colors within a tolerance, since a
|
||||
compositor blends the edge of what it draws, and `pixels.ring(image, frame,
|
||||
|
||||
+31
-2
@@ -2,8 +2,9 @@
|
||||
|
||||
komorebi puts a colored border around every window. It does not draw it: a KWin effect, KDE
|
||||
Rounded Corners, draws the border outside each window, in the gap between the tiles, and komorebi
|
||||
tells the effect how wide it is, how round the corners are and which color to use. The border
|
||||
around the window that has the focus is blue, and the border around every other window is gray.
|
||||
tells the effect how wide it is, how round the corners are and which color each window's border
|
||||
has. The border around the window that has the focus is blue, and the border around every other
|
||||
window is gray.
|
||||
|
||||
## Installing the effect
|
||||
|
||||
@@ -26,6 +27,34 @@ komorebic border disable
|
||||
komorebic border enable
|
||||
```
|
||||
|
||||
## Colors
|
||||
|
||||
A window's border has the color of what the window is to the layout:
|
||||
|
||||
| Kind | Window | Default |
|
||||
|---|---|---|
|
||||
| `single` | the focused window | blue, `66 165 245` |
|
||||
| `unfocused` | every other window | gray, `128 128 128` |
|
||||
| `unfocused-locked` | a locked container that does not have the focus | red, `158 8 8` |
|
||||
| `stack` | a stack that has the focus | green, `0 165 66` |
|
||||
| `monocle` | a monocled window | pink, `255 51 153` |
|
||||
| `floating` | a floating window that has the focus | yellow, `245 245 165` |
|
||||
|
||||
[`komorebic border-colour`](../cli/border-colour.md) sets the color of a kind, from its red,
|
||||
green and blue, each from 0 to 255; without `--window-kind` it sets `single`.
|
||||
|
||||
```sh
|
||||
komorebic border-colour 255 128 0
|
||||
komorebic border-colour --window-kind unfocused 64 64 64
|
||||
komorebic border-colour --window-kind floating 200 200 0
|
||||
```
|
||||
|
||||
The stock KDE Rounded Corners has one color for the active window and one for the others. The
|
||||
build the flake installs also takes a color for each window, which is what lets a locked, a
|
||||
floating, a stack and a monocled window have colors of their own. With the stock effect every
|
||||
kind is drawn as `single` or `unfocused`, whichever is closer, and komorebi says so once in its
|
||||
log.
|
||||
|
||||
## Width and room
|
||||
|
||||
[`komorebic border-width`](../cli/border-width.md) sets how thick the border is, in pixels: 10 by
|
||||
|
||||
Reference in new issue
Block a user