mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Fix get_primary_monitor on win32
This commit is contained in:
parent
70d36a3d3d
commit
b81cd0cd2f
|
@ -21,6 +21,9 @@ pub struct MonitorID {
|
||||||
/// http://msdn.microsoft.com/en-us/library/dd183569(v=vs.85).aspx
|
/// http://msdn.microsoft.com/en-us/library/dd183569(v=vs.85).aspx
|
||||||
flags: winapi::DWORD,
|
flags: winapi::DWORD,
|
||||||
|
|
||||||
|
/// True if this is the primary monitor.
|
||||||
|
primary: bool,
|
||||||
|
|
||||||
/// The position of the monitor in pixels on the desktop.
|
/// The position of the monitor in pixels on the desktop.
|
||||||
///
|
///
|
||||||
/// A window that is positionned at these coordinates will overlap the monitor.
|
/// 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)
|
(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
|
// adding to the resulting list
|
||||||
result.push_back(MonitorID {
|
result.push_back(MonitorID {
|
||||||
adapter_name: adapter.DeviceName,
|
adapter_name: adapter.DeviceName,
|
||||||
monitor_name: wchar_as_string(&monitor.DeviceName),
|
monitor_name: wchar_as_string(&monitor.DeviceName),
|
||||||
readable_name: wchar_as_string(&monitor.DeviceString),
|
readable_name: wchar_as_string(&monitor.DeviceString),
|
||||||
flags: monitor.StateFlags,
|
flags: monitor.StateFlags,
|
||||||
|
primary: (adapter.StateFlags & winapi::DISPLAY_DEVICE_PRIMARY_DEVICE) != 0 &&
|
||||||
|
num == 0,
|
||||||
position: position,
|
position: position,
|
||||||
dimensions: dimensions,
|
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
|
// TODO: it is possible to query the win32 API for the primary monitor, this should be done
|
||||||
// instead
|
// instead
|
||||||
for monitor in get_available_monitors().into_iter() {
|
for monitor in get_available_monitors().into_iter() {
|
||||||
if (monitor.flags & winapi::DISPLAY_DEVICE_PRIMARY_DEVICE) != 0 {
|
if monitor.primary {
|
||||||
return monitor
|
return monitor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue