diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b536dba..a4f731e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/platform/linux/x11/monitor.rs b/src/platform/linux/x11/monitor.rs index 76293c78..66a81bfd 100644 --- a/src/platform/linux/x11/monitor.rs +++ b/src/platform/linux/x11/monitor.rs @@ -75,13 +75,10 @@ pub fn get_available_monitors(x: &Arc) -> Vec { #[inline] pub fn get_primary_monitor(x: &Arc) -> 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 {