Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The layout boundary

The interface between src/layout/ and the rest of the compositor. Someone with different layout opinions replaces the layout side and keeps everything else.

LayoutElement

The abstraction that keeps the layout ignorant of Wayland. Defined in src/layout/mod.rs:

  • identity: id(), is_wl_surface(), is_child_of()
  • geometry: size(), buf_loc(), min_size(), max_size()
  • size negotiation: request_size(), expected_size(), sizing_mode()
  • rendering: render(), render_normal(), render_popups()
  • state: set_activated(), set_floating(), set_bounds()
  • transactions: configure_intent(), send_pending_configure(), on_commit()

The layout arranges rectangles. It never touches surfaces, buffers, or protocol types.

The pieces

  • Tile<W> (src/layout/tile.rs): wraps a LayoutElement with border, focus ring, shadow, and animations.
  • FloatingSpace<W> (src/layout/floating.rs): freely positioned tiles.
  • TilingSpace<W> (src/layout/tiling_space.rs): a flat tile list with a pluggable algorithm and per-space params; also per-window maximize and the rearrange animation.
  • Workspace<W> (src/layout/workspace.rs): owns a TilingSpace and a FloatingSpace.
  • Monitor (src/layout/monitor.rs): output plus workspace index.
  • The Layout<W> facade (src/layout/mod.rs): the API the rest of the compositor calls.

The facade’s API

Tiling: focus_next_window, focus_prev_window, focus_master, swap_with_master, swap_next_window, swap_prev_window, cycle_layout, flip_layout, reset_layout, grow_master_ratio, shrink_master_ratio, inc_master_count, dec_master_count, inc_stack_count, dec_stack_count.

General: window add and remove, focus, output management, workspace switching, rendering, interactive move and resize, queries.

Callers

  • src/atrium.rs: rendering, window queries, animation.
  • src/input/mod.rs: action dispatch; the tiling actions are wired here.
  • src/handlers/: window lifecycle.

Tests at the boundary

  • Golden geometry snapshots (src/layout/tests/tiling_geometry.rs) pin the exact tile rectangles for each algorithm with one to six windows.
  • Fixture tests (src/tests/) assert what clients actually receive: configure sizes, bounds, states.
  • check_ops and verify_invariants exercise structural invariants under random operation sequences.

make test runs all of it with clippy at -D warnings.