mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Remove cancellation from swipe gestures
It only worked for workspace switch, and even there it was more confusing than helpful.
This commit is contained in:
+2
-8
@@ -2886,19 +2886,13 @@ impl State {
|
||||
self.niri.gesture_swipe_3f_cumulative = None;
|
||||
|
||||
let mut handled = false;
|
||||
let res = self
|
||||
.niri
|
||||
.layout
|
||||
.workspace_switch_gesture_end(event.cancelled(), Some(true));
|
||||
let res = self.niri.layout.workspace_switch_gesture_end(Some(true));
|
||||
if let Some(output) = res {
|
||||
self.niri.queue_redraw(&output);
|
||||
handled = true;
|
||||
}
|
||||
|
||||
let res = self
|
||||
.niri
|
||||
.layout
|
||||
.view_offset_gesture_end(event.cancelled(), Some(true));
|
||||
let res = self.niri.layout.view_offset_gesture_end(Some(true));
|
||||
if let Some(output) = res {
|
||||
self.niri.queue_redraw(&output);
|
||||
handled = true;
|
||||
|
||||
@@ -40,10 +40,8 @@ impl SpatialMovementGrab {
|
||||
let layout = &mut state.niri.layout;
|
||||
let res = match self.gesture {
|
||||
GestureState::Recognizing => None,
|
||||
GestureState::ViewOffset => layout.view_offset_gesture_end(false, Some(false)),
|
||||
GestureState::WorkspaceSwitch => {
|
||||
layout.workspace_switch_gesture_end(false, Some(false))
|
||||
}
|
||||
GestureState::ViewOffset => layout.view_offset_gesture_end(Some(false)),
|
||||
GestureState::WorkspaceSwitch => layout.workspace_switch_gesture_end(Some(false)),
|
||||
};
|
||||
|
||||
if let Some(output) = res {
|
||||
|
||||
+8
-16
@@ -3534,7 +3534,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
for monitor in monitors {
|
||||
// Cancel the gesture on other outputs.
|
||||
if &monitor.output != output {
|
||||
monitor.workspace_switch_gesture_end(true, None);
|
||||
monitor.workspace_switch_gesture_end(None);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3568,18 +3568,14 @@ impl<W: LayoutElement> Layout<W> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn workspace_switch_gesture_end(
|
||||
&mut self,
|
||||
cancelled: bool,
|
||||
is_touchpad: Option<bool>,
|
||||
) -> Option<Output> {
|
||||
pub fn workspace_switch_gesture_end(&mut self, is_touchpad: Option<bool>) -> Option<Output> {
|
||||
let monitors = match &mut self.monitor_set {
|
||||
MonitorSet::Normal { monitors, .. } => monitors,
|
||||
MonitorSet::NoOutputs { .. } => return None,
|
||||
};
|
||||
|
||||
for monitor in monitors {
|
||||
if monitor.workspace_switch_gesture_end(cancelled, is_touchpad) {
|
||||
if monitor.workspace_switch_gesture_end(is_touchpad) {
|
||||
return Some(monitor.output.clone());
|
||||
}
|
||||
}
|
||||
@@ -3597,7 +3593,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
for (idx, ws) in monitor.workspaces.iter_mut().enumerate() {
|
||||
// Cancel the gesture on other workspaces.
|
||||
if &monitor.output != output || idx != monitor.active_workspace_idx {
|
||||
ws.view_offset_gesture_end(true, None);
|
||||
ws.view_offset_gesture_end(None);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3634,11 +3630,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn view_offset_gesture_end(
|
||||
&mut self,
|
||||
cancelled: bool,
|
||||
is_touchpad: Option<bool>,
|
||||
) -> Option<Output> {
|
||||
pub fn view_offset_gesture_end(&mut self, is_touchpad: Option<bool>) -> Option<Output> {
|
||||
let monitors = match &mut self.monitor_set {
|
||||
MonitorSet::Normal { monitors, .. } => monitors,
|
||||
MonitorSet::NoOutputs { .. } => return None,
|
||||
@@ -3646,7 +3638,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
|
||||
for monitor in monitors {
|
||||
for ws in &mut monitor.workspaces {
|
||||
if ws.view_offset_gesture_end(cancelled, is_touchpad) {
|
||||
if ws.view_offset_gesture_end(is_touchpad) {
|
||||
return Some(monitor.output.clone());
|
||||
}
|
||||
}
|
||||
@@ -4560,7 +4552,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
} else {
|
||||
// Cancel the view offset gesture after workspace switches, moves, etc.
|
||||
if ws_idx != mon.active_workspace_idx {
|
||||
ws.view_offset_gesture_end(false, None);
|
||||
ws.view_offset_gesture_end(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4569,7 +4561,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
MonitorSet::NoOutputs { workspaces, .. } => {
|
||||
for ws in workspaces {
|
||||
ws.refresh(false);
|
||||
ws.view_offset_gesture_end(false, None);
|
||||
ws.view_offset_gesture_end(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-11
@@ -1026,11 +1026,7 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
Some(true)
|
||||
}
|
||||
|
||||
pub fn workspace_switch_gesture_end(
|
||||
&mut self,
|
||||
cancelled: bool,
|
||||
is_touchpad: Option<bool>,
|
||||
) -> bool {
|
||||
pub fn workspace_switch_gesture_end(&mut self, is_touchpad: Option<bool>) -> bool {
|
||||
let Some(WorkspaceSwitch::Gesture(gesture)) = &mut self.workspace_switch else {
|
||||
return false;
|
||||
};
|
||||
@@ -1039,12 +1035,6 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
return false;
|
||||
}
|
||||
|
||||
if cancelled {
|
||||
self.workspace_switch = None;
|
||||
self.clean_up_workspaces();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Take into account any idle time between the last event and now.
|
||||
let now = self.clock.now_unadjusted();
|
||||
gesture.tracker.push(0., now);
|
||||
|
||||
@@ -2989,7 +2989,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
gesture.current_view_offset = clamped_offset;
|
||||
}
|
||||
|
||||
pub fn view_offset_gesture_end(&mut self, _cancelled: bool, is_touchpad: Option<bool>) -> bool {
|
||||
pub fn view_offset_gesture_end(&mut self, is_touchpad: Option<bool>) -> bool {
|
||||
let ViewOffset::Gesture(gesture) = &mut self.view_offset else {
|
||||
return false;
|
||||
};
|
||||
@@ -3279,7 +3279,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
return;
|
||||
}
|
||||
|
||||
self.view_offset_gesture_end(false, None);
|
||||
self.view_offset_gesture_end(None);
|
||||
}
|
||||
|
||||
pub fn interactive_resize_begin(&mut self, window: W::Id, edges: ResizeEdge) -> bool {
|
||||
|
||||
+3
-8
@@ -599,7 +599,6 @@ enum Op {
|
||||
is_touchpad: bool,
|
||||
},
|
||||
WorkspaceSwitchGestureEnd {
|
||||
cancelled: bool,
|
||||
is_touchpad: Option<bool>,
|
||||
},
|
||||
InteractiveMoveBegin {
|
||||
@@ -1362,8 +1361,7 @@ impl Op {
|
||||
layout.view_offset_gesture_update(delta, timestamp, is_touchpad);
|
||||
}
|
||||
Op::ViewOffsetGestureEnd { is_touchpad } => {
|
||||
// We don't handle cancels in this gesture.
|
||||
layout.view_offset_gesture_end(false, is_touchpad);
|
||||
layout.view_offset_gesture_end(is_touchpad);
|
||||
}
|
||||
Op::WorkspaceSwitchGestureBegin {
|
||||
output_idx: id,
|
||||
@@ -1383,11 +1381,8 @@ impl Op {
|
||||
} => {
|
||||
layout.workspace_switch_gesture_update(delta, timestamp, is_touchpad);
|
||||
}
|
||||
Op::WorkspaceSwitchGestureEnd {
|
||||
cancelled,
|
||||
is_touchpad,
|
||||
} => {
|
||||
layout.workspace_switch_gesture_end(cancelled, is_touchpad);
|
||||
Op::WorkspaceSwitchGestureEnd { is_touchpad } => {
|
||||
layout.workspace_switch_gesture_end(is_touchpad);
|
||||
}
|
||||
Op::InteractiveMoveBegin {
|
||||
window,
|
||||
|
||||
@@ -1619,9 +1619,8 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
.view_offset_gesture_update(delta_x, timestamp, is_touchpad)
|
||||
}
|
||||
|
||||
pub fn view_offset_gesture_end(&mut self, cancelled: bool, is_touchpad: Option<bool>) -> bool {
|
||||
self.scrolling
|
||||
.view_offset_gesture_end(cancelled, is_touchpad)
|
||||
pub fn view_offset_gesture_end(&mut self, is_touchpad: Option<bool>) -> bool {
|
||||
self.scrolling.view_offset_gesture_end(is_touchpad)
|
||||
}
|
||||
|
||||
pub fn dnd_scroll_gesture_begin(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user