forge
Explore
Log in

Don't you dare go Hollow

Don't snap after DnD scroll if view position didn't change

Browse files at this commit

dca187de37164df2584f7388cd0bb6429337a580Ivan MolodetskikhParent: fe660a2
Otherwise, any DnD breaks temporarily centered columns.
src/layout/mod.rsmodified+5 -5
@@ -1105,7 +1105,7 @@ impl<W: LayoutElement> Layout<W> {
11051105
11061106 // Unlock the view on the workspaces.
11071107 for ws in self.workspaces_mut() {
1108- ws.view_offset_gesture_end(false, None);
1108+ ws.dnd_scroll_gesture_end();
11091109 }
11101110
11111111 return Some(RemovedTile {
@@ -3853,7 +3853,7 @@ impl<W: LayoutElement> Layout<W> {
38533853 let moved_tile_was_active =
38543854 ws.active_window().is_some_and(|win| *win.id() == window_id);
38553855
3856- ws.view_offset_gesture_end(false, None);
3856+ ws.dnd_scroll_gesture_end();
38573857
38583858 if moved_tile_was_active {
38593859 ws.activate_window(&window_id);
@@ -3876,7 +3876,7 @@ impl<W: LayoutElement> Layout<W> {
38763876 // Unlock the view on the workspaces.
38773877 if !move_.is_floating {
38783878 for ws in self.workspaces_mut() {
3879- ws.view_offset_gesture_end(false, None);
3879+ ws.dnd_scroll_gesture_end();
38803880 }
38813881 }
38823882
@@ -4050,7 +4050,7 @@ impl<W: LayoutElement> Layout<W> {
40504050 self.dnd = None;
40514051
40524052 for ws in self.workspaces_mut() {
4053- ws.view_offset_gesture_end(false, None);
4053+ ws.dnd_scroll_gesture_end();
40544054 }
40554055 }
40564056
@@ -4459,7 +4459,7 @@ impl<W: LayoutElement> Layout<W> {
44594459 if is_scrolling {
44604460 ws.dnd_scroll_gesture_begin();
44614461 } else {
4462- ws.view_offset_gesture_end(false, None);
4462+ ws.dnd_scroll_gesture_end();
44634463 }
44644464 } else {
44654465 // Cancel the view offset gesture after workspace switches, moves, etc.
src/layout/scrolling.rsmodified+20 -0
@@ -3232,6 +3232,26 @@ impl<W: LayoutElement> ScrollingSpace<W> {
32323232 true
32333233 }
32343234
3235+ pub fn dnd_scroll_gesture_end(&mut self) {
3236+ let ViewOffset::Gesture(gesture) = &mut self.view_offset else {
3237+ return;
3238+ };
3239+
3240+ if gesture.dnd_last_event_time.is_some() && gesture.tracker.pos() == 0. {
3241+ // DnD didn't scroll anything, so preserve the current view position (rather than
3242+ // snapping the window).
3243+ self.view_offset = ViewOffset::Static(gesture.delta_from_tracker);
3244+
3245+ if !self.columns.is_empty() {
3246+ // Just in case, make sure the active window remains on screen.
3247+ self.animate_view_offset_to_column(None, self.active_column_idx, None);
3248+ }
3249+ return;
3250+ }
3251+
3252+ self.view_offset_gesture_end(false, None);
3253+ }
3254+
32353255 pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool {
32363256 if self.interactive_resize.is_some() {
32373257 return false;
src/layout/workspace.rsmodified+4 -0
@@ -1650,6 +1650,10 @@ impl<W: LayoutElement> Workspace<W> {
16501650 self.scrolling.dnd_scroll_gesture_scroll(delta);
16511651 }
16521652
1653+ pub fn dnd_scroll_gesture_end(&mut self) {
1654+ self.scrolling.dnd_scroll_gesture_end();
1655+ }
1656+
16531657 pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool {
16541658 if self.floating.has_window(&window) {
16551659 self.floating.interactive_resize_begin(window, edges)