Support listing available video modes for a monitor (#896)

* Support listing available video modes for a monitor

* Use derivative for Windows `MonitorHandle`

* Update FEATURES.md

* Fix multiline if statement

* Add documentation for `VideoMode` type
This commit is contained in:
Aleksi Juvani 2019-06-12 21:07:25 +03:00 committed by Osspial
parent 2b89ddec15
commit 47b5dfa034
13 changed files with 254 additions and 23 deletions

View file

@ -9,6 +9,7 @@ use event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW}
use event::ModifiersState;
use dpi::{PhysicalPosition, PhysicalSize};
use platform_impl::platform::sticky_exit_callback;
use monitor::VideoMode;
use super::window::WindowStore;
use super::WindowId;
@ -584,6 +585,20 @@ impl MonitorHandle {
.with_info(&self.proxy, |_, info| info.scale_factor)
.unwrap_or(1)
}
#[inline]
pub fn video_modes(&self) -> impl Iterator<Item = VideoMode>
{
self.mgr
.with_info(&self.proxy, |_, info| info.modes.clone())
.unwrap_or(vec![])
.into_iter()
.map(|x| VideoMode {
dimensions: (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
})
}
}
pub fn primary_monitor(outputs: &OutputMgr) -> MonitorHandle {