Skip to content

Commit

Permalink
dbus: DisplayConfig: report fractional scales as supported
Browse files Browse the repository at this point in the history
  • Loading branch information
valpackett committed Jan 5, 2025
1 parent d24a08c commit 74f2509
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/dbus/mutter_display_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ use std::collections::HashMap;
use std::sync::{Arc, Mutex};

use serde::Serialize;
use smithay::utils::Size;
use zbus::fdo::RequestNameFlags;
use zbus::object_server::SignalEmitter;
use zbus::zvariant::{self, OwnedValue, Type};
use zbus::{fdo, interface};

use super::Start;
use crate::backend::IpcOutputMap;
use crate::utils::is_laptop_panel;
use crate::utils::{is_laptop_panel, scale::supported_scales};

pub struct DisplayConfig {
ipc_outputs: Arc<Mutex<IpcOutputMap>>,
Expand Down Expand Up @@ -84,15 +85,17 @@ impl DisplayConfig {
refresh_rate,
is_preferred,
} = *m;
let refresh = refresh_rate as f64 / 1000.;
let width = i32::from(width);
let height = i32::from(height);
let refresh_rate = refresh_rate as f64 / 1000.;

Mode {
id: format!("{width}x{height}@{refresh:.3}"),
width: i32::from(width),
height: i32::from(height),
refresh_rate: refresh,
id: format!("{width}x{height}@{refresh_rate:.3}"),
width,
height,
refresh_rate,
preferred_scale: 1.,
supported_scales: vec![1., 2., 3.],
supported_scales: supported_scales(Size::from((width, height))).collect(),
properties: HashMap::from([(
String::from("is-preferred"),
OwnedValue::from(is_preferred),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn guess_monitor_scale(size_mm: Size<i32, Raw>, resolution: Size<i32, Physic
.map_or(1., |(scale, _)| scale)
}

fn supported_scales(resolution: Size<i32, Physical>) -> impl Iterator<Item = f64> {
pub fn supported_scales(resolution: Size<i32, Physical>) -> impl Iterator<Item = f64> {
(MIN_SCALE * STEPS..=MAX_SCALE * STEPS)
.map(|x| f64::from(x) / f64::from(STEPS))
.filter(move |scale| is_valid_for_resolution(resolution, *scale))
Expand Down

0 comments on commit 74f2509

Please sign in to comment.