Use EnumDisplayMonitors to enumerate monitors on Windows (#327)

* Use EnumDisplayMonitors to enumerate monitors on Windows

* Add requested changes
This commit is contained in:
kryptan
2017-10-25 18:12:39 +03:00
committed by tomaka
parent d10312c6b1
commit 760e588627
3 changed files with 70 additions and 102 deletions

View File

@@ -1,5 +1,6 @@
#![cfg(target_os = "windows")]
use std::os::raw::c_void;
use libc;
use MonitorId;
use Window;
@@ -37,8 +38,11 @@ impl WindowBuilderExt for WindowBuilder {
/// Additional methods on `MonitorId` that are specific to Windows.
pub trait MonitorIdExt {
/// Returns the name of the monitor specific to the Win32 API.
/// Returns the name of the monitor adapter specific to the Win32 API.
fn native_id(&self) -> String;
/// Returns the handle of the monitor - `HMONITOR`.
fn hmonitor(&self) -> *mut c_void;
}
impl MonitorIdExt for MonitorId {
@@ -46,4 +50,9 @@ impl MonitorIdExt for MonitorId {
fn native_id(&self) -> String {
self.inner.get_native_identifier()
}
#[inline]
fn hmonitor(&self) -> *mut c_void {
self.inner.get_hmonitor() as *mut _
}
}