From: Trent G. <tr...@us...> - 2014-03-20 08:44:14
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Allegro". The branch, 5.1 has been updated via 830bcab76949a0e2b77dc96fafad26ea02e38c0e (commit) from 724c6621459332630cf90d43707e7ceb8a085472 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 830bcab76949a0e2b77dc96fafad26ea02e38c0e Author: Trent Gamblin <tr...@us...> Date: Thu Mar 20 02:43:58 2014 -0600 Make real fullscreen modes work on OS X again. May not be perfect still. Thanks SDL. ----------------------------------------------------------------------- Summary of changes: src/macosx/osxgl.h | 9 +++++---- src/macosx/osxgl.m | 32 ++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/macosx/osxgl.h b/src/macosx/osxgl.h index f781c51..0006eec 100644 --- a/src/macosx/osxgl.h +++ b/src/macosx/osxgl.h @@ -13,17 +13,18 @@ /* This is our version of ALLEGRO_DISPLAY with driver specific extra data. */ typedef struct ALLEGRO_DISPLAY_OSX_WIN { - ALLEGRO_DISPLAY parent; - int depth; - NSOpenGLContext* ctx; + ALLEGRO_DISPLAY parent; + int depth; + NSOpenGLContext* ctx; NSOpenGLPixelFormatAttribute attributes[AL_OSX_NUM_PFA]; - NSWindow* win; + NSWindow* win; NSCursor* cursor; CGDirectDisplayID display_id; BOOL show_cursor; NSTrackingArea *tracking; unsigned int display_group; BOOL in_fullscreen; + CGDisplayModeRef original_mode; } ALLEGRO_DISPLAY_OSX_WIN; /* This is our version of ALLEGRO_MOUSE_CURSOR */ diff --git a/src/macosx/osxgl.m b/src/macosx/osxgl.m index e815224..1c171d0 100644 --- a/src/macosx/osxgl.m +++ b/src/macosx/osxgl.m @@ -967,6 +967,8 @@ static void osx_get_opengl_pixelformat_attributes(ALLEGRO_DISPLAY_OSX_WIN *dpy) [dpy->ctx clearDrawable]; // Unlock the screen if (dpy->parent.flags & ALLEGRO_FULLSCREEN) { + CGDisplaySetDisplayMode(dpy->display_id, dpy->original_mode, NULL); + CGDisplayModeRelease(dpy->original_mode); #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 if (dpy->win) { [[dpy->win contentView] exitFullScreenModeWithOptions: nil]; @@ -1080,6 +1082,12 @@ static ALLEGRO_DISPLAY* create_display_fs(int w, int h) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ALLEGRO_DEBUG("Switching to fullscreen mode sized %dx%d\n", w, h); + + int32_t system_version; + if (Gestalt(gestaltSystemVersion, &system_version) != noErr) + system_version = 0; + #define IS_LION (system_version >= 0x1070) + if (al_get_new_display_adapter() >= al_get_num_video_adapters()) { [pool drain]; return NULL; @@ -1133,7 +1141,6 @@ static ALLEGRO_DISPLAY* create_display_fs(int w, int h) [pool drain]; return NULL; } - [context makeCurrentContext]; dpy->ctx = context; // Prevent other apps from writing to this display and switch it to our @@ -1194,11 +1201,28 @@ static ALLEGRO_DISPLAY* create_display_fs(int w, int h) } /* Switch display mode */ - CFDictionaryRef options = CFDictionaryCreate(NULL, NULL, NULL, 0, NULL, NULL); + dpy->original_mode = CGDisplayCopyDisplayMode(dpy->display_id); + CGDisplayCapture(dpy->display_id); CGDisplaySetDisplayMode(dpy->display_id, mode, NULL); - CFRelease(options); #endif - [context setFullScreen]; + + NSRect rect = NSMakeRect(0, 0, w, h); + + dpy->win = [[NSWindow alloc] initWithContentRect:rect styleMask:(IS_LION ? NSBorderlessWindowMask : 0) backing:NSBackingStoreBuffered defer:NO]; + [dpy->win setAcceptsMouseMovedEvents:YES]; + [dpy->win setViewsNeedDisplay:NO]; + + NSView *window_view = [[NSView alloc] initWithFrame:rect]; + [window_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; + [[dpy->win contentView] addSubview:window_view]; + [dpy->win setLevel:CGShieldingWindowLevel()]; + [context setView:window_view]; + [context update]; + [window_view release]; + [context makeCurrentContext]; + [dpy->win setHasShadow:NO]; + [dpy->win setOpaque:YES]; + [dpy->win makeKeyAndOrderFront:nil]; // Set up the Allegro OpenGL implementation dpy->parent.ogl_extras = al_malloc(sizeof(ALLEGRO_OGL_EXTRAS)); hooks/post-receive -- Allegro |