Grid on the canvas model
Purpose
The Grid layout runs on the Canvas coordinate model through a locked camera, so there is one placement and projection path with no visible change to the Grid. This spec indexes the rules of the built steps.
Requirements
Requirement: Non-Canvas workspaces use a locked identity camera
A workspace that is not Canvas SHALL have a locked camera: in step 1, zoom 1 over a viewport at the origin, so the projection is the identity; since steps 2 to 4 it is derived from the formation pair and fitted with zoom at most 1, the identity only when formation and area are equal. The placement MUST stay the same as before to the pixel, and no input pans or zooms the locked camera. Full text: sections Step 1 (implemented) and Steps 2 to 4 (as built).
Scenario: Non-Canvas workspaces use a locked identity camera
- WHEN a Grid window is drawn
- THEN its placement equals the one before the locked camera, to the pixel
Requirement: Floating chat on the Grid
On a Grid workspace that the primary output shows, the primary chat SHALL be no grid member and float over the windows, by the one rule floating_chat_in (Canvas, or Grid on the primary output). The margin beside the whole chat is no cell, takes no grid key and is no target. Full text: section Step 1b (implemented): the floating chat on the Grid.
Scenario: Floating chat on the Grid
- WHEN the whole chat shows on a Grid workspace
- THEN the formation uses the content area minus a margin at the chat side and the margin is no cell
Requirement: Grid with floating chat stays a Grid
A Grid workspace with a floating chat SHALL stay Layout::Grid, and the output chat of a Grid workspace on an extra output stays a tile. Full text: section Step 1b (implemented): the floating chat on the Grid.
Scenario: Grid with floating chat stays a Grid
- WHEN the chat floats on a Grid workspace
- THEN the workspace layout is still
Layout::Grid
Requirement: Press outside hides the floating chat
A press outside the shown floating chat SHALL hide it on the Grid as on a Canvas (hide_chats_on_press). Full text: section Step 1b (implemented): the floating chat on the Grid.
Scenario: Press outside hides the floating chat
- WHEN the user presses outside the shown floating chat
- THEN the chat hides
Requirement: Grid is still Layout::Grid
The Grid SHALL remain Layout::Grid, not a Canvas with a frozen camera, and nothing changes for the user, the agent tools or the core. Full text: section Steps 2 to 4 (as built).
Scenario: Grid is still Layout::Grid
- WHEN the Grid workspace is built on the camera model
- THEN its layout is still
Layout::Grid
Requirement: Locked camera is derived, not stored in ViewState
The locked camera SHALL be derived from the stored formation pair and MUST NOT be written into ViewState, because ViewState.camera stays the free camera that a switch to Canvas restores. Full text: section Steps 2 to 4 (as built).
Scenario: Locked camera is derived, not stored in ViewState
- WHEN a workspace switches from Grid to Canvas
- THEN the free camera in
ViewStateis restored unchanged
Requirement: Locked camera fit
The locked camera SHALL fit the formation into the area, centered, with the zoom at most 1, and be exactly the identity when both are equal. Full text: section Steps 2 to 4 (as built).
Scenario: Locked camera fit
- WHEN the formation and the area are equal
- THEN the camera is exactly the identity
Requirement: Formation does not need the canvas lease
The formation, the stored pair and the locked camera MUST NOT read the canvas setting or its lease. Only the free camera, the Canvas layout with its chat start and the agent canvas tools still need the setting. Full text: section Steps 2 to 4 (as built).
Scenario: Formation does not need the canvas lease
- WHEN the
canvaslease is off - THEN the formation and the locked camera still work
Status
Doc status: current contract. Uncertain: the section Next steps (proposal) looks stale, since steps 2 to 4 landed. Checked 2026-11-10.
Introduction
Status: step 1 and step 1b implemented on 2026-11-03; steps 2 to 4 (phase 3 of shared workspace cameras) implemented the same day with no visible change, see Steps 2 to 4 (as built); the S4 freeze of the formation off the primary output and the fitted camera are built in phase 4 of that spec (2026-11-03), on a compositor with capabilities.sharedGrid, always on (capability plus lease); see its As built (phase 4).
Request
On 2026-11-03 the user proposed running the Grid layout on top of the Canvas model, to have one placement and coordinate path instead of two, and asked for the simplest version, with no visible change to the Grid.
Step 1 (implemented)
A workspace that is not Canvas has a locked camera: zoom 1 over a viewport at the
origin, so canvas units are screen pixels and the projection is the identity
(crate::canvas::locked_project). Compositor::screen_placement, which the scene uses
to draw and the input uses to hit test every window outside the focus layout, sends the
Space location and drawn size of a Grid, Floating or extra-output window through that
projection (also any window of a Canvas workspace without a canvas placement). The result is the same Placement as before, to the pixel, so nothing
changes for the user, the agent tools or the core. The Grid still computes its cells in
desktop/layout.rs and still configures each window at its cell size. No input pans or
zooms the locked camera, because it is not stored anywhere: it is a constant.
Step 1b (implemented): the floating chat on the Grid
On 2026-11-03 the user decided "no modo grid também pode manter o mesmo comportamento
do card de não travar, ficar flutuante". On a Grid workspace that the primary output
shows, the primary chat is no grid member (home_grid in desktop/tiling.rs gives it
no grid) and floats centered at crate::canvas::dock(content) over the windows, placed
in the Grid pass of apply_layout. floating_chat_in in desktop/canvas_mode.rs is
the one rule: Canvas, or Grid on the primary output. chat_hidden, set_chat_hidden
(the chat_dock command), the Super tap, chat_docked (the dock glass) and the chat
regions follow it. Since the Super mode of 2026-11-04 (super-mode.md)
a new Grid workspace and a new canvas both start with the chat in the box (the composer
alone at the bottom center); a Canvas workspace that returns to Grid shows it again.
While the whole chat shows, the Grid formation uses the content area minus a margin at
the chat side (chatDockSide, right by default), and the chat floats in that margin;
the margin is no cell, takes no grid key and is no target. The box and the hidden chat
give the formation the whole content area. History: from 2026-11-03 to 2026-11-04 a new
Grid workspace started with the chat shown and a new canvas with it hidden. The snapshot reports floatingChat {workspace, state} for the primary
workspace while its chat floats (null elsewhere), which the core and the host read for
a Grid workspace, because canvasWorkspaces lists only canvas bases. The workspace stays
Layout::Grid: item 3 below no longer blocks, the other items still do. The output chat
of a Grid workspace on an extra output stays a tile. Since 2026-11-03 a press outside the
shown floating chat hides it on the Grid as on a Canvas (hide_chats_on_press, see the
Click outside item of openspec/specs/canvas-windows/spec.md).
Steps 2 to 4 (as built)
Built on 2026-11-03 as phase 3 of one workspace list, one camera per monitor, approved with every default ("Seguir para o Grid"). Nothing changes for the user, the agent tools or the core: the Grid is still Layout::Grid, not a Canvas with a frozen camera, for the reasons of the next section.
- Formation (step 2).
crate::grid::Grid(theWorkspace.gridof a workspace) hasformation, the rectangle that its 6 x 4 cells divide, in canvas units, andformation_area, the screen grid area where it draws.Compositor::grid_formation(desktop/canvas_mode.rs) is the size rule: while an output shows the workspace, its grid area (on the primary output the content area between the bars: S4, so the primary view stays the identity; on an extra output the whole output, as W9 does today), else the stored rectangle.sync_formations, at the start of eachapply_layoutaftersync_views, stores both for every shown workspace that has a state; a workspace that leaves every output keeps the rectangle of its last view. This answers the open size question of step 2: the primary content area owns the size. The cells are still placed withgrid_area, which equals the formation in this phase, so every pixel stays. - Camera on every workspace (step 1 stored).
Compositor::workspace_cameragives the camera of any workspace: the free camera of the view on Canvas, elsecrate::canvas::locked_camera(formation, formation_area), which fits the formation into the area centered with the zoom at most 1 (S5) and is exactly the identity when both are equal. The locked camera is derived from the stored pair, not written intoViewState, becauseViewState.camerastays the free camera that a Super+Shift+T to Canvas restores (W9 carry); writing the locked camera there would move the camera of that switch, a visible change. - Projection.
screen_placementsends a window of a Grid, Focus or Floating workspace on the primary slot throughworkspace_camera(locked_view); the shell, the windows of an extra output grid and the windows of a Canvas workspace without a canvas placement keep the identity of step 1. - Lease (step 3). The formation, the stored pair and the locked camera never read the
canvassetting or its lease; a test runs them with the lease off. Only the free camera, the Canvas layout with its chat start and the agent canvas tools still need the setting; the floating Grid chat of step 1b never did. - Measurement (step 4). Scene measurement (
measure_the_grid_scenein native/smithay/src/grid_tests.rs, run with--ignored --nocapture, three runs each, on the 800 x 600 test output without bars, the chat and eight applications on one Grid workspace, lease off):screen_placement, which the scene and every hit test call per window, took about 147 ns per window before (fac6711) and about 209 ns after in a release build (1705 ns and 2315 ns in a debug build);apply_layoutstayed at about 16 us per pass in release (203 us and 207 us in debug). The added cost is two map lookups and the Canvas check per window, under 1 us per frame for nine windows. A first version that read the grid area live in that path cost 8.1 us per window in debug and was replaced by the stored pair. - Tests:
a_grid_workspace_stores_its_formation_and_a_locked_identity_camera_without_the_lease(grid_tests.rs) and the camera unit testsa_formation_larger_than_its_area_fits_centered_below_zoom_1andthe_locked_camera_projects_grid_rectangles_unchanged(canvas.rs). Every existing Grid, chat dock and agent contract test passes unchanged.
Left for phase 4, because each is visible with two outputs (built on 2026-11-03 for a shared Grid, see shared-workspace-cameras.md, As built (phase 4); a Grid that is not shared keeps the text below): the formation does not freeze on an extra output (it still takes the whole extra output, W9), the locked camera is never below zoom 1 in practice, the window sizes still come from the output area, and floating Grid windows stay in screen pixels (equal to canvas units while the camera is the identity). The snapshot does not report the formation or the locked camera, so the core contract is unchanged.
Why the Grid is not Layout::Canvas yet
Making a Grid workspace a real Canvas workspace with a frozen camera was checked against the code and is not safe as a small step:
- Setting and lease.
Layout::Canvasexists only while the protected settingcanvasholds the lease (set_canvas_enabled,disable_canvas); without it the compositor parks the windows back on the grid. A Grid that depends on the lease would break with the setting off (the default) and on the known-good fallback compositor, which has no Canvas, so a rollback across the change would lose the layout. - Sizes. A Canvas window keeps its client size and its saved size
(
keep_canvas_rect,restore_canvas_sizes); the Grid configures the cell size on each pass (place). Mixing both needs a per-workspace rule for who owns the size. - The chat. Since the Super mode of 2026-11-04 the chat of both layouts starts in the
box and follows the same Super tap; the whole chat is centered with no window and a
column beside windows on Canvas, and floats in a reserved margin (no cell) on the
Grid. History: on a Canvas workspace the chat floated centered, started hidden and
toggled with a Super tap (
set_chat_hidden,chat_docked); on the Grid it was a tile, and after step 1b it floated too but started shown. - Agent contracts.
grid_layout_only,canvas_layout_only, the 2 suser_activequiet time and therate_limitedlimit ofagent_windowkey offLayout::Canvas. They would start to apply to Grid focus and restore, a visible change. - Drawing cost. Canvas windows park outside the content area and draw through
canvas_placement, the canvas clip, the popup clip and the lens groups. The locked camera of step 1 adds one identity projection per window, the same work as the placement it replaces; the full canvas scene for a Grid was not measured.
Next steps (proposal)
- Store the camera on every workspace (Grid: locked), and make
canvas_placementtake that camera for Grid windows, still parked at their Space location. - Move the cell rectangles into canvas units on that camera, with the size rule of item 2.
- Decouple the lease from the coordinate model, so only the free camera, the floating
chat and the agent canvas tools need the
canvassetting. - Measure the Grid scene at zoom 1 before and after each step.
These steps are also phase 1 of one workspace list, one camera per monitor (approved on 2026-11-03), which shows one Grid workspace on several outputs as one formation seen through one camera per output.