Fixed fullscreen modes with Cocoa video driver.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402020
This commit is contained in:
parent
296ed89309
commit
1c97a53526
3 changed files with 59 additions and 8 deletions
|
@ -23,6 +23,24 @@
|
|||
|
||||
#include "SDL_cocoavideo.h"
|
||||
|
||||
/*
|
||||
Add methods to get at private members of NSScreen.
|
||||
Since there is a bug in Apple's screen switching code
|
||||
that does not update this variable when switching
|
||||
to fullscreen, we'll set it manually (but only for the
|
||||
main screen).
|
||||
*/
|
||||
@interface NSScreen (NSScreenAccess)
|
||||
- (void) setFrame:(NSRect)frame;
|
||||
@end
|
||||
|
||||
@implementation NSScreen (NSScreenAccess)
|
||||
- (void) setFrame:(NSRect)frame;
|
||||
{
|
||||
_frame = frame;
|
||||
}
|
||||
@end
|
||||
|
||||
static void
|
||||
CG_SetError(const char *prefix, CGDisplayErr result)
|
||||
{
|
||||
|
@ -164,6 +182,7 @@ Cocoa_InitModes(_THIS)
|
|||
display.driverdata = displaydata;
|
||||
SDL_AddVideoDisplay(&display);
|
||||
}
|
||||
SDL_stack_free(displays);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -220,11 +239,24 @@ Cocoa_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
|
|||
goto ERR_NO_SWITCH;
|
||||
}
|
||||
|
||||
/* Hide the menu bar so it doesn't intercept events */
|
||||
HideMenuBar();
|
||||
|
||||
/* Fade in again (asynchronously) */
|
||||
if (fade_token != kCGDisplayFadeReservationInvalidToken) {
|
||||
CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);
|
||||
CGReleaseDisplayFadeReservation(fade_token);
|
||||
}
|
||||
|
||||
/*
|
||||
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)];
|
||||
|
||||
return 0;
|
||||
|
||||
/* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */
|
||||
|
@ -253,6 +285,8 @@ Cocoa_QuitModes(_THIS)
|
|||
}
|
||||
}
|
||||
CGReleaseAllDisplays();
|
||||
ShowMenuBar();
|
||||
|
||||
_this->current_display = saved_display;
|
||||
}
|
||||
|
||||
|
|
|
@ -247,11 +247,6 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
|
||||
/* End Wisdom from Apple Engineer section. --ryan. */
|
||||
|
||||
/* FIXME: should this go somewhere else? */
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
[nscontext setFullScreen];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return nscontext;
|
||||
}
|
||||
|
@ -267,8 +262,12 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
|||
SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata;
|
||||
NSOpenGLContext *nscontext = (NSOpenGLContext *)context;
|
||||
|
||||
[nscontext setView:[windowdata->window contentView]];
|
||||
[nscontext update];
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
[nscontext setFullScreen];
|
||||
} else {
|
||||
[nscontext setView:[windowdata->window contentView]];
|
||||
[nscontext update];
|
||||
}
|
||||
[nscontext makeCurrentContext];
|
||||
} else {
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
|
|
|
@ -262,6 +262,24 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
|||
|
||||
@end
|
||||
|
||||
@interface SDLWindow : NSWindow
|
||||
/* These are needed for borderless/fullscreen windows */
|
||||
- (BOOL)canBecomeKeyWindow;
|
||||
- (BOOL)canBecomeMainWindow;
|
||||
@end
|
||||
|
||||
@implementation SDLWindow
|
||||
- (BOOL)canBecomeKeyWindow
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeMainWindow
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
static int
|
||||
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
|
||||
{
|
||||
|
@ -379,7 +397,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
|||
style |= NSResizableWindowMask;
|
||||
}
|
||||
|
||||
nswindow = [[NSWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE];
|
||||
nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE];
|
||||
|
||||
[pool release];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue