Make 'primary_monitor' return 'Option<MonitorHandle>'

Certain platforms like Wayland don't have a concept of
primary Monitor in particular. To indicate that
'primary_monitor' will return 'None' as well as in cases
where the primary monitor can't be detected.

Fixes #1683.
This commit is contained in:
Kirill Chibisov 2020-09-07 20:20:47 +03:00 committed by GitHub
parent cac627ed05
commit d103dc2631
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 86 additions and 56 deletions

View file

@ -12,6 +12,7 @@ use cocoa::{
use crate::{
event::Event,
event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootWindowTarget},
monitor::MonitorHandle as RootMonitorHandle,
platform_impl::platform::{
app::APP_CLASS,
app_delegate::APP_DELEGATE_CLASS,
@ -41,8 +42,9 @@ impl<T: 'static> EventLoopWindowTarget<T> {
}
#[inline]
pub fn primary_monitor(&self) -> MonitorHandle {
monitor::primary_monitor()
pub fn primary_monitor(&self) -> Option<RootMonitorHandle> {
let monitor = monitor::primary_monitor();
Some(RootMonitorHandle { inner: monitor })
}
}