diff options
Diffstat (limited to 'niri-ipc')
| -rw-r--r-- | niri-ipc/src/lib.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/niri-ipc/src/lib.rs b/niri-ipc/src/lib.rs index c721ac9b..db2d7a0f 100644 --- a/niri-ipc/src/lib.rs +++ b/niri-ipc/src/lib.rs @@ -278,9 +278,9 @@ pub enum OutputAction { }, /// Set the output scale. Scale { - /// Scale factor to set. + /// Scale factor to set, or "auto" for automatic selection. #[cfg_attr(feature = "clap", arg())] - scale: f64, + scale: ScaleToSet, }, /// Set the output transform. Transform { @@ -329,6 +329,15 @@ pub struct ConfiguredMode { pub refresh: Option<f64>, } +/// Output scale to set. +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)] +pub enum ScaleToSet { + /// Niri will pick the scale automatically. + Automatic, + /// Specific scale. + Specific(f64), +} + /// Output position to set. #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)] #[cfg_attr(feature = "clap", derive(clap::Subcommand))] @@ -560,3 +569,16 @@ impl FromStr for ConfiguredMode { }) } } + +impl FromStr for ScaleToSet { + type Err = &'static str; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + if s.eq_ignore_ascii_case("auto") { + return Ok(Self::Automatic); + } + + let scale = s.parse().map_err(|_| "error parsing scale")?; + Ok(Self::Specific(scale)) + } +} |
