From 929eaf0d694a9f0e8aa9b436004f0d054c9e2919 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 24 Apr 2025 21:24:39 +0300 Subject: Pass target workspace to view offset grab --- src/layout/mod.rs | 11 +++++++++-- src/layout/tests.rs | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src/layout') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index ceed2f60..9347fc73 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -3601,7 +3601,12 @@ impl Layout { None } - pub fn view_offset_gesture_begin(&mut self, output: &Output, is_touchpad: bool) { + pub fn view_offset_gesture_begin( + &mut self, + output: &Output, + workspace_idx: Option, + is_touchpad: bool, + ) { let monitors = match &mut self.monitor_set { MonitorSet::Normal { monitors, .. } => monitors, MonitorSet::NoOutputs { .. } => unreachable!(), @@ -3610,7 +3615,9 @@ impl Layout { for monitor in monitors { for (idx, ws) in monitor.workspaces.iter_mut().enumerate() { // Cancel the gesture on other workspaces. - if &monitor.output != output || idx != monitor.active_workspace_idx { + if &monitor.output != output + || idx != workspace_idx.unwrap_or(monitor.active_workspace_idx) + { ws.view_offset_gesture_end(None); continue; } diff --git a/src/layout/tests.rs b/src/layout/tests.rs index a49552a8..af8ba284 100644 --- a/src/layout/tests.rs +++ b/src/layout/tests.rs @@ -576,6 +576,8 @@ enum Op { ViewOffsetGestureBegin { #[proptest(strategy = "1..=5usize")] output_idx: usize, + #[proptest(strategy = "proptest::option::of(0..=4usize)")] + workspace_idx: Option, is_touchpad: bool, }, ViewOffsetGestureUpdate { @@ -1344,6 +1346,7 @@ impl Op { } Op::ViewOffsetGestureBegin { output_idx: id, + workspace_idx, is_touchpad: normalize, } => { let name = format!("output{id}"); @@ -1351,7 +1354,7 @@ impl Op { return; }; - layout.view_offset_gesture_begin(&output, normalize); + layout.view_offset_gesture_begin(&output, workspace_idx, normalize); } Op::ViewOffsetGestureUpdate { delta, @@ -2260,6 +2263,7 @@ fn unfullscreen_view_offset_not_reset_on_gesture() { Op::FullscreenWindow(1), Op::ViewOffsetGestureBegin { output_idx: 1, + workspace_idx: None, is_touchpad: true, }, Op::ViewOffsetGestureEnd { -- cgit