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> {
1105 1105
1106 // Unlock the view on the workspaces.1106 // Unlock the view on the workspaces.
1107 for ws in self.workspaces_mut() {1107 for ws in self.workspaces_mut() {
1108- ws.view_offset_gesture_end(false, None);1108+ ws.dnd_scroll_gesture_end();
1109 }1109 }
1110 1110
1111 return Some(RemovedTile {1111 return Some(RemovedTile {
@@ -3853,7 +3853,7 @@ impl<W: LayoutElement> Layout<W> {
3853 let moved_tile_was_active =3853 let moved_tile_was_active =
3854 ws.active_window().is_some_and(|win| *win.id() == window_id);3854 ws.active_window().is_some_and(|win| *win.id() == window_id);
3855 3855
3856- ws.view_offset_gesture_end(false, None);3856+ ws.dnd_scroll_gesture_end();
3857 3857
3858 if moved_tile_was_active {3858 if moved_tile_was_active {
3859 ws.activate_window(&window_id);3859 ws.activate_window(&window_id);
@@ -3876,7 +3876,7 @@ impl<W: LayoutElement> Layout<W> {
3876 // Unlock the view on the workspaces.3876 // Unlock the view on the workspaces.
3877 if !move_.is_floating {3877 if !move_.is_floating {
3878 for ws in self.workspaces_mut() {3878 for ws in self.workspaces_mut() {
3879- ws.view_offset_gesture_end(false, None);3879+ ws.dnd_scroll_gesture_end();
3880 }3880 }
3881 }3881 }
3882 3882
@@ -4050,7 +4050,7 @@ impl<W: LayoutElement> Layout<W> {
4050 self.dnd = None;4050 self.dnd = None;
4051 4051
4052 for ws in self.workspaces_mut() {4052 for ws in self.workspaces_mut() {
4053- ws.view_offset_gesture_end(false, None);4053+ ws.dnd_scroll_gesture_end();
4054 }4054 }
4055 }4055 }
4056 4056
@@ -4459,7 +4459,7 @@ impl<W: LayoutElement> Layout<W> {
4459 if is_scrolling {4459 if is_scrolling {
4460 ws.dnd_scroll_gesture_begin();4460 ws.dnd_scroll_gesture_begin();
4461 } else {4461 } else {
4462- ws.view_offset_gesture_end(false, None);4462+ ws.dnd_scroll_gesture_end();
4463 }4463 }
4464 } else {4464 } else {
4465 // Cancel the view offset gesture after workspace switches, moves, etc.4465 // 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> {
3232 true3232 true
3233 }3233 }
3234 3234
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+
3235 pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool {3255 pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool {
3236 if self.interactive_resize.is_some() {3256 if self.interactive_resize.is_some() {
3237 return false;3257 return false;
src/layout/workspace.rsmodified+4 -0
@@ -1650,6 +1650,10 @@ impl<W: LayoutElement> Workspace<W> {
1650 self.scrolling.dnd_scroll_gesture_scroll(delta);1650 self.scrolling.dnd_scroll_gesture_scroll(delta);
1651 }1651 }
1652 1652
1653+ pub fn dnd_scroll_gesture_end(&mut self) {
1654+ self.scrolling.dnd_scroll_gesture_end();
1655+ }
1656+
1653 pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool {1657 pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool {
1654 if self.floating.has_window(&window) {1658 if self.floating.has_window(&window) {
1655 self.floating.interactive_resize_begin(window, edges)1659 self.floating.interactive_resize_begin(window, edges)