@@ -1140,18 +1140,12 @@ - (void)windowDidChangeScreen:(NSNotification *)aNotification
11401140- (void )windowWillEnterFullScreen : (NSNotification *)aNotification
11411141{
11421142 SDL_Window *window = _data.window ;
1143- NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
1143+ const NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable | NSWindowStyleMaskTitled ;
11441144
1145- /* Don't set the titled flag on a fullscreen window if the windowed-mode window
1146- * is borderless, or the window can wind up in a weird, pseudo-decorated state
1147- * when leaving fullscreen if the border flag was toggled on .
1145+ /* For some reason, the fullscreen window won't get any mouse button events
1146+ * without the NSWindowStyleMaskTitled flag being set when entering fullscreen,
1147+ * so it's needed even if the window is borderless .
11481148 */
1149- if (!(window->flags & SDL_WINDOW_BORDERLESS)) {
1150- flags |= NSWindowStyleMaskTitled;
1151- } else {
1152- flags |= NSWindowStyleMaskBorderless;
1153- }
1154-
11551149 SetWindowStyle (window, flags);
11561150
11571151 _data.was_zoomed = !!(window->flags & SDL_WINDOW_MAXIMIZED);
@@ -1212,24 +1206,31 @@ - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
12121206
12131207- (void )windowWillExitFullScreen : (NSNotification *)aNotification
12141208{
1209+ SDL_Window *window = _data.window ;
1210+
1211+ /* If the windowed mode borders were toggled on while in a fullscreen space,
1212+ * NSWindowStyleMaskTitled has to be cleared here, or the window can end up
1213+ * in a weird, semi-decorated state upon returning to windowed mode.
1214+ */
1215+ if (_data.border_toggled && !(window->flags & SDL_WINDOW_BORDERLESS)) {
1216+ const NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
1217+
1218+ SetWindowStyle (window, flags);
1219+ _data.border_toggled = SDL_FALSE;
1220+ }
1221+
12151222 isFullscreenSpace = NO ;
12161223 inFullscreenTransition = YES ;
12171224}
12181225
12191226- (void )windowDidFailToExitFullScreen : (NSNotification *)aNotification
12201227{
12211228 SDL_Window *window = _data.window ;
1222- NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
1229+ const NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
12231230
12241231 if (window->is_destroying ) {
12251232 return ;
12261233 }
1227-
1228- if (!(window->flags & SDL_WINDOW_BORDERLESS)) {
1229- flags |= NSWindowStyleMaskTitled;
1230- } else {
1231- flags |= NSWindowStyleMaskBorderless;
1232- }
12331234
12341235 SetWindowStyle (window, flags);
12351236
@@ -2455,6 +2456,8 @@ void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_boo
24552456 Cocoa_SetWindowTitle (_this, window); /* this got blanked out. */
24562457 }
24572458 }
2459+ } else {
2460+ data.border_toggled = SDL_TRUE;
24582461 }
24592462 }
24602463}
0 commit comments