From a8991f65602abc5ecee740c443c58fa96ecd15e1 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Tue, 4 Nov 2025 11:55:00 +0200 Subject: Fix window memory never saving on close, and split-screen icon/primary bugs Screenshotted the just-split display on request rather than guessing -- it showed why windows never seem to remember placement/size, plus two real split-screen bugs. Window memory (WindowManager::remembered_geometry) was correctly wired on the read side, but the only writes came from end_drag/end_resize in dragresize.rs - a real drag or resize. A window the user opens, looks at, and closes without ever touching its edges had nothing recorded, so reopening it always fell back to a fresh cascade placement, for what is probably most ordinary window lifecycles. remove_window now also snapshots geometry (same app_id-non-empty gate the drag/resize sites use), persisted at both of its wayland-side call sites the same way the drag/resize-release site already does. desktop_icon_origins mirrored the full icon set onto every Monitor entry when general.desktop_icons_all_monitors is on - which, after a srd.monitor.split, is one entry per split part of the same physical screen, not one per real monitor. Extracted into a separately-tested icon_origins_for that collapses split parts of the same connector back to one origin, keeping a genuinely separate monitor's own origin intact. Found while fixing that: every split part also reported primary: true (computed from the connector's name, which doesn't vary per part) -- fixed by gating on part == 0 too. --- crates/wayland/src/state/lifecycle.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crates/wayland/src/state/lifecycle.rs') diff --git a/crates/wayland/src/state/lifecycle.rs b/crates/wayland/src/state/lifecycle.rs index 53a5e86..1749a3c 100644 --- a/crates/wayland/src/state/lifecycle.rs +++ b/crates/wayland/src/state/lifecycle.rs @@ -301,6 +301,11 @@ impl CompState { self.close_snap_flyout(); } self.wm.borrow_mut().remove_window(id); + // Persists whatever `remove_window` just snapshotted into + // `remembered_geometry` - see that function's own doc comment for + // why a window closing, not just a manual drag/resize release, + // needs to reach disk too. + crate::window_memory::save_all(self.wm.borrow().all_remembered_geometry()); self.pending.borrow_mut().push(CoreEvent::WindowDestroyed(id)); foreign_toplevel::window_closed(self, id); // `remove_window` may have picked a new focused window on its own -- cgit v1.2.3