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 {
3636 natural-scroll
3737 // accel-speed 0.2
3838 // accel-profile "flat"
39+ // pinch-sensitivity 1.0
3940 // scroll-factor 1.0
4041 // scroll-factor vertical=1.0 horizontal=-2.0
4142 // scroll-method "two-finger"
@@ -244,6 +245,8 @@ A few settings are common between `touchpad`, `mouse`, `trackpoint`, and `trackb
244245
245246 Settings specific to `touchpad`s:
246247
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.
247250 - `tap`: tap-to-click.
248251 - `dwt`: disable-when-typing.
249252 - `dwtp`: disable-when-trackpointing.
docs/wiki/Configuration:-Window-Rules.mdmodified+18 -0
@@ -58,6 +58,7 @@ window-rule {
5858 default-column-display "tabbed"
5959 default-floating-position x=100 y=200 relative-to="bottom-left"
6060 scroll-factor 0.75
61+ pinch-sensitivity 1.25
6162 on-xdg-activate "focus"
6263
6364 focus-ring {
@@ -758,6 +759,23 @@ window-rule {
758759 }
759760 ```
760761
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+
761779 #### `draw-border-with-background`
762780
763781 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 {
221221 pub middle_emulation: bool,
222222 #[knuffel(child)]
223223 pub scroll_factor: Option<ScrollFactor>,
224+ #[knuffel(child, unwrap(argument))]
225+ pub pinch_sensitivity: Option<FloatOrInt<0, 100>>,
224226 }
225227
226228 #[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
niri-config/src/lib.rsmodified+13 -0
@@ -708,6 +708,7 @@ mod tests {
708708 tap-button-map "left-middle-right"
709709 disabled-on-external-mouse
710710 scroll-factor 0.9
711+ pinch-sensitivity 1.8
711712 }
712713
713714 mouse {
@@ -930,6 +931,8 @@ mod tests {
930931 tab-indicator {
931932 active-color "#f00"
932933 }
934+
935+ pinch-sensitivity 1.2
933936 }
934937
935938 layer-rule {
@@ -1055,6 +1058,11 @@ mod tests {
10551058 vertical: None,
10561059 },
10571060 ),
1061+ pinch_sensitivity: Some(
1062+ FloatOrInt(
1063+ 1.8,
1064+ ),
1065+ ),
10581066 },
10591067 mouse: Mouse {
10601068 off: false,
@@ -1909,6 +1917,11 @@ mod tests {
19091917 },
19101918 ),
19111919 scroll_factor: None,
1920+ pinch_sensitivity: Some(
1921+ FloatOrInt(
1922+ 1.2,
1923+ ),
1924+ ),
19121925 tiled_state: None,
19131926 background_effect: BackgroundEffectRule {
19141927 xray: None,
niri-config/src/window_rule.rsmodified+2 -0
@@ -76,6 +76,8 @@ pub struct WindowRule {
7676 #[knuffel(child, unwrap(argument))]
7777 pub scroll_factor: Option<FloatOrInt<0, 100>>,
7878 #[knuffel(child, unwrap(argument))]
79+ pub pinch_sensitivity: Option<FloatOrInt<0, 100>>,
80+ #[knuffel(child, unwrap(argument))]
7981 pub tiled_state: Option<bool>,
8082 #[knuffel(child, default)]
8183 pub background_effect: BackgroundEffectRule,
resources/default-config.kdlmodified+1 -0
@@ -38,6 +38,7 @@ input {
3838 natural-scroll
3939 // accel-speed 0.2
4040 // accel-profile "flat"
41+ // pinch-sensitivity 1.0
4142 // scroll-method "two-finger"
4243 // disabled-on-external-mouse
4344 }
src/input/mod.rsmodified+18 -1
@@ -4179,12 +4179,29 @@ impl State {
41794179 pointer.frame(self);
41804180 }
41814181
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+
41824199 pointer.gesture_pinch_update(
41834200 self,
41844201 &GesturePinchUpdateEvent {
41854202 time: event.time(),
41864203 delta: event.delta(),
4187- scale: event.scale(),
4204+ scale: event.scale().powf(sensitivity),
41884205 rotation: event.rotation(),
41894206 },
41904207 );
src/window/mod.rsmodified+6 -0
@@ -120,6 +120,9 @@ pub struct ResolvedWindowRules {
120120 /// Multiplier for all scroll events sent to this window.
121121 pub scroll_factor: Option<f64>,
122122
123+ /// Pinch gesture sensitivity for this window.
124+ pub pinch_sensitivity: Option<f64>,
125+
123126 /// Override whether to set the Tiled xdg-toplevel state on the window.
124127 pub tiled_state: Option<bool>,
125128
@@ -306,6 +309,9 @@ impl ResolvedWindowRules {
306309 if let Some(x) = rule.scroll_factor {
307310 resolved.scroll_factor = Some(x.0);
308311 }
312+ if let Some(x) = rule.pinch_sensitivity {
313+ resolved.pinch_sensitivity = Some(x.0);
314+ }
309315 if let Some(x) = rule.tiled_state {
310316 resolved.tiled_state = Some(x);
311317 }