forge
Explore
Log in

Don't you dare go Hollow

Use unaccelerated delta for vertical gesture

Browse files at this commit

66c1272420c9fab848ff6ccf68d96a09632bc796Ivan MolodetskikhParent: e0ec6e5
With inertia in place it's ready for this.
src/input.rsmodified+16 -4
@@ -2,6 +2,7 @@ use std::any::Any;
2 use std::collections::HashSet;2 use std::collections::HashSet;
3 use std::time::Duration;3 use std::time::Duration;
4 4
5+use input::event::gesture::GestureEventCoordinates as _;
5 use niri_config::{Action, Binds, Modifiers};6 use niri_config::{Action, Binds, Modifiers};
6 use niri_ipc::LayoutSwitchTarget;7 use niri_ipc::LayoutSwitchTarget;
7 use smithay::backend::input::{8 use smithay::backend::input::{
@@ -40,7 +41,7 @@ pub struct TabletData {
40 }41 }
41 42
42 impl State {43 impl State {
43- pub fn process_input_event<I: InputBackend>(&mut self, event: InputEvent<I>)44+ pub fn process_input_event<I: InputBackend + 'static>(&mut self, event: InputEvent<I>)
44 where45 where
45 I::Device: 'static, // Needed for downcasting.46 I::Device: 'static, // Needed for downcasting.
46 {47 {
@@ -1209,13 +1210,24 @@ impl State {
1209 );1210 );
1210 }1211 }
1211 1212
1212- fn on_gesture_swipe_update<I: InputBackend>(&mut self, event: I::GestureSwipeUpdateEvent)1213+ fn on_gesture_swipe_update<I: InputBackend + 'static>(
1213- where1214+ &mut self,
1215+ event: I::GestureSwipeUpdateEvent,
1216+ ) where
1214 I::Device: 'static,1217 I::Device: 'static,
1215 {1218 {
1216 let mut delta_x = event.delta_x();1219 let mut delta_x = event.delta_x();
1217 let mut delta_y = event.delta_y();1220 let mut delta_y = event.delta_y();
1218 1221
1222+ // FIXME: remove once X is also unaccelerated.
1223+ let delta_y_accel = delta_y;
1224+
1225+ if let Some(libinput_event) =
1226+ (&event as &dyn Any).downcast_ref::<input::event::gesture::GestureSwipeUpdateEvent>()
1227+ {
1228+ delta_y = libinput_event.dy_unaccelerated();
1229+ }
1230+
1219 let device = event.device();1231 let device = event.device();
1220 if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {1232 if let Some(device) = (&device as &dyn Any).downcast_ref::<input::Device>() {
1221 if device.config_scroll_natural_scroll_enabled() {1233 if device.config_scroll_natural_scroll_enabled() {
@@ -1226,7 +1238,7 @@ impl State {
1226 1238
1227 if let Some((cx, cy)) = &mut self.niri.gesture_swipe_3f_cumulative {1239 if let Some((cx, cy)) = &mut self.niri.gesture_swipe_3f_cumulative {
1228 *cx += delta_x;1240 *cx += delta_x;
1229- *cy += delta_y;1241+ *cy += delta_y_accel;
1230 1242
1231 // Check if the gesture moved far enough to decide. Threshold copied from GNOME Shell.1243 // Check if the gesture moved far enough to decide. Threshold copied from GNOME Shell.
1232 let (cx, cy) = (*cx, *cy);1244 let (cx, cy) = (*cx, *cy);