aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-04-12 09:32:25 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-04-12 09:32:25 +0200
commitb81cd0cd2f734fe33623ef04ef67831a8d0099a2 (patch)
tree3aa080e1244ed69ef6c1636a91cbeba29c9eee7e /src/win32
parent70d36a3d3d6afba3e89faf4d3979118f9c076fe9 (diff)
downloadglutin-b81cd0cd2f734fe33623ef04ef67831a8d0099a2.tar.gz
glutin-b81cd0cd2f734fe33623ef04ef67831a8d0099a2.zip
Fix get_primary_monitor on win32
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/monitor.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/win32/monitor.rs b/src/win32/monitor.rs
index 886d0bf..4b592cb 100644
--- a/src/win32/monitor.rs
+++ b/src/win32/monitor.rs
@@ -21,6 +21,9 @@ pub struct MonitorID {
/// http://msdn.microsoft.com/en-us/library/dd183569(v=vs.85).aspx
flags: winapi::DWORD,
+ /// True if this is the primary monitor.
+ primary: bool,
+
/// The position of the monitor in pixels on the desktop.
///
/// A window that is positionned at these coordinates will overlap the monitor.
@@ -114,13 +117,15 @@ pub fn get_available_monitors() -> VecDeque<MonitorID> {
(position, dimensions)
};
- for monitor in DeviceEnumerator::monitors(adapter.DeviceName.as_ptr()) {
+ for (num, monitor) in DeviceEnumerator::monitors(adapter.DeviceName.as_ptr()).enumerate() {
// adding to the resulting list
result.push_back(MonitorID {
adapter_name: adapter.DeviceName,
monitor_name: wchar_as_string(&monitor.DeviceName),
readable_name: wchar_as_string(&monitor.DeviceString),
flags: monitor.StateFlags,
+ primary: (adapter.StateFlags & winapi::DISPLAY_DEVICE_PRIMARY_DEVICE) != 0 &&
+ num == 0,
position: position,
dimensions: dimensions,
});
@@ -135,8 +140,8 @@ pub fn get_primary_monitor() -> MonitorID {
// TODO: it is possible to query the win32 API for the primary monitor, this should be done
// instead
for monitor in get_available_monitors().into_iter() {
- if (monitor.flags & winapi::DISPLAY_DEVICE_PRIMARY_DEVICE) != 0 {
- return monitor
+ if monitor.primary {
+ return monitor;
}
}