Add tablet option map-to-focused-output
Browse files at this commit9e5716a9dbf7dbf9622a95a5bd23a898867759c6Parent: f4ebbc84 changed files +15 -2
- docs/wiki/Configuration:-Input.md +5 -0
- niri-config/src/input.rs +2 -0
- niri-config/src/lib.rs +2 -0
- src/niri.rs +6 -2
docs/wiki/Configuration:-Input.mdmodified+5 -0
| @@ -89,6 +89,7 @@ input { | |||
| 89 | tablet { | 89 | tablet { |
| 90 | // off | 90 | // off |
| 91 | map-to-output "eDP-1" | 91 | map-to-output "eDP-1" |
| 92 | + // map-to-focused-output | ||
| 92 | // left-handed | 93 | // left-handed |
| 93 | // calibration-matrix 1.0 0.0 0.0 0.0 1.0 0.0 | 94 | // calibration-matrix 1.0 0.0 0.0 0.0 1.0 0.0 |
| 94 | } | 95 | } |
| @@ -281,6 +282,10 @@ Valid output names are the same as the ones used for output configuration. | |||
| 281 | 282 | ||
| 282 | <sup>Since: 0.1.7</sup> When a tablet is not mapped to any output, it will map to the union of all connected outputs, without aspect ratio correction. | 283 | <sup>Since: 0.1.7</sup> When a tablet is not mapped to any output, it will map to the union of all connected outputs, without aspect ratio correction. |
| 283 | 284 | ||
| 285 | +Setting specific to `tablet`: | ||
| 286 | + | ||
| 287 | +- `map-to-focused-output`: <sup>Since: next release</sup> will map the tablet to the focused output, takes precedence over `map-to-output`. | ||
| 288 | + | ||
| 284 | ### General Settings | 289 | ### General Settings |
| 285 | 290 | ||
| 286 | These settings are not specific to a particular input device. | 291 | These settings are not specific to a particular input device. |
niri-config/src/input.rsmodified+2 -0
| @@ -364,6 +364,8 @@ pub struct Tablet { | |||
| 364 | #[knuffel(child, unwrap(argument))] | 364 | #[knuffel(child, unwrap(argument))] |
| 365 | pub map_to_output: Option<String>, | 365 | pub map_to_output: Option<String>, |
| 366 | #[knuffel(child)] | 366 | #[knuffel(child)] |
| 367 | + pub map_to_focused_output: bool, | ||
| 368 | + #[knuffel(child)] | ||
| 367 | pub left_handed: bool, | 369 | pub left_handed: bool, |
| 368 | } | 370 | } |
| 369 | 371 | ||
niri-config/src/lib.rsmodified+2 -0
| @@ -705,6 +705,7 @@ mod tests { | |||
| 705 | 705 | ||
| 706 | tablet { | 706 | tablet { |
| 707 | map-to-output "eDP-1" | 707 | map-to-output "eDP-1" |
| 708 | + map-to-focused-output | ||
| 708 | calibration-matrix 1.0 2.0 3.0 \ | 709 | calibration-matrix 1.0 2.0 3.0 \ |
| 709 | 4.0 5.0 6.0 | 710 | 4.0 5.0 6.0 |
| 710 | } | 711 | } |
| @@ -1097,6 +1098,7 @@ mod tests { | |||
| 1097 | map_to_output: Some( | 1098 | map_to_output: Some( |
| 1098 | "eDP-1", | 1099 | "eDP-1", |
| 1099 | ), | 1100 | ), |
| 1101 | + map_to_focused_output: true, | ||
| 1100 | left_handed: false, | 1102 | left_handed: false, |
| 1101 | }, | 1103 | }, |
| 1102 | touch: Touch { | 1104 | touch: Touch { |
src/niri.rsmodified+6 -2
| @@ -3582,8 +3582,12 @@ impl Niri { | |||
| 3582 | 3582 | ||
| 3583 | pub fn output_for_tablet(&self) -> Option<&Output> { | 3583 | pub fn output_for_tablet(&self) -> Option<&Output> { |
| 3584 | let config = self.config.borrow(); | 3584 | let config = self.config.borrow(); |
| 3585 | - let map_to_output = config.input.tablet.map_to_output.as_ref(); | 3585 | + if config.input.tablet.map_to_focused_output { |
| 3586 | - map_to_output.and_then(|name| self.output_by_name_match(name)) | 3586 | + self.layout.active_output() |
| 3587 | + } else { | ||
| 3588 | + let map_to_output = config.input.tablet.map_to_output.as_ref(); | ||
| 3589 | + map_to_output.and_then(|name| self.output_by_name_match(name)) | ||
| 3590 | + } | ||
| 3587 | } | 3591 | } |
| 3588 | 3592 | ||
| 3589 | pub fn output_for_touch(&self) -> Option<&Output> { | 3593 | pub fn output_for_touch(&self) -> Option<&Output> { |