mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
Fix no primary monitor panic in XWayland (#318)
* Fix no primary monitor panic in XWayland In this case try to use the first existing monitor instead of panicking. Fixes #317 * Shift no monitor panic to x11::get_primary_monitor * Update changelog with xll get_primary_monitor fallback
This commit is contained in:
parent
36058ab8e6
commit
b3c5ee6219
|
@ -13,6 +13,7 @@
|
|||
`EnumDisplayDevices`. This changes the value returned by `MonitorId::get_name()`.
|
||||
- On Windows added `MonitorIdExt::hmonitor` method
|
||||
- Impl `Clone` for `EventsLoopProxy`
|
||||
- `EventsLoop::get_primary_monitor()` on X11 will fallback to any available monitor if no primary is found
|
||||
|
||||
# Version 0.8.3 (2017-10-11)
|
||||
|
||||
|
|
|
@ -75,13 +75,10 @@ pub fn get_available_monitors(x: &Arc<XConnection>) -> Vec<MonitorId> {
|
|||
|
||||
#[inline]
|
||||
pub fn get_primary_monitor(x: &Arc<XConnection>) -> MonitorId {
|
||||
for monitor in get_available_monitors(x) {
|
||||
if monitor.primary {
|
||||
return monitor.clone()
|
||||
}
|
||||
}
|
||||
|
||||
panic!("[winit] Failed to find the primary monitor")
|
||||
get_available_monitors(x).into_iter().find(|m| m.primary)
|
||||
// 'no primary' case is better handled picking some existing monitor
|
||||
.or_else(|| get_available_monitors(x).into_iter().next())
|
||||
.expect("[winit] Failed to find any x11 monitor")
|
||||
}
|
||||
|
||||
impl MonitorId {
|
||||
|
|
Loading…
Reference in a new issue