forge
Explore
Log in

Don't you dare go Hollow

Add configurable pinch sensitivity

Browse files at this commit

6bf5b31eff8ea758ae04892eed2b796705f60cf5ESParent: 02fdd8e
  • feat
    • add configurable pinch sensitivity
Show full message
feat: add configurable pinch sensitivity
docs/wiki/Configuration:-Input.mdmodified+3 -0
@@ -36,6 +36,7 @@ input {
36 natural-scroll36 natural-scroll
37 // accel-speed 0.237 // accel-speed 0.2
38 // accel-profile "flat"38 // accel-profile "flat"
39+ // pinch-sensitivity 1.0
39 // scroll-factor 1.040 // scroll-factor 1.0
40 // scroll-factor vertical=1.0 horizontal=-2.041 // scroll-factor vertical=1.0 horizontal=-2.0
41 // scroll-method "two-finger"42 // scroll-method "two-finger"
@@ -244,6 +245,8 @@ A few settings are common between `touchpad`, `mouse`, `trackpoint`, and `trackb
244 245
245 Settings specific to `touchpad`s:246 Settings specific to `touchpad`s:
246 247
248+- `pinch-sensitivity`: <sup>Since: next release</sup> scales the sensitivity of pinch gestures sent to applications.
249+ Values above `1.0` increase sensitivity, while values below `1.0` decrease it.
247 - `tap`: tap-to-click.250 - `tap`: tap-to-click.
248 - `dwt`: disable-when-typing.251 - `dwt`: disable-when-typing.
249 - `dwtp`: disable-when-trackpointing.252 - `dwtp`: disable-when-trackpointing.
docs/wiki/Configuration:-Window-Rules.mdmodified+18 -0
@@ -58,6 +58,7 @@ window-rule {
58 default-column-display "tabbed"58 default-column-display "tabbed"
59 default-floating-position x=100 y=200 relative-to="bottom-left"59 default-floating-position x=100 y=200 relative-to="bottom-left"
60 scroll-factor 0.7560 scroll-factor 0.75
61+ pinch-sensitivity 1.25
61 on-xdg-activate "focus"62 on-xdg-activate "focus"
62 63
63 focus-ring {64 focus-ring {
@@ -758,6 +759,23 @@ window-rule {
758 }759 }
759 ```760 ```
760 761
762+#### `pinch-sensitivity`
763+
764+<sup>Since: next release</sup>
765+
766+Set the sensitivity of pinch gestures sent to a window.
767+
768+This will be multiplied with the pinch sensitivity set for your touchpad in the [input section](./Configuration:-Input.md#pointing-devices).
769+
770+```kdl
771+// Make pinch gestures in Firefox more sensitive.
772+window-rule {
773+ match app-id="firefox$"
774+
775+ pinch-sensitivity 1.25
776+}
777+```
778+
761 #### `draw-border-with-background`779 #### `draw-border-with-background`
762 780
763 Override whether the border and the focus ring draw with a background.781 Override whether the border and the focus ring draw with a background.
niri-config/src/input.rsmodified+2 -0
@@ -221,6 +221,8 @@ pub struct Touchpad {
221 pub middle_emulation: bool,221 pub middle_emulation: bool,
222 #[knuffel(child)]222 #[knuffel(child)]
223 pub scroll_factor: Option<ScrollFactor>,223 pub scroll_factor: Option<ScrollFactor>,
224+ #[knuffel(child, unwrap(argument))]
225+ pub pinch_sensitivity: Option<FloatOrInt<0, 100>>,
224 }226 }
225 227
226 #[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]228 #[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
niri-config/src/lib.rsmodified+13 -0
@@ -708,6 +708,7 @@ mod tests {
708 tap-button-map "left-middle-right"708 tap-button-map "left-middle-right"
709 disabled-on-external-mouse709 disabled-on-external-mouse
710 scroll-factor 0.9710 scroll-factor 0.9
711+ pinch-sensitivity 1.8
711 }712 }
712 713
713 mouse {714 mouse {
@@ -930,6 +931,8 @@ mod tests {
930 tab-indicator {931 tab-indicator {
931 active-color "#f00"932 active-color "#f00"
932 }933 }
934+
935+ pinch-sensitivity 1.2
933 }936 }
934 937
935 layer-rule {938 layer-rule {
@@ -1055,6 +1058,11 @@ mod tests {
1055 vertical: None,1058 vertical: None,
1056 },1059 },
1057 ),1060 ),
1061+ pinch_sensitivity: Some(
1062+ FloatOrInt(
1063+ 1.8,
1064+ ),
1065+ ),
1058 },1066 },
1059 mouse: Mouse {1067 mouse: Mouse {
1060 off: false,1068 off: false,
@@ -1909,6 +1917,11 @@ mod tests {
1909 },1917 },
1910 ),1918 ),
1911 scroll_factor: None,1919 scroll_factor: None,
1920+ pinch_sensitivity: Some(
1921+ FloatOrInt(
1922+ 1.2,
1923+ ),
1924+ ),
1912 tiled_state: None,1925 tiled_state: None,
1913 background_effect: BackgroundEffectRule {1926 background_effect: BackgroundEffectRule {
1914 xray: None,1927 xray: None,
niri-config/src/window_rule.rsmodified+2 -0
@@ -76,6 +76,8 @@ pub struct WindowRule {
76 #[knuffel(child, unwrap(argument))]76 #[knuffel(child, unwrap(argument))]
77 pub scroll_factor: Option<FloatOrInt<0, 100>>,77 pub scroll_factor: Option<FloatOrInt<0, 100>>,
78 #[knuffel(child, unwrap(argument))]78 #[knuffel(child, unwrap(argument))]
79+ pub pinch_sensitivity: Option<FloatOrInt<0, 100>>,
80+ #[knuffel(child, unwrap(argument))]
79 pub tiled_state: Option<bool>,81 pub tiled_state: Option<bool>,
80 #[knuffel(child, default)]82 #[knuffel(child, default)]
81 pub background_effect: BackgroundEffectRule,83 pub background_effect: BackgroundEffectRule,
resources/default-config.kdlmodified+1 -0
@@ -38,6 +38,7 @@ input {
38 natural-scroll38 natural-scroll
39 // accel-speed 0.239 // accel-speed 0.2
40 // accel-profile "flat"40 // accel-profile "flat"
41+ // pinch-sensitivity 1.0
41 // scroll-method "two-finger"42 // scroll-method "two-finger"
42 // disabled-on-external-mouse43 // disabled-on-external-mouse
43 }44 }
src/input/mod.rsmodified+18 -1
@@ -4179,12 +4179,29 @@ impl State {
4179 pointer.frame(self);4179 pointer.frame(self);
4180 }4180 }
4181 4181
4182+ let input_sensitivity = self
4183+ .niri
4184+ .config
4185+ .borrow()
4186+ .input
4187+ .touchpad
4188+ .pinch_sensitivity
4189+ .map(|x| x.0)
4190+ .unwrap_or(1.);
4191+ let window_sensitivity = pointer
4192+ .current_focus()
4193+ .map(|focused| self.niri.find_root_shell_surface(&focused))
4194+ .and_then(|root| self.niri.layout.find_window_and_output(&root).unzip().0)
4195+ .and_then(|window| window.rules().pinch_sensitivity)
4196+ .unwrap_or(1.);
4197+ let sensitivity = input_sensitivity * window_sensitivity;
4198+
4182 pointer.gesture_pinch_update(4199 pointer.gesture_pinch_update(
4183 self,4200 self,
4184 &GesturePinchUpdateEvent {4201 &GesturePinchUpdateEvent {
4185 time: event.time(),4202 time: event.time(),
4186 delta: event.delta(),4203 delta: event.delta(),
4187- scale: event.scale(),4204+ scale: event.scale().powf(sensitivity),
4188 rotation: event.rotation(),4205 rotation: event.rotation(),
4189 },4206 },
4190 );4207 );
src/window/mod.rsmodified+6 -0
@@ -120,6 +120,9 @@ pub struct ResolvedWindowRules {
120 /// Multiplier for all scroll events sent to this window.120 /// Multiplier for all scroll events sent to this window.
121 pub scroll_factor: Option<f64>,121 pub scroll_factor: Option<f64>,
122 122
123+ /// Pinch gesture sensitivity for this window.
124+ pub pinch_sensitivity: Option<f64>,
125+
123 /// Override whether to set the Tiled xdg-toplevel state on the window.126 /// Override whether to set the Tiled xdg-toplevel state on the window.
124 pub tiled_state: Option<bool>,127 pub tiled_state: Option<bool>,
125 128
@@ -306,6 +309,9 @@ impl ResolvedWindowRules {
306 if let Some(x) = rule.scroll_factor {309 if let Some(x) = rule.scroll_factor {
307 resolved.scroll_factor = Some(x.0);310 resolved.scroll_factor = Some(x.0);
308 }311 }
312+ if let Some(x) = rule.pinch_sensitivity {
313+ resolved.pinch_sensitivity = Some(x.0);
314+ }
309 if let Some(x) = rule.tiled_state {315 if let Some(x) = rule.tiled_state {
310 resolved.tiled_state = Some(x);316 resolved.tiled_state = Some(x);
311 }317 }