From f26627460636401709f39e88ac5259348f262298 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 11 Feb 2011 00:25:44 -0800 Subject: [PATCH] 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 | 30 +++++-- src/render/opengles/SDL_render_gles.c | 11 --- src/render/opengles2/SDL_render_gles2.c | 11 --- src/video/SDL_sysvideo.h | 17 +++- src/video/SDL_video.c | 113 ++++++++++++++++-------- src/video/android/SDL_androidwindow.c | 1 - src/video/cocoa/SDL_cocoamodes.m | 13 --- src/video/cocoa/SDL_cocoaopengl.h | 3 + src/video/cocoa/SDL_cocoaopengl.m | 7 +- src/video/cocoa/SDL_cocoavideo.m | 1 + src/video/cocoa/SDL_cocoawindow.h | 1 + src/video/cocoa/SDL_cocoawindow.m | 90 +++++++++++++++---- src/video/uikit/SDL_uikitwindow.m | 1 - 13 files changed, 198 insertions(+), 101 deletions(-) diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index fa34034a2..22ec79454 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -82,24 +82,35 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, 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 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, 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) { diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index ef9ab9de5..8c08b0e43 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -40,9 +40,6 @@ glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) /* 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 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) 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) { diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 2da7c4a47..e22f943fd 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1085,27 +1085,16 @@ GLES2_RenderPresent(SDL_Renderer *renderer) #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) { diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 8ea2d26ae..95e39b0c0 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -72,6 +72,20 @@ struct SDL_Window 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 @@ struct SDL_VideoDisplay SDL_DisplayMode *display_modes; SDL_DisplayMode desktop_mode; SDL_DisplayMode current_mode; - SDL_bool updating_fullscreen; SDL_Window *fullscreen_window; @@ -178,6 +191,8 @@ struct SDL_VideoDevice 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); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index e73dcd8c4..bfa40dc6e 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -600,21 +600,21 @@ SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect) 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 @@ static void 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 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt) 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 (window = _this->windows; window; window = window->next) { - if (FULLSCREEN_VISIBLE(window) && - SDL_GetDisplayForWindow(window) == display) { + for (other = _this->windows; other; other = other->next) { + if (FULLSCREEN_VISIBLE(other) && + SDL_GetDisplayForWindow(other) == display) { SDL_DisplayMode fullscreen_mode; - if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) { + if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) { + if (_this->PrepWindowFullscreen) { + _this->PrepWindowFullscreen(_this, other); + } + 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 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) 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_RecreateWindow(SDL_Window * window, Uint32 flags) 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 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags) 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 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h) { 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 diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 263c4d5f0..824abd731 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -42,7 +42,6 @@ Android_CreateWindow(_THIS, SDL_Window * window) 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 */ diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index ddb762255..9f0158ba5 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -299,19 +299,6 @@ - (void) setFrame:(NSRect)frame; 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 */ diff --git a/src/video/cocoa/SDL_cocoaopengl.h b/src/video/cocoa/SDL_cocoaopengl.h index fc01329fa..b0a97bdbb 100644 --- a/src/video/cocoa/SDL_cocoaopengl.h +++ b/src/video/cocoa/SDL_cocoaopengl.h @@ -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; diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index f828a7346..ff185b8db 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -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]; } diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 78b1d7ee3..d64a76071 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -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; diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h index c5f5e5a38..77689c411 100644 --- a/src/video/cocoa/SDL_cocoawindow.h +++ b/src/video/cocoa/SDL_cocoawindow.h @@ -102,6 +102,7 @@ extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window); 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, diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 6e96dcd48..7b428e262 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -398,6 +398,22 @@ - (void)rightMouseDown:(NSEvent *)theEvent @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 @@ - (void)rightMouseDown:(NSEvent *)theEvent 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 @@ - (void)rightMouseDown:(NSEvent *)theEvent /* 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 @@ - (void)rightMouseDown:(NSEvent *)theEvent 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 @@ - (void)rightMouseDown:(NSEvent *)theEvent 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 @@ - (void)rightMouseDown:(NSEvent *)theEvent 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; @@ -699,6 +703,56 @@ - (void)rightMouseDown:(NSEvent *)theEvent [pool release]; } +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) { diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 9ebedd43b..52d64dd70 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -64,7 +64,6 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo 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 */