mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-23 00:44:15 +01:00
feat(wm): windows, containers, workspaces and monitors
The window manager tiles a tree of four levels: monitors, each with a ring of workspaces, each with a ring of containers, each with a ring of windows. It is the model komorebi has on Windows and macOS, and the first thing the daemon keeps that the backend does not give it. A window is a Copy handle that carries the compositor's id and asks the backend for everything else, so moving one is a call on the handle and needs no context passed to it. A workspace tiles itself: the layout gives each container a tile of the work area its monitor hands it, less the offset and the padding, and every window of the container is asked to move there. A locked container keeps its index because the workspace inserts, removes and swaps its containers through LockableSequence. This is tiling only. Stacks, monocle, maximize, the floating layer, resize adjustments, placement rules and the link between workspaces and KWin's desktops come with the commits that use them. impl_ring_elements!, which gives every holder of a ring the same accessors, lands here with its first users.
This commit is contained in:
1 parent
ed6a8e96c3
commit
c0345eb0e9
12 files changed
+2135
-7
No files matched your search
@@ -5,9 +5,9 @@ compositor to put it there. Everything it needs from the compositor is behind on
|
||||
[`Backend`](../../komorebi/src/backend/mod.rs), so the window manager is written, and
|
||||
tested, without one.
|
||||
|
||||
This page describes that trait, who implements and calls it, and where each of its rules
|
||||
is enforced. It grows with the code: each part of the daemon that is added has its place
|
||||
here.
|
||||
This page describes that trait, who implements and calls it, where each of its rules is
|
||||
enforced, and the model of the desktop the window manager tiles. It grows with the code:
|
||||
each part of the daemon that is added has its place here.
|
||||
|
||||
## Vocabulary
|
||||
|
||||
@@ -15,6 +15,12 @@ here.
|
||||
compositor's `u32` id.
|
||||
- **Monitor**: a connected output, with its bounds and its work area (its bounds minus
|
||||
the panels).
|
||||
- **Workspace**: the containers a monitor shows, in order, and the layout that tiles
|
||||
them. A monitor has a ring of workspaces and shows one of them.
|
||||
- **Container**: what a layout places. It gets one tile, and every window in it is put on
|
||||
that tile.
|
||||
- **Layout**: the arrangement (BSP, columns, rows, ...) that turns a work area and a
|
||||
number of containers into one rectangle, a **tile**, for each container.
|
||||
- **Compositor**: the program that owns the screen and the windows. On KDE Plasma it is
|
||||
KWin.
|
||||
- **Backend**: the implementation of the [`Backend`](../../komorebi/src/backend/mod.rs)
|
||||
@@ -48,11 +54,39 @@ The desktop, as the window manager sees it, is two lists and a pointer:
|
||||
A command is one of: move and resize a window, focus it, raise it, minimize it or bring it
|
||||
back, close it, and put the pointer in the middle of a rectangle.
|
||||
|
||||
The window manager tiles a tree of four levels, each level a [`Ring`]: a list with one
|
||||
element focused, so that "the focused workspace" or "the focused container" means
|
||||
the same thing at every level.
|
||||
|
||||
- A **monitor** ([`Monitor`]) is one of the backend's monitors: its bounds, its work area,
|
||||
its padding, an optional work area offset, and its workspaces. It shows the focused one.
|
||||
- A **workspace** ([`Workspace`]) has a layout, its padding, and its containers, in order.
|
||||
- A **container** ([`Container`]) has its windows. A new window gets a container of its
|
||||
own. A container can be locked, which keeps it at its index while others are inserted,
|
||||
removed or swapped around it.
|
||||
- A **window** ([`Window`]) is a `Copy` handle that carries only the compositor's id.
|
||||
Everything else about the window, and every change to it, goes through the backend.
|
||||
|
||||
Tiling a workspace ([`Workspace::update`]) is a function of this tree and a work area. The
|
||||
monitor gives its focused workspace the work area, the padding to fall back to and the
|
||||
offset ([`WorkspaceGlobals`]). The workspace takes the offset and its padding off the work
|
||||
area, the layout gives one tile per container, in order, each shrunk by the container
|
||||
padding, and every window of a container is asked to move onto its tile with `set_rect`. A
|
||||
tile is clamped to the work area, so it cannot reach onto a neighboring monitor.
|
||||
|
||||
## The parts
|
||||
|
||||
- [`backend`](../../komorebi/src/backend/mod.rs): the trait, the two data types, and the
|
||||
process-wide handle ([`set_backend`], [`backend`], [`with_backend`]).
|
||||
- [`backend::fake`](../../komorebi/src/backend/fake.rs): the fake.
|
||||
- [`ring`](../../komorebi/src/ring.rs): the [`Ring`], and the macro that gives every type
|
||||
holding one the same accessors (`containers()`, `focused_container_mut()`, ...).
|
||||
- [`monitor`](../../komorebi/src/monitor.rs), [`workspace`](../../komorebi/src/workspace.rs),
|
||||
[`container`](../../komorebi/src/container.rs), [`window`](../../komorebi/src/window.rs):
|
||||
the four levels of the tree.
|
||||
- [`lockable_sequence`](../../komorebi/src/lockable_sequence.rs): inserting, removing and
|
||||
swapping in a list where some elements are locked in place, which is how a workspace
|
||||
changes its containers.
|
||||
|
||||
The handle is a process-wide singleton so that a window can be a small `Copy` value
|
||||
that carries only its id, and ask the backend for what it needs. A test replaces it for
|
||||
@@ -84,6 +118,7 @@ the fake. The window manager is its only caller, through [`backend`]. The contra
|
||||
| The window manager asks for a backend that was never installed | runtime error: [`backend`] panics, naming [`set_backend`] and [`with_backend`] | `# Panics` on [`backend`] | none |
|
||||
| A test's backend does not outlive the test | framework path: [`with_backend`] restores the previous one on drop | `with_backend_puts_the_previous_backend_back_when_the_closure_panics` | none |
|
||||
| A command about a missing window is an error, not a panic | test | `a_command_about_a_window_nobody_opened_is_an_error` and `a_command_about_a_closed_window_is_an_error`, against the fake only | none |
|
||||
| A locked container keeps its index | framework path: a [`Workspace`] inserts, removes and swaps its containers through `LockableSequence` | `test_locked_containers_with_new_window` and `test_locked_containers_remove_window` | `containers_mut()` is the `VecDeque` itself |
|
||||
| Queries never block on the compositor | convention only | none | none |
|
||||
| Only the backend module reaches the compositor | convention only | none | none |
|
||||
|
||||
@@ -97,3 +132,21 @@ breaks the first, and a module that talks to D-Bus directly breaks the second.
|
||||
tests.
|
||||
- [`komorebi/src/core`](../../komorebi/src/core/mod.rs): the vocabulary the rest is written
|
||||
in.
|
||||
- [`komorebi/src/workspace.rs`](../../komorebi/src/workspace.rs): tiling, in
|
||||
`Workspace::update`.
|
||||
- [`komorebi/src/monitor.rs`](../../komorebi/src/monitor.rs): the work area, padding and
|
||||
offset a monitor gives the workspace it shows.
|
||||
|
||||
[`Backend`]: ../../komorebi/src/backend/mod.rs
|
||||
[`WindowInfo`]: ../../komorebi/src/backend/mod.rs
|
||||
[`MonitorInfo`]: ../../komorebi/src/backend/mod.rs
|
||||
[`set_backend`]: ../../komorebi/src/backend/mod.rs
|
||||
[`backend`]: ../../komorebi/src/backend/mod.rs
|
||||
[`with_backend`]: ../../komorebi/src/backend/mod.rs
|
||||
[`Ring`]: ../../komorebi/src/ring.rs
|
||||
[`Monitor`]: ../../komorebi/src/monitor.rs
|
||||
[`Workspace`]: ../../komorebi/src/workspace.rs
|
||||
[`Workspace::update`]: ../../komorebi/src/workspace.rs
|
||||
[`WorkspaceGlobals`]: ../../komorebi/src/workspace.rs
|
||||
[`Container`]: ../../komorebi/src/container.rs
|
||||
[`Window`]: ../../komorebi/src/window.rs
|
||||
+3
-1
@@ -12,7 +12,9 @@ komorebi has a Windows implementation, the original, and a macOS one. The Window
|
||||
the reference. I used it as the reference for what to adapt, and I prefer what KDE and
|
||||
Wayland do natively over a workaround that the other two platforms need. The events the
|
||||
window manager reacts to follow the Windows ones (a window is shown, destroyed, focused,
|
||||
minimized, moved, resized), and a window is a small `Copy` handle, as there.
|
||||
minimized, moved, resized), and a window is a small `Copy` handle, as there. The model the
|
||||
window manager tiles is the one both platforms have: monitors, each with workspaces, each
|
||||
with containers, each with windows.
|
||||
|
||||
## Why is everything the window manager needs behind one trait?
|
||||
|
||||
|
||||
Reference in new issue
Block a user