Make 'current_monitor' return 'Option<MonitorHandle>'
On certain platforms window couldn't be on any monitor resulting in failures of 'current_monitor' function. Such issue was happening on Wayland, since the window isn't on any monitor, unless the user has drawn something into it. Returning 'Option<MonitorHandle>' will give an ability to handle such situations gracefully by properly indicating that there's no current monitor. Fixes #793.
This commit is contained in:
parent
e2cf2a5754
commit
cac627ed05
12 changed files with 65 additions and 29 deletions
|
|
@ -736,13 +736,15 @@ impl Window {
|
|||
|
||||
/// Monitor info functions.
|
||||
impl Window {
|
||||
/// Returns the monitor on which the window currently resides
|
||||
/// Returns the monitor on which the window currently resides.
|
||||
///
|
||||
/// Returns `None` if current monitor can't be detected.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// **iOS:** Can only be called on the main thread.
|
||||
#[inline]
|
||||
pub fn current_monitor(&self) -> MonitorHandle {
|
||||
pub fn current_monitor(&self) -> Option<MonitorHandle> {
|
||||
self.window.current_monitor()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue