aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-03-02 15:01:46 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-03-02 15:41:56 +0400
commit66c1272420c9fab848ff6ccf68d96a09632bc796 (patch)
treeca2daeaf711f411cdbd63e0ea9d2096b5ec8cc74 /src/input.rs
parente0ec6e5b11bc222c252157beb064104f4c60dfbe (diff)
downloadniri-66c1272420c9fab848ff6ccf68d96a09632bc796.tar.gz
niri-66c1272420c9fab848ff6ccf68d96a09632bc796.tar.bz2
niri-66c1272420c9fab848ff6ccf68d96a09632bc796.zip
Use unaccelerated delta for vertical gesture
With inertia in place it's ready for this.
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/input.rs b/src/input.rs
index 232cd77f..0b930b20 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -2,6 +2,7 @@ use std::any::Any;
use std::collections::HashSet;
use std::time::Duration;
+use input::event::gesture::GestureEventCoordinates as _;
use niri_config::{Action, Binds, Modifiers};
use niri_ipc::LayoutSwitchTarget;
use smithay::backend::input::{
@@ -40,7 +41,7 @@ pub struct TabletData {
}
impl State {
- pub fn process_input_event<I: InputBackend>(&mut self, event: InputEvent<I>)
+ pub fn process_input_event<I: InputBackend + 'static>(&mut self, event: InputEvent<I>)
where
I::Device: 'static, // Needed for downcasting.
{
@@ -1209,13 +1210,24 @@ impl State {
);
}
- fn on_gesture_swipe_update<I: InputBackend>(&mut self, event: I::GestureSwipeUpdateEvent)
- where
+ fn on_gesture_swipe_update<I: InputBackend + 'static>(
+ &mut self,
+ event: I::GestureSwipeUpdateEvent,
+ ) where
I::Device: 'static,
{
let mut delta_x = event.delta_x();
let mut delta_y = event.delta_y();
+ // FIXME: remove once X is also unaccelerated.
+ let delta_y_accel = delta_y;
+
+ if let Some(libinput_event) =
+ (&event as &dyn Any).downcast_ref::<input::event::gesture::GestureSwipeUpdateEvent>()
+ {
+ delta_y = libinput_event.dy_unaccelerated();
+ }
+
let device = event.device();
if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {
if device.config_scroll_natural_scroll_enabled() {
@@ -1226,7 +1238,7 @@ impl State {
if let Some((cx, cy)) = &mut self.niri.gesture_swipe_3f_cumulative {
*cx += delta_x;
- *cy += delta_y;
+ *cy += delta_y_accel;
// Check if the gesture moved far enough to decide. Threshold copied from GNOME Shell.
let (cx, cy) = (*cx, *cy);