Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off.
authorSam Lantinga <slouken@libsdl.org>
Fri, 11 Feb 2011 00:25:44 -0800
changeset 5249 7a963be087ef
parent 5248 ff2564c24045
child 5250 f908e06b3c96
Mostly fixed fullscreen mode on Mac OS X, and you can toggle it on and off. There are still some problems with the ConvertNSRect() calculations when switching video modes, which causes wierd window positioning issues, and the fullscreen window is still minimized on exit.
src/events/SDL_windowevents.c
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/android/SDL_androidwindow.c
src/video/cocoa/SDL_cocoamodes.m
src/video/cocoa/SDL_cocoaopengl.h
src/video/cocoa/SDL_cocoaopengl.m
src/video/cocoa/SDL_cocoavideo.m
src/video/cocoa/SDL_cocoawindow.h
src/video/cocoa/SDL_cocoawindow.m
src/video/uikit/SDL_uikitwindow.m
--- a/src/events/SDL_windowevents.c	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/events/SDL_windowevents.c	Fri Feb 11 00:25:44 2011 -0800
@@ -82,24 +82,35 @@
         SDL_OnWindowHidden(window);
         break;
     case SDL_WINDOWEVENT_MOVED:
-        if (window->flags & SDL_WINDOW_FULLSCREEN) {
+        if (SDL_WINDOWPOS_ISUNDEFINED(data1) ||
+            SDL_WINDOWPOS_ISUNDEFINED(data2)) {
             return 0;
         }
-        if (data1 == SDL_WINDOWPOS_UNDEFINED) {
-            data1 = window->x;
-        }
-        if (data2 == SDL_WINDOWPOS_UNDEFINED) {
-            data2 = window->y;
+        if (window->flags & SDL_WINDOW_FULLSCREEN) {
+            window->fullscreen.x = data1;
+            window->fullscreen.y = data1;
+        } else {
+            window->windowed.x = data1;
+            window->windowed.y = data1;
         }
         if (data1 == window->x && data2 == window->y) {
             return 0;
         }
         window->x = data1;
         window->y = data2;
+
+        if (window->flags & SDL_WINDOW_FULLSCREEN) {
+            /* Do we really want to do this? */
+            return 0;
+        }
         break;
     case SDL_WINDOWEVENT_RESIZED:
         if (window->flags & SDL_WINDOW_FULLSCREEN) {
-            return 0;
+            window->fullscreen.w = data1;
+            window->fullscreen.h = data1;
+        } else {
+            window->windowed.w = data1;
+            window->windowed.h = data1;
         }
         if (data1 == window->w && data2 == window->h) {
             return 0;
@@ -107,6 +118,11 @@
         window->w = data1;
         window->h = data2;
         SDL_OnWindowResized(window);
+
+        if (window->flags & SDL_WINDOW_FULLSCREEN) {
+            /* Do we really want to do this? */
+            return 0;
+        }
         break;
     case SDL_WINDOWEVENT_MINIMIZED:
         if (window->flags & SDL_WINDOW_MINIMIZED) {
--- a/src/render/opengles/SDL_render_gles.c	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/render/opengles/SDL_render_gles.c	Fri Feb 11 00:25:44 2011 -0800
@@ -40,9 +40,6 @@
 
 /* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
 
-/* Used to re-create the window with OpenGL capability */
-extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
-
 static const float inv255f = 1.0f / 255.0f;
 
 static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags);
@@ -146,14 +143,6 @@
     SDL_Renderer *renderer;
     GLES_RenderData *data;
     GLint value;
-    Uint32 window_flags;
-
-    window_flags = SDL_GetWindowFlags(window);
-    if (!(window_flags & SDL_WINDOW_OPENGL)) {
-        if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
-            return NULL;
-        }
-    }
 
     renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
--- a/src/render/opengles2/SDL_render_gles2.c	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/render/opengles2/SDL_render_gles2.c	Fri Feb 11 00:25:44 2011 -0800
@@ -1085,27 +1085,16 @@
 
 #define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B
 
-/* Used to re-create the window with OpenGL capability */
-extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
-
 static SDL_Renderer *
 GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
 {
     SDL_Renderer *renderer;
     GLES2_DriverContext *rdata;
-    Uint32 window_flags;
     GLint nFormats;
 #ifndef ZUNE_HD
     GLboolean hasCompiler;
 #endif
 
-    window_flags = SDL_GetWindowFlags(window);
-    if (!(window_flags & SDL_WINDOW_OPENGL)) {
-        if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
-            return NULL;
-        }
-    }
-
     /* Create the renderer struct */
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer));
     if (!renderer) {
--- a/src/video/SDL_sysvideo.h	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/SDL_sysvideo.h	Fri Feb 11 00:25:44 2011 -0800
@@ -72,6 +72,20 @@
     const void *magic;
     Uint32 id;
     char *title;
+
+    /* The fullscreen values */
+    struct {
+        int x, y;
+        int w, h;
+    } fullscreen;
+
+    /* The windowed values */
+    struct {
+        int x, y;
+        int w, h;
+    } windowed;
+
+    /* The public values */
     int x, y;
     int w, h;
     Uint32 flags;
@@ -106,7 +120,6 @@
     SDL_DisplayMode *display_modes;
     SDL_DisplayMode desktop_mode;
     SDL_DisplayMode current_mode;
-    SDL_bool updating_fullscreen;
 
     SDL_Window *fullscreen_window;
 
@@ -178,6 +191,8 @@
     void (*MaximizeWindow) (_THIS, SDL_Window * window);
     void (*MinimizeWindow) (_THIS, SDL_Window * window);
     void (*RestoreWindow) (_THIS, SDL_Window * window);
+    void (*PrepWindowFullscreen) (_THIS, SDL_Window * window);
+    void (*SetWindowFullscreen) (_THIS, SDL_Window * window);
     void (*SetWindowGrab) (_THIS, SDL_Window * window);
     void (*DestroyWindow) (_THIS, SDL_Window * window);
     int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
--- a/src/video/SDL_video.c	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/SDL_video.c	Fri Feb 11 00:25:44 2011 -0800
@@ -600,21 +600,21 @@
         SDL_VideoDisplay *display = &_this->displays[displayIndex];
 
         if (_this->GetDisplayBounds) {
-            if (_this->GetDisplayBounds(_this, display, rect) < 0) {
-                return -1;
+            if (_this->GetDisplayBounds(_this, display, rect) == 0) {
+                return 0;
             }
+        }
+
+        /* Assume that the displays are left to right */
+        if (displayIndex == 0) {
+            rect->x = 0;
+            rect->y = 0;
         } else {
-            /* Assume that the displays are left to right */
-            if (displayIndex == 0) {
-                rect->x = 0;
-                rect->y = 0;
-            } else {
-                SDL_GetDisplayBounds(displayIndex-1, rect);
-                rect->x += rect->w;
-            }
-            rect->w = display->desktop_mode.w;
-            rect->h = display->desktop_mode.h;
+            SDL_GetDisplayBounds(displayIndex-1, rect);
+            rect->x += rect->w;
         }
+        rect->w = display->desktop_mode.w;
+        rect->h = display->desktop_mode.h;
     }
     return 0;
 }
