Don't snap after DnD scroll if view position didn't change
Browse files at this commitdca187de37164df2584f7388cd0bb6429337a580Parent: fe660a23 changed files +29 -5
- src/layout/mod.rs +5 -5
- src/layout/scrolling.rs +20 -0
- src/layout/workspace.rs +4 -0
src/layout/mod.rsmodified+5 -5
| @@ -1105,7 +1105,7 @@ impl<W: LayoutElement> Layout<W> { | ||
| 1105 | 1105 | |
| 1106 | 1106 | // Unlock the view on the workspaces. |
| 1107 | 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 | 1111 | return Some(RemovedTile { |
| @@ -3853,7 +3853,7 @@ impl<W: LayoutElement> Layout<W> { | ||
| 3853 | 3853 | let moved_tile_was_active = |
| 3854 | 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 | 3858 | if moved_tile_was_active { |
| 3859 | 3859 | ws.activate_window(&window_id); |
| @@ -3876,7 +3876,7 @@ impl<W: LayoutElement> Layout<W> { | ||
| 3876 | 3876 | // Unlock the view on the workspaces. |
| 3877 | 3877 | if !move_.is_floating { |
| 3878 | 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 | 4050 | self.dnd = None; |
| 4051 | 4051 | |
| 4052 | 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 | 4459 | if is_scrolling { |
| 4460 | 4460 | ws.dnd_scroll_gesture_begin(); |
| 4461 | 4461 | } else { |
| 4462 | - ws.view_offset_gesture_end(false, None); | |
| 4462 | + ws.dnd_scroll_gesture_end(); | |
| 4463 | 4463 | } |
| 4464 | 4464 | } else { |
| 4465 | 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 | 3232 | 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 | 3255 | pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool { |
| 3236 | 3256 | if self.interactive_resize.is_some() { |
| 3237 | 3257 | return false; |
src/layout/workspace.rsmodified+4 -0
| @@ -1650,6 +1650,10 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 1650 | 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 | 1657 | pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool { |
| 1654 | 1658 | if self.floating.has_window(&window) { |
| 1655 | 1659 | self.floating.interactive_resize_begin(window, edges) |