diff --git a/docs/wiki/Configuration:-Input.md b/docs/wiki/Configuration:-Input.md index 60a3808d..a0f216e1 100644 --- a/docs/wiki/Configuration:-Input.md +++ b/docs/wiki/Configuration:-Input.md @@ -89,6 +89,7 @@ input { tablet { // off map-to-output "eDP-1" + // map-to-focused-output // left-handed // calibration-matrix 1.0 0.0 0.0 0.0 1.0 0.0 } @@ -281,6 +282,10 @@ Valid output names are the same as the ones used for output configuration. Since: 0.1.7 When a tablet is not mapped to any output, it will map to the union of all connected outputs, without aspect ratio correction. +Setting specific to `tablet`: + +- `map-to-focused-output`: Since: next release will map the tablet to the focused output, takes precedence over `map-to-output`. + ### General Settings These settings are not specific to a particular input device. diff --git a/niri-config/src/input.rs b/niri-config/src/input.rs index 12af80ae..dceb5c6c 100644 --- a/niri-config/src/input.rs +++ b/niri-config/src/input.rs @@ -364,6 +364,8 @@ pub struct Tablet { #[knuffel(child, unwrap(argument))] pub map_to_output: Option, #[knuffel(child)] + pub map_to_focused_output: bool, + #[knuffel(child)] pub left_handed: bool, } diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index c0a9bd5b..b9c6bd65 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -705,6 +705,7 @@ mod tests { tablet { map-to-output "eDP-1" + map-to-focused-output calibration-matrix 1.0 2.0 3.0 \ 4.0 5.0 6.0 } @@ -1097,6 +1098,7 @@ mod tests { map_to_output: Some( "eDP-1", ), + map_to_focused_output: true, left_handed: false, }, touch: Touch { diff --git a/src/niri.rs b/src/niri.rs index d9b28143..9ee651be 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -3582,8 +3582,12 @@ impl Niri { pub fn output_for_tablet(&self) -> Option<&Output> { let config = self.config.borrow(); - let map_to_output = config.input.tablet.map_to_output.as_ref(); - map_to_output.and_then(|name| self.output_by_name_match(name)) + if config.input.tablet.map_to_focused_output { + self.layout.active_output() + } else { + let map_to_output = config.input.tablet.map_to_output.as_ref(); + map_to_output.and_then(|name| self.output_by_name_match(name)) + } } pub fn output_for_touch(&self) -> Option<&Output> {