diff options
Diffstat (limited to 'engine/src/windowing/monitor.rs')
| -rw-r--r-- | engine/src/windowing/monitor.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/engine/src/windowing/monitor.rs b/engine/src/windowing/monitor.rs new file mode 100644 index 0000000..894448a --- /dev/null +++ b/engine/src/windowing/monitor.rs @@ -0,0 +1,50 @@ +use crate::windowing::dpi::{PhysicalPosition, PhysicalSize}; + +/// Handle to a monitor that may or may not exist any longer. +#[derive(Debug, Clone)] +pub struct Handle +{ + inner: winit::monitor::MonitorHandle, +} + +impl Handle +{ + /// Returns a human-readable name of the monitor. + #[inline] + pub fn name(&self) -> Option<String> + { + self.inner.name() + } + + /// Returns the monitor's resolution. + #[inline] + pub fn size(&self) -> PhysicalSize<u32> + { + self.inner.size().into() + } + + /// Returns the top-left corner position of the monitor relative to the larger full + /// screen area. + #[inline] + pub fn position(&self) -> PhysicalPosition<i32> + { + self.inner.position().into() + } + + /// Returns the scale factor of the underlying monitor. + #[inline] + pub fn scale_factor(&self) -> f64 + { + self.inner.scale_factor() + } +} + +impl Handle +{ + pub(super) fn from_winit_monitor_handle( + monitor: winit::monitor::MonitorHandle, + ) -> Self + { + Self { inner: monitor } + } +} |
