From 7c02df250e8f17afd406dbc1460d131fb2b13777 Mon Sep 17 00:00:00 2001 From: Hojjat Date: Tue, 21 Apr 2026 12:16:44 -0600 Subject: [PATCH] fix: restore the window to where it was before the drag Restoring a window after snapping it to a corner, or maximizing it should restore to where the window was before the drag, not after the drop. --- src/shell/grabs/moving.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index b49bdd84..ad5915f9 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -869,12 +869,22 @@ impl Drop for MoveGrab { if matches!(previous, ManagedLayer::Floating) && let Some(sz) = grab_state.snapping_zone { + // `last_geometry` was set to the pre-drag geometry(in FloatingLayout::unmap). + // Snapshot it here and restore it after so "restore-to-floating" goes back to where the user had the window. + let pre_drag_geometry = *window.last_geometry.lock().unwrap(); + if sz == SnappingZone::Maximize { shell.maximize_toggle( &window, &seat, &state.common.event_loop_handle, ); + if let Some(geo) = pre_drag_geometry + && let Some(state) = + window.maximized_state.lock().unwrap().as_mut() + { + state.original_geometry = geo; + } } else { let directions = match sz { SnappingZone::Maximize => vec![], @@ -904,6 +914,9 @@ impl Drop for MoveGrab { &window, ); } + if let Some(geo) = pre_drag_geometry { + *window.last_geometry.lock().unwrap() = Some(geo); + } } } Some((window, location.to_global(&output)))