mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Make scale use FloatOrInt
This commit is contained in:
@@ -298,7 +298,7 @@ pub struct Output {
|
|||||||
#[knuffel(argument)]
|
#[knuffel(argument)]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
#[knuffel(child, unwrap(argument))]
|
#[knuffel(child, unwrap(argument))]
|
||||||
pub scale: Option<f64>,
|
pub scale: Option<FloatOrInt<0, 10>>,
|
||||||
#[knuffel(child, unwrap(argument, str), default = Transform::Normal)]
|
#[knuffel(child, unwrap(argument, str), default = Transform::Normal)]
|
||||||
pub transform: Transform,
|
pub transform: Transform,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
@@ -2462,7 +2462,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
output "eDP-1" {
|
output "eDP-1" {
|
||||||
scale 2.0
|
scale 2
|
||||||
transform "flipped-90"
|
transform "flipped-90"
|
||||||
position x=10 y=20
|
position x=10 y=20
|
||||||
mode "1920x1080@144"
|
mode "1920x1080@144"
|
||||||
@@ -2636,7 +2636,7 @@ mod tests {
|
|||||||
outputs: vec![Output {
|
outputs: vec![Output {
|
||||||
off: false,
|
off: false,
|
||||||
name: "eDP-1".to_owned(),
|
name: "eDP-1".to_owned(),
|
||||||
scale: Some(2.),
|
scale: Some(FloatOrInt(2.)),
|
||||||
transform: Transform::Flipped90,
|
transform: Transform::Flipped90,
|
||||||
position: Some(Position { x: 10, y: 20 }),
|
position: Some(Position { x: 10, y: 20 }),
|
||||||
mode: Some(ConfiguredMode {
|
mode: Some(ConfiguredMode {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ input {
|
|||||||
mode "1920x1080@120.030"
|
mode "1920x1080@120.030"
|
||||||
|
|
||||||
// You can use integer or fractional scale, for example use 1.5 for 150% scale.
|
// 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:
|
// Transform allows to rotate the output counter-clockwise, valid values are:
|
||||||
// normal, 90, 180, 270, flipped, flipped-90, flipped-180 and flipped-270.
|
// normal, 90, 180, 270, flipped, flipped-90, flipped-180 and flipped-270.
|
||||||
|
|||||||
+9
-4
@@ -11,7 +11,9 @@ use std::{env, mem, thread};
|
|||||||
use _server_decoration::server::org_kde_kwin_server_decoration_manager::Mode as KdeDecorationsMode;
|
use _server_decoration::server::org_kde_kwin_server_decoration_manager::Mode as KdeDecorationsMode;
|
||||||
use anyhow::{ensure, Context};
|
use anyhow::{ensure, Context};
|
||||||
use calloop::futures::Scheduler;
|
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 niri_ipc::Workspace;
|
||||||
use smithay::backend::allocator::Fourcc;
|
use smithay::backend::allocator::Fourcc;
|
||||||
use smithay::backend::renderer::damage::OutputDamageTracker;
|
use smithay::backend::renderer::damage::OutputDamageTracker;
|
||||||
@@ -1048,7 +1050,10 @@ impl State {
|
|||||||
.iter()
|
.iter()
|
||||||
.find(|o| o.name.eq_ignore_ascii_case(&name));
|
.find(|o| o.name.eq_ignore_ascii_case(&name));
|
||||||
|
|
||||||
let scale = config.and_then(|c| c.scale).unwrap_or_else(|| {
|
let scale = config
|
||||||
|
.and_then(|c| c.scale)
|
||||||
|
.map(|s| s.0)
|
||||||
|
.unwrap_or_else(|| {
|
||||||
let size_mm = output.physical_properties().size;
|
let size_mm = output.physical_properties().size;
|
||||||
let resolution = output.current_mode().unwrap().size;
|
let resolution = output.current_mode().unwrap().size;
|
||||||
guess_monitor_scale(size_mm, resolution)
|
guess_monitor_scale(size_mm, resolution)
|
||||||
@@ -1118,7 +1123,7 @@ impl State {
|
|||||||
niri_ipc::OutputAction::Scale { scale } => {
|
niri_ipc::OutputAction::Scale { scale } => {
|
||||||
config.scale = match scale {
|
config.scale = match scale {
|
||||||
niri_ipc::ScaleToSet::Automatic => None,
|
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,
|
niri_ipc::OutputAction::Transform { transform } => config.transform = transform,
|
||||||
@@ -1731,7 +1736,7 @@ impl Niri {
|
|||||||
.outputs
|
.outputs
|
||||||
.iter()
|
.iter()
|
||||||
.find(|o| o.name.eq_ignore_ascii_case(&name));
|
.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 size_mm = output.physical_properties().size;
|
||||||
let resolution = output.current_mode().unwrap().size;
|
let resolution = output.current_mode().unwrap().size;
|
||||||
guess_monitor_scale(size_mm, resolution)
|
guess_monitor_scale(size_mm, resolution)
|
||||||
|
|||||||
@@ -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> 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" {
|
output "eDP-1" {
|
||||||
scale 2.0
|
scale 2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user