aboutsummaryrefslogtreecommitdiff
path: root/src/input/move_grab.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-04-25 09:36:50 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-04-25 02:00:18 -0700
commitaf1fca35bb15b8010cd3a12bbafe71b55d9ecf57 (patch)
tree6283896fd931b9e5244a435cee9a0c227a850c23 /src/input/move_grab.rs
parent9571d149b2cecd3df8ba3f90f0af296e9f69af6e (diff)
downloadniri-af1fca35bb15b8010cd3a12bbafe71b55d9ecf57.tar.gz
niri-af1fca35bb15b8010cd3a12bbafe71b55d9ecf57.tar.bz2
niri-af1fca35bb15b8010cd3a12bbafe71b55d9ecf57.zip
Implement an Overview
Diffstat (limited to 'src/input/move_grab.rs')
-rw-r--r--src/input/move_grab.rs47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/input/move_grab.rs b/src/input/move_grab.rs
index 96362b45..e939696b 100644
--- a/src/input/move_grab.rs
+++ b/src/input/move_grab.rs
@@ -1,10 +1,11 @@
use smithay::backend::input::ButtonState;
use smithay::desktop::Window;
use smithay::input::pointer::{
- AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent,
- GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
- GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
- MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent,
+ AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, GestureHoldBeginEvent,
+ GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
+ GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
+ GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
+ RelativeMotionEvent,
};
use smithay::input::SeatHandler;
use smithay::utils::{IsAlive, Logical, Point};
@@ -15,14 +16,32 @@ pub struct MoveGrab {
start_data: PointerGrabStartData<State>,
last_location: Point<f64, Logical>,
window: Window,
+ gesture: GestureState,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum GestureState {
+ Recognizing,
+ Move,
}
impl MoveGrab {
- pub fn new(start_data: PointerGrabStartData<State>, window: Window) -> Self {
+ pub fn new(
+ start_data: PointerGrabStartData<State>,
+ window: Window,
+ use_threshold: bool,
+ ) -> Self {
+ let gesture = if use_threshold {
+ GestureState::Recognizing
+ } else {
+ GestureState::Move
+ };
+
Self {
last_location: start_data.location,
start_data,
window,
+ gesture,
}
}
@@ -53,6 +72,24 @@ impl PointerGrab<State> for MoveGrab {
let output = output.clone();
let event_delta = event.location - self.last_location;
self.last_location = event.location;
+
+ if self.gesture == GestureState::Recognizing {
+ let c = event.location - self.start_data.location;
+
+ // Check if the gesture moved far enough to decide.
+ if c.x * c.x + c.y * c.y >= 8. * 8. {
+ self.gesture = GestureState::Move;
+
+ data.niri
+ .cursor_manager
+ .set_cursor_image(CursorImageStatus::Named(CursorIcon::Move));
+ }
+ }
+
+ if self.gesture != GestureState::Move {
+ return;
+ }
+
let ongoing = data.niri.layout.interactive_move_update(
&self.window,
event_delta,