diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-05 12:39:20 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-05 12:39:20 +0400 |
| commit | 2e4a2e13b175fcbb0fef58214f7de5b60775214a (patch) | |
| tree | a3e71dbe9986919a012e003be0d563d109e68505 /niri-ipc/src | |
| parent | df0ee996ee0c70d4fb0fb853535e1563da3c0d09 (diff) | |
| download | niri-2e4a2e13b175fcbb0fef58214f7de5b60775214a.tar.gz niri-2e4a2e13b175fcbb0fef58214f7de5b60775214a.tar.bz2 niri-2e4a2e13b175fcbb0fef58214f7de5b60775214a.zip | |
Make missing scale = automatic selection
That was the intention, but I missed it before.
Diffstat (limited to 'niri-ipc/src')
| -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)) + } +} |
