Fixed bug 1141
authorSam Lantinga <slouken@libsdl.org>
Sat, 26 Feb 2011 11:29:23 -0800
changeset 5400 1df8b8a20191
parent 5399 1e2a82a66df8
child 5401 ccaccc76a196
Fixed bug 1141 Rebuild the window with the new style on older versions of Mac OS X.
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoawindow.m	Sat Feb 26 10:15:13 2011 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.m	Sat Feb 26 11:29:23 2011 -0800
@@ -787,6 +787,24 @@
     [pool release];
 }
 
+static NSWindow *
+Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style)
+{
+    if (!data->created) {
+        /* Don't mess with other people's windows... */
+        return nswindow;
+    }
+
+    [data->listener close];
+    data->nswindow = [[SDLWindow alloc] initWithContentRect:[[nswindow contentView] frame] styleMask:style backing:NSBackingStoreBuffered defer:YES screen:[nswindow screen]];
+    [data->nswindow setContentView:[nswindow contentView]];
+    [data->listener listen:data];
+
+    [nswindow close];
+
+    return data->nswindow;
+}
+
 void
 Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
 {
@@ -807,6 +825,8 @@
 
         if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
             [nswindow performSelector: @selector(setStyleMask:) withObject: (id)NSBorderlessWindowMask];
+        } else {
+            nswindow = Cocoa_RebuildWindow(data, nswindow, NSBorderlessWindowMask);
         }
     } else {
         rect.origin.x = window->windowed.x;
@@ -817,6 +837,8 @@
 
         if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
             [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];
+        } else {
+            nswindow = Cocoa_RebuildWindow(data, nswindow, GetWindowStyle(window));
         }
     }