@@ -1016,14 +1016,13 @@
 SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt)
 {
     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
+    SDL_Window *other;
 
-    /* See if we're already processing a window */
-    if (display->updating_fullscreen) {
+    /* See if anything changed */
+    if ((display->fullscreen_window == window) == attempt) {
         return;
     }
 
-    display->updating_fullscreen = SDL_TRUE;
-
     /* See if we even want to do anything here */
     if ((window->flags & SDL_WINDOW_FULLSCREEN) &&
         (window->flags & SDL_WINDOW_SHOWN)) {
@@ -1042,29 +1041,52 @@
 
     if (FULLSCREEN_VISIBLE(window)) {
         /* Hide any other fullscreen windows */
-        if (display->fullscreen_window != window) {
+        if (display->fullscreen_window &&
+            display->fullscreen_window != window) {
             SDL_MinimizeWindow(display->fullscreen_window);
         }
     }
 
-    display->updating_fullscreen = SDL_FALSE;
+    /* See if there are any fullscreen windows */
+    for (other = _this->windows; other; other = other->next) {
+        if (FULLSCREEN_VISIBLE(other) &&
+            SDL_GetDisplayForWindow(other) == display) {
+            SDL_DisplayMode fullscreen_mode;
+            if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) {
+                if (_this->PrepWindowFullscreen) {
+                    _this->PrepWindowFullscreen(_this, other);
+                }
 
-    /* See if there are any fullscreen windows */
-    for (window = _this->windows; window; window = window->next) {
-        if (FULLSCREEN_VISIBLE(window) &&
-            SDL_GetDisplayForWindow(window) == display) {
-            SDL_DisplayMode fullscreen_mode;
-            if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
                 SDL_SetDisplayModeForDisplay(display, &fullscreen_mode);
-                display->fullscreen_window = window;
+
+                if (_this->SetWindowFullscreen) {
+                    _this->SetWindowFullscreen(_this, other);
+                }
+                display->fullscreen_window = other;
+
+                /* Generate a mode change events here */
+                SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
+                                    fullscreen_mode.w, fullscreen_mode.h);
                 return;
             }
         }
     }
 
     /* Nope, restore the desktop mode */
+    if (_this->PrepWindowFullscreen) {
+        _this->PrepWindowFullscreen(_this, window);
+    }
+
     SDL_SetDisplayModeForDisplay(display, NULL);
+
+    if (_this->SetWindowFullscreen) {
+        _this->SetWindowFullscreen(_this, window);
+    }
     display->fullscreen_window = NULL;
+
+    /* Generate a mode change events here */
+    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED,
+                        window->windowed.w, window->windowed.h);
 }
 
 SDL_Window *
@@ -1084,6 +1106,11 @@
             return NULL;
         }
     }
