mirror of
https://github.com/YaLTeR/niri.git
synced 2025-10-06 00:23:14 +02:00
Don't snap after DnD scroll if view position didn't change
Otherwise, any DnD breaks temporarily centered columns.
This commit is contained in:
@@ -1105,7 +1105,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
|
||||
// Unlock the view on the workspaces.
|
||||
for ws in self.workspaces_mut() {
|
||||
ws.view_offset_gesture_end(false, None);
|
||||
ws.dnd_scroll_gesture_end();
|
||||
}
|
||||
|
||||
return Some(RemovedTile {
|
||||
@@ -3853,7 +3853,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
let moved_tile_was_active =
|
||||
ws.active_window().is_some_and(|win| *win.id() == window_id);
|
||||
|
||||
ws.view_offset_gesture_end(false, None);
|
||||
ws.dnd_scroll_gesture_end();
|
||||
|
||||
if moved_tile_was_active {
|
||||
ws.activate_window(&window_id);
|
||||
@@ -3876,7 +3876,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
// Unlock the view on the workspaces.
|
||||
if !move_.is_floating {
|
||||
for ws in self.workspaces_mut() {
|
||||
ws.view_offset_gesture_end(false, None);
|
||||
ws.dnd_scroll_gesture_end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4050,7 +4050,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
self.dnd = None;
|
||||
|
||||
for ws in self.workspaces_mut() {
|
||||
ws.view_offset_gesture_end(false, None);
|
||||
ws.dnd_scroll_gesture_end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4459,7 +4459,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
if is_scrolling {
|
||||
ws.dnd_scroll_gesture_begin();
|
||||
} else {
|
||||
ws.view_offset_gesture_end(false, None);
|
||||
ws.dnd_scroll_gesture_end();
|
||||
}
|
||||
} else {
|
||||
// Cancel the view offset gesture after workspace switches, moves, etc.
|
||||
|
@@ -3232,6 +3232,26 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn dnd_scroll_gesture_end(&mut self) {
|
||||
let ViewOffset::Gesture(gesture) = &mut self.view_offset else {
|
||||
return;
|
||||
};
|
||||
|
||||
if gesture.dnd_last_event_time.is_some() && gesture.tracker.pos() == 0. {
|
||||
// DnD didn't scroll anything, so preserve the current view position (rather than
|
||||
// snapping the window).
|
||||
self.view_offset = ViewOffset::Static(gesture.delta_from_tracker);
|
||||
|
||||
if !self.columns.is_empty() {
|
||||
// Just in case, make sure the active window remains on screen.
|
||||
self.animate_view_offset_to_column(None, self.active_column_idx, None);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
self.view_offset_gesture_end(false, None);
|
||||
}
|
||||
|
||||
pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool {
|
||||
if self.interactive_resize.is_some() {
|
||||
return false;
|
||||
|
@@ -1650,6 +1650,10 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
self.scrolling.dnd_scroll_gesture_scroll(delta);
|
||||
}
|
||||
|
||||
pub fn dnd_scroll_gesture_end(&mut self) {
|
||||
self.scrolling.dnd_scroll_gesture_end();
|
||||
}
|
||||
|
||||
pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool {
|
||||
if self.floating.has_window(&window) {
|
||||
self.floating.interactive_resize_begin(window, edges)
|
||||
|
Reference in New Issue
Block a user