dbus: DisplayConfig: report fractional scales as supported
Browse files at this commitb853d5b1247fddfaeac0dbdfb9304c69c6de463aParent: 693e0e02 changed files +11 -7
- src/dbus/mutter_display_config.rs +10 -6
- src/utils/scale.rs +1 -1
src/dbus/mutter_display_config.rsmodified+10 -6
| @@ -2,6 +2,7 @@ use std::collections::HashMap; | |||
| 2 | use std::sync::{Arc, Mutex}; | 2 | use std::sync::{Arc, Mutex}; |
| 3 | 3 | ||
| 4 | use serde::Serialize; | 4 | use serde::Serialize; |
| 5 | +use smithay::utils::Size; | ||
| 5 | use zbus::fdo::RequestNameFlags; | 6 | use zbus::fdo::RequestNameFlags; |
| 6 | use zbus::object_server::SignalEmitter; | 7 | use zbus::object_server::SignalEmitter; |
| 7 | use zbus::zvariant::{self, OwnedValue, Type}; | 8 | use zbus::zvariant::{self, OwnedValue, Type}; |
| @@ -10,6 +11,7 @@ use zbus::{fdo, interface}; | |||
| 10 | use super::Start; | 11 | use super::Start; |
| 11 | use crate::backend::IpcOutputMap; | 12 | use crate::backend::IpcOutputMap; |
| 12 | use crate::utils::is_laptop_panel; | 13 | use crate::utils::is_laptop_panel; |
| 14 | +use crate::utils::scale::supported_scales; | ||
| 13 | 15 | ||
| 14 | pub struct DisplayConfig { | 16 | pub struct DisplayConfig { |
| 15 | ipc_outputs: Arc<Mutex<IpcOutputMap>>, | 17 | ipc_outputs: Arc<Mutex<IpcOutputMap>>, |
| @@ -84,15 +86,17 @@ impl DisplayConfig { | |||
| 84 | refresh_rate, | 86 | refresh_rate, |
| 85 | is_preferred, | 87 | is_preferred, |
| 86 | } = *m; | 88 | } = *m; |
| 87 | - let refresh = refresh_rate as f64 / 1000.; | 89 | + let width = i32::from(width); |
| 90 | + let height = i32::from(height); | ||
| 91 | + let refresh_rate = refresh_rate as f64 / 1000.; | ||
| 88 | 92 | ||
| 89 | Mode { | 93 | Mode { |
| 90 | - id: format!("{width}x{height}@{refresh:.3}"), | 94 | + id: format!("{width}x{height}@{refresh_rate:.3}"), |
| 91 | - width: i32::from(width), | 95 | + width, |
| 92 | - height: i32::from(height), | 96 | + height, |
| 93 | - refresh_rate: refresh, | 97 | + refresh_rate, |
| 94 | preferred_scale: 1., | 98 | preferred_scale: 1., |
| 95 | - supported_scales: vec![1., 2., 3.], | 99 | + supported_scales: supported_scales(Size::from((width, height))).collect(), |
| 96 | properties: HashMap::from([( | 100 | properties: HashMap::from([( |
| 97 | String::from("is-preferred"), | 101 | String::from("is-preferred"), |
| 98 | OwnedValue::from(is_preferred), | 102 | OwnedValue::from(is_preferred), |
src/utils/scale.rsmodified+1 -1
| @@ -38,7 +38,7 @@ pub fn guess_monitor_scale(size_mm: Size<i32, Raw>, resolution: Size<i32, Physic | |||
| 38 | .map_or(1., |(scale, _)| scale) | 38 | .map_or(1., |(scale, _)| scale) |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | -fn supported_scales(resolution: Size<i32, Physical>) -> impl Iterator<Item = f64> { | 41 | +pub fn supported_scales(resolution: Size<i32, Physical>) -> impl Iterator<Item = f64> { |
| 42 | (MIN_SCALE * STEPS..=MAX_SCALE * STEPS) | 42 | (MIN_SCALE * STEPS..=MAX_SCALE * STEPS) |
| 43 | .map(|x| f64::from(x) / f64::from(STEPS)) | 43 | .map(|x| f64::from(x) / f64::from(STEPS)) |
| 44 | .filter(move |scale| is_valid_for_resolution(resolution, *scale)) | 44 | .filter(move |scale| is_valid_for_resolution(resolution, *scale)) |