+
+    /* Some platforms have OpenGL enabled by default */
+#if (SDL_VIDEO_OPENGL && __MACOSX__) || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
+    flags |= SDL_WINDOW_OPENGL;
+#endif
     if (flags & SDL_WINDOW_OPENGL) {
         if (!_this->GL_CreateContext) {
             SDL_SetError("No OpenGL support in video driver");
@@ -1169,13 +1196,6 @@
         SDL_SetError("No OpenGL support in video driver");
         return -1;
     }
-    if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) {
-        if (flags & SDL_WINDOW_OPENGL) {
-            SDL_GL_LoadLibrary(NULL);
-        } else {
-            SDL_GL_UnloadLibrary();
-        }
-    }
 
     if (window->flags & SDL_WINDOW_FOREIGN) {
         /* Can't destroy and re-create foreign windows, hrm */
@@ -1184,10 +1204,29 @@
         flags &= ~SDL_WINDOW_FOREIGN;
     }
 
+    /* Restore video mode, etc. */
+    SDL_UpdateFullscreenMode(window, SDL_FALSE);
+
+    /* Tear down the old native window */
+    if (window->surface) {
+        window->surface->refcount = 0;
+        SDL_FreeSurface(window->surface);
+    }
+    if (_this->DestroyWindowFramebuffer) {
+        _this->DestroyWindowFramebuffer(_this, window);
+    }
     if (_this->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) {
         _this->DestroyWindow(_this, window);
     }
 
+    if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) {
+        if (flags & SDL_WINDOW_OPENGL) {
+            SDL_GL_LoadLibrary(NULL);
+        } else {
+            SDL_GL_UnloadLibrary();
+        }
+    }
+
     window->title = NULL;
     window->flags = (flags & allowed_flags);
 
@@ -1396,13 +1435,13 @@
 {
     CHECK_WINDOW_MAGIC(window, );
 
-    window->w = w;
-    window->h = h;
-
-    if (_this->SetWindowSize) {
-        _this->SetWindowSize(_this, window);
+    /* FIXME: Should this change fullscreen modes? */
+    if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
+        if (_this->SetWindowSize) {
+            _this->SetWindowSize(_this, window);
+        }
+        SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, w, h);
     }
-    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, w, h);
 }
 
 void
--- a/src/video/android/SDL_androidwindow.c	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/android/SDL_androidwindow.c	Fri Feb 11 00:25:44 2011 -0800
@@ -42,7 +42,6 @@
     window->h = Android_ScreenHeight;
 
     window->flags &= ~SDL_WINDOW_RESIZABLE;     /* window is NEVER resizeable */
-    window->flags |= SDL_WINDOW_OPENGL;         /* window is always OpenGL */
     window->flags |= SDL_WINDOW_FULLSCREEN;     /* window is always fullscreen */
     window->flags |= SDL_WINDOW_SHOWN;          /* only one window on Android */
     window->flags |= SDL_WINDOW_INPUT_FOCUS;    /* always has input focus */    
