Pane logo

Rust ยท tiling window manager engine

Windows that always
tile the screen.

Pane is a dependency free tiling window manager engine in pure Rust, zero external crates. It does not bind to a display server. It treats the screen as an abstract rectangle and computes exactly where every window goes, which makes the whole engine headless, testable, and provable: for any sequence of operations the tiled windows form an exact partition of the screen. Open windows, split, move, resize, float, and switch workspaces here, and watch the partition invariant recheck after every action.

Open the playground View on GitHub
How to use this playground
  1. Open a window. Press Open (vertical). The first window fills the whole screen. Each further open splits the focused window in two, side by side for vertical or stacked for horizontal.
  2. See the focus. The focused window has a bright border and is marked with * in the layout tree on the right.
  3. Move focus. The arrow buttons under focus move the highlight to the nearest window in that direction. Nothing else changes.
  4. Move a window. The move arrows swap the focused window with its neighbour, so you can rearrange the layout.
  5. Resize. Grow and Shrink change the split ratio of the focused window against its sibling.
  6. Float. Toggle float lifts the focused window out of the tiling as an overlay (shown dashed and amber). Floating windows are deliberately excluded from the partition, which the readout accounts for.
  7. Workspaces. The numbered buttons switch between independent layouts. Each workspace keeps its own tree and focus.
  8. Watch the invariant. The readout below the screen recomputes after every action and confirms that the tiled windows plus the gaps exactly equal the screen area. If it ever turned red, the tiling would have a hole or an overlap.

A short guided tour

  1. Press Open (vertical) three times. You now have three windows side by side, and the readout shows windows plus gaps equal the screen.
  2. Press a focus arrow to select a different window, then Open (horizontal). Only the focused window splits, into a top and bottom pair.
  3. Press Grow a few times and watch the focused window take space from its sibling while the total stays exact.
  4. Press Toggle float. The window lifts out as an overlay and the tiled windows reclaim its space. Toggle again to tile it back.
  5. Switch to workspace 2 and build a different layout. Switch back and your first layout is exactly as you left it.
windows
focus
move
resize
workspace
0dependencies
6library modules
8operations
4workspaces

the headless engine the playground drives, the same partition invariant the Rust core asserts after every operation. the readout under the screen rechecks live.

Simulated screen

invariant HOLDS

Layout tree


      

The same engine on the command line

The pane binary applies a scripted sequence of operations and prints the resulting tiling, with the partition accounting on every step. This is a real, trimmed run of pane demo.

$ pane demo pane demo on a 1200x800 screen with an 8px gap $ open # first window fills the screen window 1 * rect x=8 y=8 w=1184 h=784 invariant HOLDS | screen area 960000 = windows 928256 + gaps 31744 $ open h # split horizontally, two stacked windows window 1 rect x=8 y=8 w=1184 h=384 window 2 * rect x=8 y=408 w=1184 h=384 invariant HOLDS | screen area 960000 = windows 909312 + gaps 50688 $ open v # split the focused one vertically window 2 rect x=8 y=408 w=584 h=384 window 3 * rect x=608 y=408 w=584 h=384 invariant HOLDS | screen area 960000 = windows 903168 + gaps 56832 $ float # float the focused window over the tiling float 4 * rect x=300 y=200 w=600 h=400 invariant HOLDS | screen area 960000 = windows 903168 + gaps 56832

How it relates to a real window manager

Most tiling window managers weld their layout logic to X11, Wayland, or a specific OS. The interesting part, the algorithm that decides how windows share the screen, is buried under platform glue and cannot be reused or tested in isolation. Pane pulls that algorithm out on its own.

i3, bspwm, dwm

Real tiling window managers. They draw on a display server and manage real windows, and their layout core is tied to X11 or Wayland, so it is hard to reuse or test apart from the running compositor.

Pane

The layout core on its own. It treats the screen as an abstract rectangle, does no I/O, and binds to no display server, so it is headless, embeddable, and its partition invariant can be proven rather than hoped for.

Build on it

Someone building a real window manager can use Pane as the layout engine and write only a thin backend that draws the rectangles it returns. An agent managing panes or viewports can drive it through a tiny operation API and trust the partition to stay consistent.

The building blocks

What the engine is made of

tree Binary space partition

A leaf is a window, a split is two children with a direction and a ratio. Opening a window splits the focused leaf in two; closing one promotes its sibling.

geometry Exact integer split math

Splits use integer arithmetic clamped so both children keep positive size and the two extents always sum to the parent exactly. No floating point drift, no rounding holes.

invariant The partition invariant

The tiled cells exactly tile the screen: zero overlaps, zero uncovered space, and with gaps on, covered area plus gap area equals the screen area exactly.

focus Focus and move by geometry

Focus and move pick the nearest window in a direction by cell center, with a deterministic tie break, so navigation is spatial and reproducible.

workspaces Workspaces and monocle

Independent layouts each keep their own tree and focus. Monocle zooms one window fullscreen and restores the exact previous tiling on exit.

determinism Determinism

The same operation sequence yields identical rectangles every run, which is what makes the fuzz gates and the command line output reproducible.

The tiling is provably exact

The green readout under the screen is not decoration. It is the same partition invariant the Rust engine asserts after every single operation in tests/partition.rs: the tiled window cells exactly tile the screen, zero overlaps and zero uncovered space, and with gaps on, covered area plus gap area equals the screen area exactly. The checker itself is unit tested against known bad layouts so the gate cannot silently pass a hole.

# bounded for CI, tunable by env vars; the check runs after every operation
PANE_FUZZ_OPS=2000 PANE_FUZZ_RUNS=50 PANE_FUZZ_SEED=42 cargo test --release

# heavy stress, ten million operations on the partition gate
PANE_FUZZ_OPS=1000000 PANE_FUZZ_RUNS=10 PANE_FUZZ_MAX_WINDOWS=128 \
    cargo test --release --test partition partition_holds_no_gap

Use it

Pane is a library plus a small binary, pure Rust with zero external crates. Embed the engine, or script it from the command line.

Library

Build a WindowManager over a Rect, apply Op values, and read the placements from frame(). The modules split cleanly: geometry, tree, workspace, manager, invariant, and render.

CLI binary

The pane binary runs a scripted operation sequence and prints the tiling, with a configurable screen size and gap. Feed it a script argument or pipe one in.

Gates and stress

cargo test runs the partition, tree consistency, and determinism gates, tunable through PANE_FUZZ_OPS, PANE_FUZZ_RUNS, and PANE_FUZZ_MAX_WINDOWS for heavy stress.

# build, test the correctness gates, lint with warnings denied
cargo build --release
cargo test
cargo clippy --all-targets -- -D warnings

# the binary applies a scripted sequence of operations and prints the tiling
pane demo
pane --gap 8 'open; open h; focus up; open v; resize right'
pane --screen 1920x1080 --gap 4 'open; open v; open h'