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 | 2 | use std::sync::{Arc, Mutex}; |
| 3 | 3 | |
| 4 | 4 | use serde::Serialize; |
| 5 | +use smithay::utils::Size; | |
| 5 | 6 | use zbus::fdo::RequestNameFlags; |
| 6 | 7 | use zbus::object_server::SignalEmitter; |
| 7 | 8 | use zbus::zvariant::{self, OwnedValue, Type}; |
| @@ -10,6 +11,7 @@ use zbus::{fdo, interface}; | ||
| 10 | 11 | use super::Start; |
| 11 | 12 | use crate::backend::IpcOutputMap; |
| 12 | 13 | use crate::utils::is_laptop_panel; |
| 14 | +use crate::utils::scale::supported_scales; | |
| 13 | 15 | |
| 14 | 16 | pub struct DisplayConfig { |
| 15 | 17 | ipc_outputs: Arc<Mutex<IpcOutputMap>>, |
| @@ -84,15 +86,17 @@ impl DisplayConfig { | ||
| 84 | 86 | refresh_rate, |
| 85 | 87 | is_preferred, |
| 86 | 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 | 93 | Mode { |
| 90 | - id: format!("{width}x{height}@{refresh:.3}"), | |
| 91 | - width: i32::from(width), | |
| 92 | - height: i32::from(height), | |
| 93 | - refresh_rate: refresh, | |
| 94 | + id: format!("{width}x{height}@{refresh_rate:.3}"), | |
| 95 | + width, | |
| 96 | + height, | |
| 97 | + refresh_rate, | |
| 94 | 98 | preferred_scale: 1., |
| 95 | - supported_scales: vec![1., 2., 3.], | |
| 99 | + supported_scales: supported_scales(Size::from((width, height))).collect(), | |
| 96 | 100 | properties: HashMap::from([( |
| 97 | 101 | String::from("is-preferred"), |
| 98 | 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 | 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 | 42 | (MIN_SCALE * STEPS..=MAX_SCALE * STEPS) |
| 43 | 43 | .map(|x| f64::from(x) / f64::from(STEPS)) |
| 44 | 44 | .filter(move |scale| is_valid_for_resolution(resolution, *scale)) |