aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--niri-config/src/lib.rs6
-rw-r--r--resources/default-config.kdl2
-rw-r--r--src/niri.rs21
-rw-r--r--wiki/Configuration:-Outputs.md4
4 files changed, 21 insertions, 12 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index a9285fad..04dda809 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -298,7 +298,7 @@ pub struct Output {
#[knuffel(argument)]
pub name: String,
#[knuffel(child, unwrap(argument))]
- pub scale: Option<f64>,
+ pub scale: Option<FloatOrInt<0, 10>>,
#[knuffel(child, unwrap(argument, str), default = Transform::Normal)]
pub transform: Transform,
#[knuffel(child)]
@@ -2462,7 +2462,7 @@ mod tests {
}
output "eDP-1" {
- scale 2.0
+ scale 2
transform "flipped-90"
position x=10 y=20
mode "1920x1080@144"
@@ -2636,7 +2636,7 @@ mod tests {
outputs: vec![Output {
off: false,
name: "eDP-1".to_owned(),
- scale: Some(2.),
+ scale: Some(FloatOrInt(2.)),
transform: Transform::Flipped90,
position: Some(Position { x: 10, y: 20 }),
mode: Some(ConfiguredMode {
diff --git a/resources/default-config.kdl b/resources/default-config.kdl
index ad612d2c..469517da 100644
--- a/resources/default-config.kdl
+++ b/resources/default-config.kdl
@@ -66,7 +66,7 @@ input {
mode "1920x1080@120.030"
// You can use integer or fractional scale, for example use 1.5 for 150% scale.
- scale 2.0
+ scale 2
// Transform allows to rotate the output counter-clockwise, valid values are:
// normal, 90, 180, 270, flipped, flipped-90, flipped-180 and flipped-270.
diff --git a/src/niri.rs b/src/niri.rs
index 4817b6b0..fca93657 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -11,7 +11,9 @@ use std::{env, mem, thread};
use _server_decoration::server::org_kde_kwin_server_decoration_manager::Mode as KdeDecorationsMode;
use anyhow::{ensure, Context};
use calloop::futures::Scheduler;
-use niri_config::{Config, Key, Modifiers, PreviewRender, TrackLayout, WorkspaceReference};
+use niri_config::{
+ Config, FloatOrInt, Key, Modifiers, PreviewRender, TrackLayout, WorkspaceReference,
+};
use niri_ipc::Workspace;
use smithay::backend::allocator::Fourcc;
use smithay::backend::renderer::damage::OutputDamageTracker;
@@ -1048,11 +1050,14 @@ impl State {
.iter()
.find(|o| o.name.eq_ignore_ascii_case(&name));
- let scale = config.and_then(|c| c.scale).unwrap_or_else(|| {
- let size_mm = output.physical_properties().size;
- let resolution = output.current_mode().unwrap().size;
- guess_monitor_scale(size_mm, resolution)
- });
+ let scale = config
+ .and_then(|c| c.scale)
+ .map(|s| s.0)
+ .unwrap_or_else(|| {
+ let size_mm = output.physical_properties().size;
+ let resolution = output.current_mode().unwrap().size;
+ guess_monitor_scale(size_mm, resolution)
+ });
let scale = closest_representable_scale(scale.clamp(0.1, 10.));
let mut transform = config
@@ -1118,7 +1123,7 @@ impl State {
niri_ipc::OutputAction::Scale { scale } => {
config.scale = match scale {
niri_ipc::ScaleToSet::Automatic => None,
- niri_ipc::ScaleToSet::Specific(scale) => Some(scale),
+ niri_ipc::ScaleToSet::Specific(scale) => Some(FloatOrInt(scale)),
}
}
niri_ipc::OutputAction::Transform { transform } => config.transform = transform,
@@ -1731,7 +1736,7 @@ impl Niri {
.outputs
.iter()
.find(|o| o.name.eq_ignore_ascii_case(&name));
- let scale = c.and_then(|c| c.scale).unwrap_or_else(|| {
+ let scale = c.and_then(|c| c.scale).map(|s| s.0).unwrap_or_else(|| {
let size_mm = output.physical_properties().size;
let resolution = output.current_mode().unwrap().size;
guess_monitor_scale(size_mm, resolution)
diff --git a/wiki/Configuration:-Outputs.md b/wiki/Configuration:-Outputs.md
index 8a63a6bd..6ecf91ab 100644
--- a/wiki/Configuration:-Outputs.md
+++ b/wiki/Configuration:-Outputs.md
@@ -72,6 +72,10 @@ Set the scale of the monitor.
<sup>Since: 0.1.7</sup> You can use fractional scale values, for example `scale 1.5` for 150% scale.
+<sup>Since: 0.1.7</sup> Dot is no longer needed for integer scale, for example you can write `scale 2` instead of `scale 2.0`.
+
+<sup>Since: 0.1.7</sup> Scale below 0 and above 10 will now fail during config parsing. Scale was previously clamped to these values anyway.
+
```
output "eDP-1" {
scale 2.0