@@ -1122,12 +1122,18 @@ impl UnownedWindow {
11221122 // does not take a screen parameter, but uses the current screen)
11231123 if let Some ( ref fullscreen) = fullscreen {
11241124 let new_screen = match fullscreen {
1125- Fullscreen :: Borderless ( borderless) => {
1126- let RootMonitorHandle { inner : monitor } = borderless
1127- . clone ( )
1128- . unwrap_or_else ( || self . current_monitor_inner ( ) ) ;
1125+ Fullscreen :: Borderless ( Some ( borderless) ) => {
1126+ let RootMonitorHandle { inner : monitor } = borderless. clone ( ) ;
11291127 monitor
11301128 }
1129+ Fullscreen :: Borderless ( None ) => {
1130+ if let Some ( current) = self . current_monitor_inner ( ) {
1131+ let RootMonitorHandle { inner : monitor } = current;
1132+ monitor
1133+ } else {
1134+ return ;
1135+ }
1136+ }
11311137 Fullscreen :: Exclusive ( RootVideoMode {
11321138 video_mode : VideoMode { ref monitor, .. } ,
11331139 } ) => monitor. clone ( ) ,
@@ -1399,22 +1405,22 @@ impl UnownedWindow {
13991405
14001406 #[ inline]
14011407 // Allow directly accessing the current monitor internally without unwrapping.
1402- pub ( crate ) fn current_monitor_inner ( & self ) -> RootMonitorHandle {
1408+ pub ( crate ) fn current_monitor_inner ( & self ) -> Option < RootMonitorHandle > {
14031409 unsafe {
1404- let screen: Retained < NSScreen > = msg_send ! [ & self . ns_window, screen] ;
1410+ let screen: Retained < NSScreen > = self . ns_window . screen ( ) ? ;
14051411 let desc = NSScreen :: deviceDescription ( & screen) ;
14061412 let key = NSString :: from_str ( "NSScreenNumber" ) ;
14071413 let value = NSDictionary :: objectForKey ( & desc, & key) . unwrap ( ) ;
14081414 let display_id: NSUInteger = msg_send ! [ & value, unsignedIntegerValue] ;
1409- RootMonitorHandle {
1415+ Some ( RootMonitorHandle {
14101416 inner : MonitorHandle :: new ( display_id. try_into ( ) . unwrap ( ) ) ,
1411- }
1417+ } )
14121418 }
14131419 }
14141420
14151421 #[ inline]
14161422 pub fn current_monitor ( & self ) -> Option < RootMonitorHandle > {
1417- Some ( self . current_monitor_inner ( ) )
1423+ self . current_monitor_inner ( )
14181424 }
14191425 #[ inline]
14201426 pub fn monitor_from_point ( & self , x : f64 , y : f64 ) -> Option < RootMonitorHandle > {
0 commit comments