--- a/src/video/cocoa/SDL_cocoamodes.m	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/cocoa/SDL_cocoamodes.m	Fri Feb 11 00:25:44 2011 -0800
@@ -299,19 +299,6 @@
         CGReleaseDisplayFadeReservation(fade_token);
     }
 
-    [[NSApp mainWindow] makeKeyAndOrderFront: nil];
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
-    /* 
-        There is a bug in Cocoa where NSScreen doesn't synchronize
-        with CGDirectDisplay, so the main screen's frame is wrong.
-        As a result, coordinate translation produces incorrect results.
-        We can hack around this bug by setting the screen rect
-        ourselves. This hack should be removed if/when the bug is fixed.
-    */
-    [[NSScreen mainScreen] setFrame:NSMakeRect(0,0,mode->w,mode->h)]; 
-#endif
-
     return 0;
 
     /* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */
--- a/src/video/cocoa/SDL_cocoaopengl.h	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/cocoa/SDL_cocoaopengl.h	Fri Feb 11 00:25:44 2011 -0800
@@ -26,6 +26,9 @@
 
 #if SDL_VIDEO_OPENGL_CGL
 
+/* Define this if you want to be able to toggle fullscreen mode seamlessly */
+#define FULLSCREEN_TOGGLEABLE
+
 struct SDL_GLDriverData
 {
     int initialized;
--- a/src/video/cocoa/SDL_cocoaopengl.m	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/cocoa/SDL_cocoaopengl.m	Fri Feb 11 00:25:44 2011 -0800
@@ -81,9 +81,11 @@
 
     pool = [[NSAutoreleasePool alloc] init];
 
+#ifndef FULLSCREEN_TOGGLEABLE
     if (window->flags & SDL_WINDOW_FULLSCREEN) {
         attr[i++] = NSOpenGLPFAFullScreen;
     }
+#endif
 
     attr[i++] = NSOpenGLPFAColorSize;
     attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
@@ -199,9 +201,12 @@
         SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
         NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
 
+#ifndef FULLSCREEN_TOGGLEABLE
         if (window->flags & SDL_WINDOW_FULLSCREEN) {
             [nscontext setFullScreen];
-        } else {
+        } else
+#endif
+        {
             [nscontext setView:[windowdata->nswindow contentView]];
             [nscontext update];
         }
--- a/src/video/cocoa/SDL_cocoavideo.m	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/cocoa/SDL_cocoavideo.m	Fri Feb 11 00:25:44 2011 -0800
@@ -90,6 +90,7 @@
     device->MaximizeWindow = Cocoa_MaximizeWindow;
     device->MinimizeWindow = Cocoa_MinimizeWindow;
     device->RestoreWindow = Cocoa_RestoreWindow;
+    device->SetWindowFullscreen = Cocoa_SetWindowFullscreen;
     device->SetWindowGrab = Cocoa_SetWindowGrab;
     device->DestroyWindow = Cocoa_DestroyWindow;
     device->GetWindowWMInfo = Cocoa_GetWindowWMInfo;
--- a/src/video/cocoa/SDL_cocoawindow.h	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.h	Fri Feb 11 00:25:44 2011 -0800
@@ -102,6 +102,7 @@
 extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window);
 extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
 extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
+extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window);
 extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window);
 extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
 extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window,
--- a/src/video/cocoa/SDL_cocoawindow.m	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Feb 11 00:25:44 2011 -0800
@@ -398,6 +398,22 @@
 
 @end
 
