diff options
| author | srdusr <[email protected]> | 2025-11-04 11:55:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2025-11-04 11:55:00 +0200 |
| commit | a8991f65602abc5ecee740c443c58fa96ecd15e1 (patch) | |
| tree | 31c9d1e15915b6e3757b293140e6ee47b6d28008 /crates/core/src/manager/tests.rs | |
| parent | a4710d792a1b16698fc30b9e97e6c08c82129d6d (diff) | |
| download | srdwm-a8991f65602abc5ecee740c443c58fa96ecd15e1.tar.gz srdwm-a8991f65602abc5ecee740c443c58fa96ecd15e1.zip | |
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.
Diffstat (limited to 'crates/core/src/manager/tests.rs')
| -rw-r--r-- | crates/core/src/manager/tests.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crates/core/src/manager/tests.rs b/crates/core/src/manager/tests.rs index c82d3dd..3d628a8 100644 --- a/crates/core/src/manager/tests.rs +++ b/crates/core/src/manager/tests.rs @@ -363,6 +363,35 @@ } #[test] + fn closing_a_window_remembers_its_geometry_even_if_it_was_never_dragged_or_resized() { + // Real report: "windows don't remember their placement/size" -- + // true for any window the user never manually touched, since only + // `end_drag`/`end_resize` used to write `remembered_geometry` at + // all. A window that was simply placed by SmartPlacement, looked + // at, and closed had nothing recorded, so reopening it always fell + // back to a fresh placement - indistinguishable from the memory + // feature not existing at all for that (extremely common) case. + let mut wm = wm_with_monitor(); + wm.set_layout(wm.current_workspace(), "tiling"); + let a = wm.alloc_window_id(); + let mut w = Window::new(a, "a"); + w.app_id = "alacritty".into(); + w.geometry = Rect::new(321, 111, 444, 222); + wm.add_window(w); + // Never dragged, never resized - closed exactly as SmartPlacement + // left it. + wm.remove_window(a); + + let b = wm.alloc_window_id(); + let mut w2 = Window::new(b, "b"); + w2.app_id = "alacritty".into(); + w2.geometry = Rect::new(0, 0, 800, 600); + wm.add_window(w2); + let placed = wm.window(b).unwrap().geometry; + assert_eq!((placed.x, placed.y, placed.width, placed.height), (321, 111, 444, 222), "the next alacritty window must open where/how large the first one was when it closed"); + } + + #[test] fn a_remembered_position_on_a_monitor_that_no_longer_exists_falls_back_to_placement() { let mut wm = wm_with_monitor(); wm.set_layout(wm.current_workspace(), "dynamic"); |