git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit968c182506678461675256e2f968ed172d0204ca
parent8c9d6479c5
authorLucas Galante <[email protected]>
date2026-08-17 12:02
restore: promote cell-aligned Floating windows to Tiled at map time

Geometric tiling detection only ran at drag/resize end, so a window
restored (or last-state-borrowed) onto an exactly cell-aligned saved
geometry kept its saved Floating mode until first touched — a migration
artifact from pre-rework state files. try_restore now runs the same
is_cell_aligned test and lock as op_end. No demotion here: a saved
Tiled window off the current grid re-snaps via the Tiled arrange arm.

Co-Authored-By: Claude Fable 5 <[email protected]>

 src/server/window.rs | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/server/window.rs b/src/server/window.rs
index 6e2f054..70013da 100644
--- a/src/server/window.rs
+++ b/src/server/window.rs
@@ -962,6 +962,28 @@ impl Window {
                 _ => {}
             }
 
+            // Geometric promotion at restore time: a window whose saved
+            // geometry sits cell-aligned IS tiled, even if an older session
+            // saved it as Floating (pre-rework state, or a session that
+            // never touched it after it landed on the grid). Same test and
+            // lock as the op_end detection. No demotion here — a saved
+            // Tiled window off the current grid is re-snapped by the Tiled
+            // arrange arm instead.
+            if self.tiling_mode == crate::tiling::TilingMode::Floating {
+                let sp = (*self.server).wm.layout.snap_params();
+                if crate::policy::snap::is_cell_aligned(
+                    self.virtual_x,
+                    self.virtual_y,
+                    saved.width as f64,
+                    saved.height as f64,
+                    &sp,
+                    1.0,
+                ) {
+                    self.tiling_mode = crate::tiling::TilingMode::Tiled;
+                    self.mode_locked = true;
+                }
+            }
+
             self.restored = true;
             self.session_restored = from_session;
             // The saved `focused` flag only means something for the startup