mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 14:48:34 +01:00
feat(wm): layouts
Every workspace started in BSP and stayed there. `komorebic change-layout` gives the focused workspace one of the layouts of komorebi-layouts, `cycle-layout next|previous` steps through them, and `flip-layout` mirrors the tiles along an axis, on top of the flip there is. A flip mirrors the tiles, not the order of the containers, and the directions of focus and move are flipped with it, so `focus left` still goes to the tile on the left. `toggle-tiling` turns the tiling of the focused workspace off and on: while it is off, no window of the workspace is moved, and the windows that open are taken in and tiled once it is on again. `preselect-direction` reserves the place on one side of the focused window for the next window: an empty container holds it, the layout gives it a tile, and the next window takes it. `cancel-preselect` gives it back. A new VM suite, vm-commands, after the spike's m8 script, runs every layout with five, three, two and one windows against a real KWin with two outputs, and then every komorebic command there is, checking after each that the daemon is alive, answers, and has every window KWin has, and that KWin has the windows where the daemon asked. Every command that comes later adds its line to that sweep.
This commit is contained in:
1 parent
1bbb534844
commit
41c32aad8e
25 files changed
+1224
-70
No files matched your search
@@ -0,0 +1,10 @@
|
||||
```text
|
||||
Cancel a workspace preselect set by the preselect-direction command, if one exists
|
||||
|
||||
Usage: cancel-preselect
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
@@ -0,0 +1,23 @@
|
||||
```text
|
||||
Set the layout on the focused workspace
|
||||
|
||||
Usage: change-layout <DEFAULT_LAYOUT>
|
||||
|
||||
Arguments:
|
||||
<DEFAULT_LAYOUT>
|
||||
Possible values:
|
||||
- bsp: BSP Layout
|
||||
- columns: Columns Layout
|
||||
- rows: Rows Layout
|
||||
- vertical-stack: Vertical Stack Layout
|
||||
- horizontal-stack: Horizontal Stack Layout
|
||||
- ultrawide-vertical-stack: Ultrawide Vertical Stack Layout
|
||||
- grid: Grid Layout
|
||||
- right-main-vertical-stack: Right Main Vertical Stack Layout
|
||||
- scrolling: Scrolling Layout
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -0,0 +1,14 @@
|
||||
```text
|
||||
Cycle between available layouts
|
||||
|
||||
Usage: cycle-layout <CYCLE_DIRECTION>
|
||||
|
||||
Arguments:
|
||||
<CYCLE_DIRECTION>
|
||||
[possible values: previous, next]
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
@@ -0,0 +1,17 @@
|
||||
```text
|
||||
Flip the layout on the focused workspace
|
||||
|
||||
Usage: flip-layout <AXIS>
|
||||
|
||||
Arguments:
|
||||
<AXIS>
|
||||
Possible values:
|
||||
- horizontal: Horizontal axis
|
||||
- vertical: Vertical axis
|
||||
- horizontal-and-vertical: Both horizontal and vertical axes
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -0,0 +1,14 @@
|
||||
```text
|
||||
Preselect the specified direction for the next window to be spawned on supported layouts
|
||||
|
||||
Usage: preselect-direction <OPERATION_DIRECTION>
|
||||
|
||||
Arguments:
|
||||
<OPERATION_DIRECTION>
|
||||
[possible values: left, right, up, down]
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
```text
|
||||
Toggle window tiling on the focused workspace
|
||||
|
||||
Usage: toggle-tiling
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
|
||||
```
|
||||
@@ -27,7 +27,7 @@ its place here.
|
||||
- **Event**: what the compositor reports about a window: it was shown, destroyed, given
|
||||
the focus, minimized or restored ([`WindowManagerEvent`]).
|
||||
- **Message**: what a client sends the daemon on its socket, a [`SocketMessage`]: an order
|
||||
(focus a window, move it, retile, stop) or a question (the state, the monitors, one [`StateQuery`]).
|
||||
(focus a window, move it, change the layout, retile, stop) or a question (the state, the monitors, one [`StateQuery`]).
|
||||
- **Direction**: where an order goes from the focused container: a side of its tile
|
||||
([`OperationDirection`]), or the next or the previous container of the workspace
|
||||
([`CycleDirection`]).
|
||||
@@ -262,6 +262,22 @@ through `LockableSequence`, so a lock stays with its index: the container swappe
|
||||
index is locked in its place. When there is no container in that direction, the message fails
|
||||
and nothing moves.
|
||||
|
||||
`ChangeLayout` and `CycleLayout` set the focused workspace's [`Layout`], and `FlipLayout`
|
||||
mirrors it along an axis, on top of the flip it has ([`Workspace::layout_flip`]); each tiles
|
||||
the workspace again ([`WindowManager::change_workspace_layout_default`],
|
||||
[`WindowManager::cycle_layout`], [`WindowManager::flip_layout`]). A flip mirrors the tiles,
|
||||
not the order of the containers, and a direction is flipped with them, so `focus left` on a
|
||||
flipped layout goes to the tile on the left. `ToggleTiling` turns the workspace's tiling off
|
||||
and on ([`Workspace::tile`]): with it off, [`Workspace::update`] moves no window, the workspace
|
||||
still takes the windows that open into containers, and they are tiled when it is turned on.
|
||||
|
||||
`PreselectDirection` reserves the index on one side of the focused container for the next
|
||||
window ([`WindowManager::preselect_container_in_direction`]). The workspace inserts an empty
|
||||
container there ([`Container::preselect`]), which [`Workspace::update`] keeps and the layout
|
||||
gives a tile, and [`Workspace::new_container_for_window`] puts the next window in it.
|
||||
`CancelPreselect` removes it. A workspace reserves one place at a time, and the grid layout
|
||||
none.
|
||||
|
||||
## The NixOS module
|
||||
|
||||
The flake exports one module under two names, `nixosModules.default` and
|
||||
@@ -312,7 +328,7 @@ module's unit.
|
||||
changes its containers.
|
||||
- [`window_manager`](../../komorebi/src/window_manager.rs): the [`WindowManager`] and the
|
||||
operations on it (tile the workspace in front, tile every monitor, take a minimized
|
||||
window out, move the focus, move the focused container).
|
||||
window out, move the focus, move the focused container, change the layout).
|
||||
- [`desktop`](../../komorebi/src/desktop.rs): loads the monitors and the open windows from
|
||||
the backend.
|
||||
- [`window_manager_event`](../../komorebi/src/window_manager_event.rs) and
|
||||
@@ -395,6 +411,7 @@ the fake. The window manager is its only caller, through [`backend`]. The contra
|
||||
| A socket left behind by a daemon that did not stop cleanly does not keep the next one from starting | framework path: [`WindowManager::new`] removes the file before it binds | `a_socket_file_left_behind_is_replaced` | none |
|
||||
| A daemon that is told to stop leaves no socket behind | framework path: [`WindowManager::stop`] removes it before it exits | `the_daemon_answers_on_its_socket_and_stops_when_it_is_told_to` | `SIGKILL` |
|
||||
| A container moved onto a locked index is locked in its place, and the lock leaves the container that moved away | framework path: [`Workspace::swap_containers`] swaps through `LockableSequence`, which keeps the lock with the index | `test_swap_respecting_locks_various_cases`, `a_lock_stays_with_its_index_when_a_window_is_moved_onto_it` | `containers_mut()` is the `VecDeque` itself |
|
||||
| A workspace whose tiling is off moves no window | framework path: [`Workspace::update`] returns before the layout when [`Workspace::tile`] is false | `with_tiling_off_no_window_is_moved_until_it_is_back_on` | none |
|
||||
| Moving the focus moves no window | test | `focus_gives_the_focus_to_the_window_on_that_side_and_moves_nothing`, `vm-core-e2e` ("moving the focus moved no window") | none |
|
||||
| A subscriber that is gone is dropped, not retried | test | `a_subscriber_that_is_gone_is_dropped_and_not_tried_again` | none |
|
||||
| The bridge holds no window manager logic | convention, with every decision about an event in the table, which the `kwin::state` unit tests pin | the unit tests in `komorebi/src/kwin/state.rs` | none |
|
||||
@@ -503,9 +520,12 @@ A window is shown, and ends up on a tile:
|
||||
driven end to end against the fake.
|
||||
- [`komorebi/tests/socket.rs`](../../komorebi/tests/socket.rs): the daemon over its socket,
|
||||
from its start to a `Stop`.
|
||||
- [`komorebi/tests/focus.rs`](../../komorebi/tests/focus.rs) and
|
||||
[`komorebi/tests/moving.rs`](../../komorebi/tests/moving.rs): the focus and move commands
|
||||
against the fake.
|
||||
- [`komorebi/tests/focus.rs`](../../komorebi/tests/focus.rs),
|
||||
[`komorebi/tests/moving.rs`](../../komorebi/tests/moving.rs) and
|
||||
[`komorebi/tests/layouts.rs`](../../komorebi/tests/layouts.rs): the focus, move and layout
|
||||
commands against the fake.
|
||||
- [`nix/tests/vm/suites/commands`](../../nix/tests/vm/suites/commands/test.py): every layout,
|
||||
and every `komorebic` command, against a real KWin with two outputs.
|
||||
- [`nix/nixos-module.nix`](../../nix/nixos-module.nix): the NixOS module;
|
||||
[`nix/tests/nixos-module.nix`](../../nix/tests/nixos-module.nix), its scenarios, evaluated in
|
||||
real NixOS systems; and [`nix/tests/vm/suites/module`](../../nix/tests/vm/suites/module/test.py),
|
||||
@@ -537,6 +557,14 @@ A window is shown, and ends up on a tile:
|
||||
[`WindowManager::move_container_in_direction`]: ../../komorebi/src/window_manager.rs
|
||||
[`WindowManager::move_container_in_cycle_direction`]: ../../komorebi/src/window_manager.rs
|
||||
[`Workspace::swap_containers`]: ../../komorebi/src/workspace.rs
|
||||
[`Workspace::layout_flip`]: ../../komorebi/src/workspace.rs
|
||||
[`Workspace::tile`]: ../../komorebi/src/workspace.rs
|
||||
[`Layout`]: ../../komorebi/src/core/mod.rs
|
||||
[`Container::preselect`]: ../../komorebi/src/container.rs
|
||||
[`WindowManager::change_workspace_layout_default`]: ../../komorebi/src/window_manager.rs
|
||||
[`WindowManager::cycle_layout`]: ../../komorebi/src/window_manager.rs
|
||||
[`WindowManager::flip_layout`]: ../../komorebi/src/window_manager.rs
|
||||
[`WindowManager::preselect_container_in_direction`]: ../../komorebi/src/window_manager.rs
|
||||
[`Workspace::new_idx_for_direction`]: ../../komorebi/src/workspace.rs
|
||||
[`Workspace::new_idx_for_cycle_direction`]: ../../komorebi/src/workspace.rs
|
||||
[`OperationDirection`]: ../../komorebi/src/core/mod.rs
|
||||
|
||||
@@ -126,8 +126,9 @@ the run.
|
||||
- `komorebic(*args)` runs `komorebic` in the session and returns what it
|
||||
printed, failing the test if it fails. `state()` is the daemon's state as
|
||||
`komorebic state` prints it, `managed(workspace)` the number of windows the
|
||||
daemon has on a workspace of the first monitor, and `focused_title(workspace)`
|
||||
the title of the window it has focused there.
|
||||
daemon has on a workspace of the first monitor, `managed_all()` the number it
|
||||
has on every workspace of every monitor, and `focused_title(workspace)` the
|
||||
title of the window it has focused there.
|
||||
- `daemon` reads the daemon's view of the desktop from that log, at the debug
|
||||
level the nodes set: `daemon.events(log)` lists the window events it handled,
|
||||
in order, `daemon.window_ids(log)` maps a window's title to the daemon's id
|
||||
|
||||
+2
-1
@@ -33,7 +33,8 @@ the flake's module, which also starts komorebi with every Plasma session, and fr
|
||||
anywhere else. [Running komorebi](usage/running-komorebi.md) explains how to start and stop the
|
||||
daemon, ask it what it is doing and read its log.
|
||||
[Focusing windows](usage/focusing-windows.md) explains how to give the focus to another window,
|
||||
and [Moving windows](usage/moving-windows.md) how to move the focused window to another tile.
|
||||
[Moving windows](usage/moving-windows.md) how to move the focused window to another tile, and
|
||||
[Layouts](usage/layouts.md) how to change the arrangement of the tiles.
|
||||
[Subscribing to notifications](usage/subscribing-to-notifications.md) explains how a program
|
||||
such as a status bar follows what komorebi does. The [CLI reference](cli/start.md) has a page
|
||||
for every `komorebic` command, generated from its help.
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
# Layouts
|
||||
|
||||
The layout of a workspace turns its work area and the number of its containers into one tile
|
||||
for each container. Every workspace starts with the BSP layout. A command that changes the
|
||||
layout tiles the focused workspace again at once.
|
||||
|
||||
## The layouts
|
||||
|
||||
These are the layouts of `komorebi-layouts`, in the order `cycle-layout next` goes through them:
|
||||
|
||||
| Layout | `komorebic` name | The tiles |
|
||||
|---|---|---|
|
||||
| BSP | `bsp` | each new tile splits the last one in two, alternately side by side and one above the other |
|
||||
| Columns | `columns` | side by side, as wide as each other |
|
||||
| Rows | `rows` | one above the other, as high as each other |
|
||||
| Vertical stack | `vertical-stack` | the first on the left half, the others stacked on the right |
|
||||
| Horizontal stack | `horizontal-stack` | the first on the top half, the others side by side below it |
|
||||
| Ultrawide vertical stack | `ultrawide-vertical-stack` | the first in the middle, the second on the left, the others stacked on the right |
|
||||
| Grid | `grid` | columns of tiles, as even as the number of containers allows |
|
||||
| Right main vertical stack | `right-main-vertical-stack` | the first on the right half, the others stacked on the left |
|
||||
| Scrolling | `scrolling` | columns side by side |
|
||||
|
||||
## Changing the layout
|
||||
|
||||
[`komorebic change-layout`](../cli/change-layout.md) gives the focused workspace the layout it
|
||||
names, and [`komorebic cycle-layout`](../cli/cycle-layout.md) the next or the previous one in
|
||||
the table above:
|
||||
|
||||
```sh
|
||||
komorebic change-layout vertical-stack
|
||||
komorebic cycle-layout next
|
||||
komorebic cycle-layout previous
|
||||
```
|
||||
|
||||
`cycle-layout next` goes from the scrolling layout back to BSP. Going backwards,
|
||||
`komorebi-layouts` leaves the scrolling layout out: `cycle-layout previous` goes from BSP to the
|
||||
right main vertical stack.
|
||||
|
||||
[`komorebic query focused-workspace-layout`](../cli/query.md) prints the layout of the focused
|
||||
workspace.
|
||||
|
||||
## Flipping the layout
|
||||
|
||||
[`komorebic flip-layout`](../cli/flip-layout.md) mirrors the tiles of the focused workspace:
|
||||
`horizontal` swaps left and right, `vertical` top and bottom, and `horizontal-and-vertical`
|
||||
both. A flip is added to the one the workspace has, so the same flip twice puts the layout
|
||||
back.
|
||||
|
||||
```sh
|
||||
komorebic flip-layout horizontal
|
||||
komorebic flip-layout horizontal
|
||||
```
|
||||
|
||||
The containers keep their order, and the directions of [`focus`](focusing-windows.md) and
|
||||
[`move`](moving-windows.md) are the ones on the screen: after `flip-layout horizontal`,
|
||||
`focus left` goes to the tile on the left.
|
||||
|
||||
## Turning tiling off
|
||||
|
||||
[`komorebic toggle-tiling`](../cli/toggle-tiling.md) turns the tiling of the focused workspace
|
||||
off, and on again. While it is off, komorebi moves none of its windows: they stay where they
|
||||
are, and can be moved by hand. Windows that open on the workspace are still taken into it, and
|
||||
when tiling is turned back on, every window is tiled again. `query focused-workspace-layout`
|
||||
prints `None` while tiling is off.
|
||||
|
||||
## Preselecting a tile
|
||||
|
||||
[`komorebic preselect-direction`](../cli/preselect-direction.md) reserves the place on one side
|
||||
of the focused window for the next window that opens on the workspace. The layout gives the
|
||||
reserved place a tile at once, empty until the window opens.
|
||||
[`komorebic cancel-preselect`](../cli/cancel-preselect.md) gives the place up.
|
||||
|
||||
```sh
|
||||
komorebic preselect-direction left
|
||||
komorebic cancel-preselect
|
||||
```
|
||||
|
||||
The place is a position in the order of the workspace, so where its tile is depends on the
|
||||
layout. A workspace reserves one place at a time: a second `preselect-direction` is ignored
|
||||
until the window opens or the place is given up. The grid layout has no preselection.
|
||||
Reference in new issue
Block a user