+static unsigned int
+GetStyleMask(SDL_Window * window)
+{
+    unsigned int style;
+
+    if (window->flags & SDL_WINDOW_BORDERLESS) {
+        style = NSBorderlessWindowMask;
+    } else {
+        style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
+    }
+    if (window->flags & SDL_WINDOW_RESIZABLE) {
+        style |= NSResizableWindowMask;
+    }
+    return style;
+}
+
 static int
 SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
 {
@@ -406,7 +422,7 @@
     SDL_WindowData *data;
 
     /* Allocate the window data */
-    data = (SDL_WindowData *) SDL_malloc(sizeof(*data));
+    data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
     if (!data) {
         SDL_OutOfMemory();
         return -1;
@@ -424,7 +440,6 @@
 
     /* Fill in the SDL window with the window data */
     {
-        SDL_Rect bounds;
         NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
         NSView *contentView = [[SDLView alloc] initWithFrame: rect
                                                     listener: data->listener];
@@ -495,16 +510,14 @@
     unsigned int style;
 
     Cocoa_GetDisplayBounds(_this, display, &bounds);
-    if ((window->flags & SDL_WINDOW_FULLSCREEN)
-        || SDL_WINDOWPOS_ISCENTERED(window->x)) {
+    if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
         rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
     } else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
         rect.origin.x = bounds.x;
     } else {
         rect.origin.x = window->x;
     }
-    if ((window->flags & SDL_WINDOW_FULLSCREEN)
-        || SDL_WINDOWPOS_ISCENTERED(window->y)) {
+    if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
         rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
     } else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
         rect.origin.y = bounds.y;
@@ -515,14 +528,7 @@
     rect.size.height = window->h;
     ConvertNSRect(&rect);
 
-    if (window->flags & SDL_WINDOW_BORDERLESS) {
-        style = NSBorderlessWindowMask;
-    } else {
-        style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
-    }
-    if (window->flags & SDL_WINDOW_RESIZABLE) {
-        style |= NSResizableWindowMask;
-    }
+    style = GetStyleMask(window);
 
     /* Figure out which screen to place this window */
     NSArray *screens = [NSScreen screens];
@@ -600,14 +606,12 @@
     SDL_Rect bounds;
 
     Cocoa_GetDisplayBounds(_this, display, &bounds);
-    if ((window->flags & SDL_WINDOW_FULLSCREEN)
-        || SDL_WINDOWPOS_ISCENTERED(window->x)) {
+    if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
         rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
     } else {
         rect.origin.x = window->x;
     }
-    if ((window->flags & SDL_WINDOW_FULLSCREEN)
-        || SDL_WINDOWPOS_ISCENTERED(window->y)) {
+    if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
         rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
     } else {
         rect.origin.y = window->y;
@@ -700,6 +704,56 @@
 }
 
 void
+Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window)
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    NSWindow *nswindow = data->nswindow;
+    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
+    NSRect rect;
+    unsigned int style;
+
+    if (FULLSCREEN_VISIBLE(window)) {
+        SDL_Rect bounds;
+
+        Cocoa_GetDisplayBounds(_this, display, &bounds);
+        rect.origin.x = bounds.x;
+        rect.origin.y = bounds.y;
+        rect.size.width = bounds.w;
+        rect.size.height = bounds.h;
+        ConvertNSRect(&rect);
+
+        style = NSBorderlessWindowMask;
+    } else {
+        rect.origin.x = window->windowed.x;
+        rect.origin.y = window->windowed.y;
+        rect.size.width = window->windowed.w;
+        rect.size.height = window->windowed.h;
+        /* FIXME: This calculation is wrong, we're changing the origin */
+        ConvertNSRect(&rect);
+
+        style = GetStyleMask(window);
+    }
+
+    [nswindow setStyleMask:style];
+    [nswindow setContentSize:rect.size];
+    rect = [nswindow frameRectForContentRect:rect];
+    [nswindow setFrameOrigin:rect.origin];
+
+#ifdef FULLSCREEN_TOGGLEABLE
+    if (FULLSCREEN_VISIBLE(window)) {
+        /* OpenGL is rendering to the window, so make it visible! */
+        [nswindow setLevel:CGShieldingWindowLevel()];
+    } else {
+        [nswindow setLevel:kCGNormalWindowLevel];
+    }
+#endif
+    [nswindow makeKeyAndOrderFront:nil];
+
+    [pool release];
+}
+
+void
 Cocoa_SetWindowGrab(_THIS, SDL_Window * window)
 {
     if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
--- a/src/video/uikit/SDL_uikitwindow.m	Thu Feb 10 22:49:14 2011 -0800
+++ b/src/video/uikit/SDL_uikitwindow.m	Fri Feb 11 00:25:44 2011 -0800
@@ -64,7 +64,6 @@
     window->driverdata = data;
     
     window->flags &= ~SDL_WINDOW_RESIZABLE;        /* window is NEVER resizeable */
-    window->flags |= SDL_WINDOW_OPENGL;            /* window is always OpenGL */
     window->flags |= SDL_WINDOW_FULLSCREEN;        /* window is always fullscreen */
     window->flags |= SDL_WINDOW_SHOWN;            /* only one window on iPod touch, always shown */
     window->flags |= SDL_WINDOW_INPUT_FOCUS;    /* always has input focus */