From e1a6494cb48f3e7fd42576a84c47e69c8d94bc55 Mon Sep 17 00:00:00 2001 From: Osspial Date: Wed, 12 Jun 2019 15:32:52 -0400 Subject: [PATCH] Change Monitor dimensions functions to size functions --- src/monitor.rs | 10 +++++----- src/platform_impl/android/mod.rs | 8 ++++---- src/platform_impl/emscripten/mod.rs | 2 +- src/platform_impl/ios/monitor.rs | 8 ++++---- src/platform_impl/linux/mod.rs | 6 +++--- src/platform_impl/linux/wayland/event_loop.rs | 8 ++++---- src/platform_impl/linux/x11/monitor.rs | 4 ++-- src/platform_impl/linux/x11/util/randr.rs | 6 +++--- src/platform_impl/macos/monitor.rs | 8 ++++---- src/platform_impl/windows/monitor.rs | 4 ++-- src/platform_impl/windows/window.rs | 2 +- src/window.rs | 2 +- 12 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/monitor.rs b/src/monitor.rs index c70cfb8d32..0e52a3c2a1 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -52,15 +52,15 @@ impl Iterator for AvailableMonitorsIter { /// [monitor_get]: ../monitor/struct.MonitorHandle.html#method.video_modes #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct VideoMode { - pub(crate) dimensions: (u32, u32), + pub(crate) size: (u32, u32), pub(crate) bit_depth: u16, pub(crate) refresh_rate: u16, } impl VideoMode { /// Returns the resolution of this video mode. - pub fn dimensions(&self) -> PhysicalSize { - self.dimensions.into() + pub fn size(&self) -> PhysicalSize { + self.size.into() } /// Returns the bit depth of this video mode, as in how many bits you have @@ -104,8 +104,8 @@ impl MonitorHandle { /// Returns the monitor's resolution. #[inline] - pub fn dimensions(&self) -> PhysicalSize { - self.inner.dimensions() + pub fn size(&self) -> PhysicalSize { + self.inner.size() } /// Returns the top-left corner position of the monitor relative to the larger full diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index ce58c0e758..86ea4ccb3a 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -107,7 +107,7 @@ impl EventLoop { None } else { let dpi_factor = MonitorHandle.hidpi_factor(); - let physical_size = MonitorHandle.dimensions(); + let physical_size = MonitorHandle.size(); let size = LogicalSize::from_physical(physical_size, dpi_factor); Some(Event::WindowEvent { window_id: RootWindowId(WindowId), @@ -207,7 +207,7 @@ impl fmt::Debug for MonitorHandle { let monitor_id_proxy = MonitorHandle { name: self.name(), - dimensions: self.dimensions(), + dimensions: self.size(), position: self.outer_position(), hidpi_factor: self.hidpi_factor(), }; @@ -223,7 +223,7 @@ impl MonitorHandle { } #[inline] - pub fn dimensions(&self) -> PhysicalSize { + pub fn size(&self) -> PhysicalSize { unsafe { let window = android_glue::native_window(); ( @@ -325,7 +325,7 @@ impl Window { None } else { let dpi_factor = self.hidpi_factor(); - let physical_size = self.current_monitor().dimensions(); + let physical_size = self.current_monitor().size(); Some(LogicalSize::from_physical(physical_size, dpi_factor)) } } diff --git a/src/platform_impl/emscripten/mod.rs b/src/platform_impl/emscripten/mod.rs index 140ba53d97..dfc7272d92 100644 --- a/src/platform_impl/emscripten/mod.rs +++ b/src/platform_impl/emscripten/mod.rs @@ -54,7 +54,7 @@ impl MonitorHandle { } #[inline] - pub fn dimensions(&self) -> PhysicalSize { + pub fn size(&self) -> PhysicalSize { (0, 0).into() } diff --git a/src/platform_impl/ios/monitor.rs b/src/platform_impl/ios/monitor.rs index 3bfa0f32e5..152a5ecdd2 100644 --- a/src/platform_impl/ios/monitor.rs +++ b/src/platform_impl/ios/monitor.rs @@ -67,14 +67,14 @@ impl fmt::Debug for MonitorHandle { #[derive(Debug)] struct MonitorHandle { name: Option, - dimensions: PhysicalSize, + size: PhysicalSize, position: PhysicalPosition, hidpi_factor: f64, } let monitor_id_proxy = MonitorHandle { name: self.name(), - dimensions: self.dimensions(), + size: self.size(), position: self.position(), hidpi_factor: self.hidpi_factor(), }; @@ -109,7 +109,7 @@ impl Inner { } } - pub fn dimensions(&self) -> PhysicalSize { + pub fn size(&self) -> PhysicalSize { unsafe { let bounds: CGRect = msg_send![self.ui_screen(), nativeBounds]; (bounds.size.width as f64, bounds.size.height as f64).into() @@ -142,7 +142,7 @@ impl Inner { let mode: id = unsafe { msg_send![available_modes, objectAtIndex: i] }; let size: CGSize = unsafe { msg_send![mode, size] }; modes.insert(VideoMode { - dimensions: (size.width as u32, size.height as u32), + size: (size.width as u32, size.height as u32), bit_depth: 32, refresh_rate: refresh_rate as u16, }); diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index ca0b067000..b54a4a2596 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -120,10 +120,10 @@ impl MonitorHandle { } #[inline] - pub fn dimensions(&self) -> PhysicalSize { + pub fn size(&self) -> PhysicalSize { match self { - &MonitorHandle::X(ref m) => m.dimensions(), - &MonitorHandle::Wayland(ref m) => m.dimensions(), + &MonitorHandle::X(ref m) => m.size(), + &MonitorHandle::Wayland(ref m) => m.size(), } } diff --git a/src/platform_impl/linux/wayland/event_loop.rs b/src/platform_impl/linux/wayland/event_loop.rs index 03d2c24051..23deb87d68 100644 --- a/src/platform_impl/linux/wayland/event_loop.rs +++ b/src/platform_impl/linux/wayland/event_loop.rs @@ -531,7 +531,7 @@ impl fmt::Debug for MonitorHandle { struct MonitorHandle { name: Option, native_identifier: u32, - dimensions: PhysicalSize, + size: PhysicalSize, position: PhysicalPosition, hidpi_factor: i32, } @@ -539,7 +539,7 @@ impl fmt::Debug for MonitorHandle { let monitor_id_proxy = MonitorHandle { name: self.name(), native_identifier: self.native_identifier(), - dimensions: self.dimensions(), + size: self.size(), position: self.position(), hidpi_factor: self.hidpi_factor(), }; @@ -560,7 +560,7 @@ impl MonitorHandle { self.mgr.with_info(&self.proxy, |id, _| id).unwrap_or(0) } - pub fn dimensions(&self) -> PhysicalSize { + pub fn size(&self) -> PhysicalSize { match self.mgr.with_info(&self.proxy, |_, info| { info.modes .iter() @@ -594,7 +594,7 @@ impl MonitorHandle { .unwrap_or(vec![]) .into_iter() .map(|x| VideoMode { - dimensions: (x.dimensions.0 as u32, x.dimensions.1 as u32), + size: (x.dimensions.0 as u32, x.dimensions.1 as u32), refresh_rate: (x.refresh_rate as f32 / 1000.0).round() as u16, bit_depth: 32 }) diff --git a/src/platform_impl/linux/x11/monitor.rs b/src/platform_impl/linux/x11/monitor.rs index 716ddaaa41..eb9b0ec2ab 100644 --- a/src/platform_impl/linux/x11/monitor.rs +++ b/src/platform_impl/linux/x11/monitor.rs @@ -70,7 +70,7 @@ impl MonitorHandle { primary: bool, ) -> Option { let (name, hidpi_factor, video_modes) = unsafe { xconn.get_output_info(resources, &repr)? }; - let (dimensions, position) = unsafe { (repr.dimensions(), repr.position()) }; + let (dimensions, position) = unsafe { (repr.size(), repr.position()) }; let rect = util::AaRect::new(position, dimensions); Some(MonitorHandle { id, @@ -93,7 +93,7 @@ impl MonitorHandle { self.id as u32 } - pub fn dimensions(&self) -> PhysicalSize { + pub fn size(&self) -> PhysicalSize { self.dimensions.into() } diff --git a/src/platform_impl/linux/x11/util/randr.rs b/src/platform_impl/linux/x11/util/randr.rs index 80c617b1ef..4513e77d9c 100644 --- a/src/platform_impl/linux/x11/util/randr.rs +++ b/src/platform_impl/linux/x11/util/randr.rs @@ -52,7 +52,7 @@ impl MonitorRepr { } } - pub unsafe fn dimensions(&self) -> (u32, u32) { + pub unsafe fn size(&self) -> (u32, u32) { match *self { MonitorRepr::Monitor(monitor) => ((*monitor).width as u32, (*monitor).height as u32), MonitorRepr::Crtc(crtc) => ((*crtc).width as u32, (*crtc).height as u32), @@ -136,7 +136,7 @@ impl XConnection { }; VideoMode { - dimensions: (x.width, x.height), + size: (x.width, x.height), refresh_rate: (refresh_rate as f32 / 1000.0).round() as u16, bit_depth: bit_depth as u16, } @@ -151,7 +151,7 @@ impl XConnection { dpi / 96. } else { calc_dpi_factor( - repr.dimensions(), + repr.size(), ((*output_info).mm_width as u64, (*output_info).mm_height as u64), ) }; diff --git a/src/platform_impl/macos/monitor.rs b/src/platform_impl/macos/monitor.rs index d9d924ffd2..43cfe55650 100644 --- a/src/platform_impl/macos/monitor.rs +++ b/src/platform_impl/macos/monitor.rs @@ -41,7 +41,7 @@ impl fmt::Debug for MonitorHandle { struct MonitorHandle { name: Option, native_identifier: u32, - dimensions: PhysicalSize, + size: PhysicalSize, position: PhysicalPosition, hidpi_factor: f64, } @@ -49,7 +49,7 @@ impl fmt::Debug for MonitorHandle { let monitor_id_proxy = MonitorHandle { name: self.name(), native_identifier: self.native_identifier(), - dimensions: self.dimensions(), + size: self.size(), position: self.position(), hidpi_factor: self.hidpi_factor(), }; @@ -74,7 +74,7 @@ impl MonitorHandle { self.0 } - pub fn dimensions(&self) -> PhysicalSize { + pub fn size(&self) -> PhysicalSize { let MonitorHandle(display_id) = *self; let display = CGDisplay::new(display_id); let height = display.pixels_high(); @@ -133,7 +133,7 @@ impl MonitorHandle { }; VideoMode { - dimensions: (mode.width() as u32, mode.height() as u32), + size: (mode.width() as u32, mode.height() as u32), refresh_rate: refresh_rate as u16, bit_depth: mode.bit_depth() as u16, } diff --git a/src/platform_impl/windows/monitor.rs b/src/platform_impl/windows/monitor.rs index 01de9da64a..d078136542 100644 --- a/src/platform_impl/windows/monitor.rs +++ b/src/platform_impl/windows/monitor.rs @@ -162,7 +162,7 @@ impl MonitorHandle { } #[inline] - pub fn dimensions(&self) -> PhysicalSize { + pub fn size(&self) -> PhysicalSize { self.dimensions.into() } @@ -201,7 +201,7 @@ impl MonitorHandle { assert!(mode.dmFields & REQUIRED_FIELDS == REQUIRED_FIELDS); modes.insert(VideoMode { - dimensions: (mode.dmPelsWidth, mode.dmPelsHeight), + size: (mode.dmPelsWidth, mode.dmPelsHeight), bit_depth: mode.dmBitsPerPel as u16, refresh_rate: mode.dmDisplayFrequency as u16, }); diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 351ffc1c8c..1ccd5261cd 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -403,7 +403,7 @@ impl Window { match &monitor { &Some(RootMonitorHandle { ref inner }) => { let (x, y): (i32, i32) = inner.position().into(); - let (width, height): (u32, u32) = inner.dimensions().into(); + let (width, height): (u32, u32) = inner.size().into(); let mut monitor = monitor.clone(); self.thread_executor.execute_in_thread(move || { diff --git a/src/window.rs b/src/window.rs index c65d6e88ff..c042f109eb 100644 --- a/src/window.rs +++ b/src/window.rs @@ -287,7 +287,7 @@ impl WindowBuilder { self.window.inner_size = Some(self.window.inner_size.unwrap_or_else(|| { if let Some(ref monitor) = self.window.fullscreen { // resizing the window to the dimensions of the monitor when fullscreen - LogicalSize::from_physical(monitor.dimensions(), 1.0) + LogicalSize::from_physical(monitor.size(), 1.0) } else { // default dimensions (1024, 768).into()