Remove MonitorHandle::size/refresh_rate_millihertz()
This commit is contained in:
parent
2e53533cc1
commit
0ffcfd8a3a
13 changed files with 81 additions and 218 deletions
|
|
@ -241,21 +241,11 @@ impl MonitorHandle {
|
|||
x11_or_wayland!(match self; MonitorHandle(m) => m.native_identifier())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn size(&self) -> PhysicalSize<u32> {
|
||||
x11_or_wayland!(match self; MonitorHandle(m) => m.size())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||
x11_or_wayland!(match self; MonitorHandle(m) => m.position())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn refresh_rate_millihertz(&self) -> Option<u32> {
|
||||
x11_or_wayland!(match self; MonitorHandle(m) => m.refresh_rate_millihertz())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scale_factor(&self) -> f64 {
|
||||
x11_or_wayland!(match self; MonitorHandle(m) => m.scale_factor() as _)
|
||||
|
|
@ -292,7 +282,7 @@ impl VideoModeHandle {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn refresh_rate_millihertz(&self) -> u32 {
|
||||
pub fn refresh_rate_millihertz(&self) -> Option<u32> {
|
||||
x11_or_wayland!(match self; VideoModeHandle(m) => m.refresh_rate_millihertz())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,20 +28,6 @@ impl MonitorHandle {
|
|||
output_data.with_output_info(|info| info.id)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn size(&self) -> PhysicalSize<u32> {
|
||||
let output_data = self.proxy.data::<OutputData>().unwrap();
|
||||
let dimensions = output_data.with_output_info(|info| {
|
||||
info.modes.iter().find_map(|mode| mode.current.then_some(mode.dimensions))
|
||||
});
|
||||
|
||||
match dimensions {
|
||||
Some((width, height)) => (width as u32, height as u32),
|
||||
_ => (0, 0),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||
let output_data = self.proxy.data::<OutputData>().unwrap();
|
||||
|
|
@ -59,14 +45,6 @@ impl MonitorHandle {
|
|||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn refresh_rate_millihertz(&self) -> Option<u32> {
|
||||
let output_data = self.proxy.data::<OutputData>().unwrap();
|
||||
output_data.with_output_info(|info| {
|
||||
info.modes.iter().find_map(|mode| mode.current.then_some(mode.refresh_rate as u32))
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scale_factor(&self) -> i32 {
|
||||
let output_data = self.proxy.data::<OutputData>().unwrap();
|
||||
|
|
@ -153,8 +131,8 @@ impl VideoModeHandle {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn refresh_rate_millihertz(&self) -> u32 {
|
||||
self.refresh_rate_millihertz
|
||||
pub fn refresh_rate_millihertz(&self) -> Option<u32> {
|
||||
Some(self.refresh_rate_millihertz)
|
||||
}
|
||||
|
||||
pub fn monitor(&self) -> MonitorHandle {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ pub struct VideoModeHandle {
|
|||
pub(crate) current: bool,
|
||||
pub(crate) size: (u32, u32),
|
||||
pub(crate) bit_depth: u16,
|
||||
pub(crate) refresh_rate_millihertz: u32,
|
||||
pub(crate) refresh_rate_millihertz: Option<u32>,
|
||||
pub(crate) native_mode: randr::Mode,
|
||||
pub(crate) monitor: Option<MonitorHandle>,
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ impl VideoModeHandle {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn refresh_rate_millihertz(&self) -> u32 {
|
||||
pub fn refresh_rate_millihertz(&self) -> Option<u32> {
|
||||
self.refresh_rate_millihertz
|
||||
}
|
||||
|
||||
|
|
@ -54,8 +54,6 @@ pub struct MonitorHandle {
|
|||
pub(crate) id: randr::Crtc,
|
||||
/// The name of the monitor
|
||||
pub(crate) name: String,
|
||||
/// The size of the monitor
|
||||
dimensions: (u32, u32),
|
||||
/// The position of the monitor in the X screen
|
||||
position: (i32, i32),
|
||||
/// If the monitor is the primary one
|
||||
|
|
@ -118,16 +116,7 @@ impl MonitorHandle {
|
|||
|
||||
let rect = util::AaRect::new(position, dimensions);
|
||||
|
||||
Some(MonitorHandle {
|
||||
id,
|
||||
name,
|
||||
scale_factor,
|
||||
dimensions,
|
||||
position,
|
||||
primary,
|
||||
rect,
|
||||
video_modes,
|
||||
})
|
||||
Some(MonitorHandle { id, name, scale_factor, position, primary, rect, video_modes })
|
||||
}
|
||||
|
||||
pub fn dummy() -> Self {
|
||||
|
|
@ -135,7 +124,6 @@ impl MonitorHandle {
|
|||
id: 0,
|
||||
name: "<dummy monitor>".into(),
|
||||
scale_factor: 1.0,
|
||||
dimensions: (1, 1),
|
||||
position: (0, 0),
|
||||
primary: true,
|
||||
rect: util::AaRect::new((0, 0), (1, 1)),
|
||||
|
|
@ -157,20 +145,10 @@ impl MonitorHandle {
|
|||
self.id as _
|
||||
}
|
||||
|
||||
pub fn size(&self) -> PhysicalSize<u32> {
|
||||
self.dimensions.into()
|
||||
}
|
||||
|
||||
pub fn position(&self) -> PhysicalPosition<i32> {
|
||||
self.position.into()
|
||||
}
|
||||
|
||||
pub fn refresh_rate_millihertz(&self) -> Option<u32> {
|
||||
self.video_modes
|
||||
.iter()
|
||||
.find_map(|mode| mode.current.then_some(mode.refresh_rate_millihertz))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scale_factor(&self) -> f64 {
|
||||
self.scale_factor
|
||||
|
|
|
|||
|
|
@ -85,8 +85,7 @@ impl XConnection {
|
|||
VideoModeHandle {
|
||||
current: mode.id == current_mode,
|
||||
size: (mode.width.into(), mode.height.into()),
|
||||
refresh_rate_millihertz: monitor::mode_refresh_rate_millihertz(mode)
|
||||
.unwrap_or(0),
|
||||
refresh_rate_millihertz: monitor::mode_refresh_rate_millihertz(mode),
|
||||
bit_depth: bit_depth as u16,
|
||||
native_mode: mode.id,
|
||||
// This is populated in `MonitorHandle::video_modes` as the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue