Add configurable pinch sensitivity
Browse files at this commit6bf5b31eff8ea758ae04892eed2b796705f60cf5Parent: 02fdd8e- feat
- add configurable pinch sensitivity
8 changed files +63 -1
- docs/wiki/Configuration:-Input.md +3 -0
- docs/wiki/Configuration:-Window-Rules.md +18 -0
- niri-config/src/input.rs +2 -0
- niri-config/src/lib.rs +13 -0
- niri-config/src/window_rule.rs +2 -0
- resources/default-config.kdl +1 -0
- src/input/mod.rs +18 -1
- src/window/mod.rs +6 -0
docs/wiki/Configuration:-Input.mdmodified+3 -0
| @@ -36,6 +36,7 @@ input { | ||
| 36 | 36 | natural-scroll |
| 37 | 37 | // accel-speed 0.2 |
| 38 | 38 | // accel-profile "flat" |
| 39 | + // pinch-sensitivity 1.0 | |
| 39 | 40 | // scroll-factor 1.0 |
| 40 | 41 | // scroll-factor vertical=1.0 horizontal=-2.0 |
| 41 | 42 | // scroll-method "two-finger" |
| @@ -244,6 +245,8 @@ A few settings are common between `touchpad`, `mouse`, `trackpoint`, and `trackb | ||
| 244 | 245 | |
| 245 | 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 | 250 | - `tap`: tap-to-click. |
| 248 | 251 | - `dwt`: disable-when-typing. |
| 249 | 252 | - `dwtp`: disable-when-trackpointing. |
docs/wiki/Configuration:-Window-Rules.mdmodified+18 -0
| @@ -58,6 +58,7 @@ window-rule { | ||
| 58 | 58 | default-column-display "tabbed" |
| 59 | 59 | default-floating-position x=100 y=200 relative-to="bottom-left" |
| 60 | 60 | scroll-factor 0.75 |
| 61 | + pinch-sensitivity 1.25 | |
| 61 | 62 | on-xdg-activate "focus" |
| 62 | 63 | |
| 63 | 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 | 779 | #### `draw-border-with-background` |
| 762 | 780 | |
| 763 | 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 | 221 | pub middle_emulation: bool, |
| 222 | 222 | #[knuffel(child)] |
| 223 | 223 | pub scroll_factor: Option<ScrollFactor>, |
| 224 | + #[knuffel(child, unwrap(argument))] | |
| 225 | + pub pinch_sensitivity: Option<FloatOrInt<0, 100>>, | |
| 224 | 226 | } |
| 225 | 227 | |
| 226 | 228 | #[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)] |
niri-config/src/lib.rsmodified+13 -0
| @@ -708,6 +708,7 @@ mod tests { | ||
| 708 | 708 | tap-button-map "left-middle-right" |
| 709 | 709 | disabled-on-external-mouse |
| 710 | 710 | scroll-factor 0.9 |
| 711 | + pinch-sensitivity 1.8 | |
| 711 | 712 | } |
| 712 | 713 | |
| 713 | 714 | mouse { |
| @@ -930,6 +931,8 @@ mod tests { | ||
| 930 | 931 | tab-indicator { |
| 931 | 932 | active-color "#f00" |
| 932 | 933 | } |
| 934 | + | |
| 935 | + pinch-sensitivity 1.2 | |
| 933 | 936 | } |
| 934 | 937 | |
| 935 | 938 | layer-rule { |
| @@ -1055,6 +1058,11 @@ mod tests { | ||
| 1055 | 1058 | vertical: None, |
| 1056 | 1059 | }, |
| 1057 | 1060 | ), |
| 1061 | + pinch_sensitivity: Some( | |
| 1062 | + FloatOrInt( | |
| 1063 | + 1.8, | |
| 1064 | + ), | |
| 1065 | + ), | |
| 1058 | 1066 | }, |
| 1059 | 1067 | mouse: Mouse { |
| 1060 | 1068 | off: false, |
| @@ -1909,6 +1917,11 @@ mod tests { | ||
| 1909 | 1917 | }, |
| 1910 | 1918 | ), |
| 1911 | 1919 | scroll_factor: None, |
| 1920 | + pinch_sensitivity: Some( | |
| 1921 | + FloatOrInt( | |
| 1922 | + 1.2, | |
| 1923 | + ), | |
| 1924 | + ), | |
| 1912 | 1925 | tiled_state: None, |
| 1913 | 1926 | background_effect: BackgroundEffectRule { |
| 1914 | 1927 | xray: None, |
niri-config/src/window_rule.rsmodified+2 -0
| @@ -76,6 +76,8 @@ pub struct WindowRule { | ||
| 76 | 76 | #[knuffel(child, unwrap(argument))] |
| 77 | 77 | pub scroll_factor: Option<FloatOrInt<0, 100>>, |
| 78 | 78 | #[knuffel(child, unwrap(argument))] |
| 79 | + pub pinch_sensitivity: Option<FloatOrInt<0, 100>>, | |
| 80 | + #[knuffel(child, unwrap(argument))] | |
| 79 | 81 | pub tiled_state: Option<bool>, |
| 80 | 82 | #[knuffel(child, default)] |
| 81 | 83 | pub background_effect: BackgroundEffectRule, |
resources/default-config.kdlmodified+1 -0
| @@ -38,6 +38,7 @@ input { | ||
| 38 | 38 | natural-scroll |
| 39 | 39 | // accel-speed 0.2 |
| 40 | 40 | // accel-profile "flat" |
| 41 | + // pinch-sensitivity 1.0 | |
| 41 | 42 | // scroll-method "two-finger" |
| 42 | 43 | // disabled-on-external-mouse |
| 43 | 44 | } |
src/input/mod.rsmodified+18 -1
| @@ -4179,12 +4179,29 @@ impl State { | ||
| 4179 | 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 | 4199 | pointer.gesture_pinch_update( |
| 4183 | 4200 | self, |
| 4184 | 4201 | &GesturePinchUpdateEvent { |
| 4185 | 4202 | time: event.time(), |
| 4186 | 4203 | delta: event.delta(), |
| 4187 | - scale: event.scale(), | |
| 4204 | + scale: event.scale().powf(sensitivity), | |
| 4188 | 4205 | rotation: event.rotation(), |
| 4189 | 4206 | }, |
| 4190 | 4207 | ); |
src/window/mod.rsmodified+6 -0
| @@ -120,6 +120,9 @@ pub struct ResolvedWindowRules { | ||
| 120 | 120 | /// Multiplier for all scroll events sent to this window. |
| 121 | 121 | pub scroll_factor: Option<f64>, |
| 122 | 122 | |
| 123 | + /// Pinch gesture sensitivity for this window. | |
| 124 | + pub pinch_sensitivity: Option<f64>, | |
| 125 | + | |
| 123 | 126 | /// Override whether to set the Tiled xdg-toplevel state on the window. |
| 124 | 127 | pub tiled_state: Option<bool>, |
| 125 | 128 | |
| @@ -306,6 +309,9 @@ impl ResolvedWindowRules { | ||
| 306 | 309 | if let Some(x) = rule.scroll_factor { |
| 307 | 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 | 315 | if let Some(x) = rule.tiled_state { |
| 310 | 316 | resolved.tiled_state = Some(x); |
| 311 | 317 | } |