- added native fullscreen mode option to Cocoa backend (#1154)

This commit is contained in:
Perry Fraser 2020-08-09 07:41:29 -04:00 committed by GitHub
parent b6f0c4071d
commit 86cf5c9e53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,6 +102,7 @@ EXTERN_CVAR(Int, vid_preferbackend)
EXTERN_CVAR(Bool, vk_debug) EXTERN_CVAR(Bool, vk_debug)
CVAR(Bool, mvk_debug, false, 0) CVAR(Bool, mvk_debug, false, 0)
CVAR(Bool, vid_nativefullscreen, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{ {
@ -290,6 +291,7 @@ CocoaWindow* CreateWindow(const NSUInteger styleMask)
[window setOpaque:YES]; [window setOpaque:YES];
[window makeFirstResponder:appCtrl]; [window makeFirstResponder:appCtrl];
[window setAcceptsMouseMovedEvents:YES]; [window setAcceptsMouseMovedEvents:YES];
[window exitAppOnClose];
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[nc addObserver:window [nc addObserver:window
@ -633,7 +635,6 @@ void SystemBaseFrameBuffer::SetWindowedMode()
const NSRect frameSize = NSMakeRect(win_x, win_y, win_w, win_h); const NSRect frameSize = NSMakeRect(win_x, win_y, win_w, win_h);
[m_window setFrame:frameSize display:YES]; [m_window setFrame:frameSize display:YES];
[m_window enterFullscreenOnZoom]; [m_window enterFullscreenOnZoom];
[m_window exitAppOnClose];
} }
void SystemBaseFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI) void SystemBaseFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
@ -650,7 +651,11 @@ void SystemBaseFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
[m_window.contentView layer].contentsScale = hiDPI ? m_window.screen.backingScaleFactor : 1.0; [m_window.contentView layer].contentsScale = hiDPI ? m_window.screen.backingScaleFactor : 1.0;
} }
if (fullscreen) if (vid_nativefullscreen && fullscreen != m_fullscreen)
{
[m_window toggleFullScreen:(nil)];
}
else if (fullscreen)
{ {
SetFullscreenMode(); SetFullscreenMode();
} }
@ -742,7 +747,11 @@ void SystemGLFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
NSOpenGLView* const glView = [m_window contentView]; NSOpenGLView* const glView = [m_window contentView];
[glView setWantsBestResolutionOpenGLSurface:hiDPI]; [glView setWantsBestResolutionOpenGLSurface:hiDPI];
if (fullscreen) if (vid_nativefullscreen && fullscreen != m_fullscreen)
{
[m_window toggleFullScreen:(nil)];
}
else if (fullscreen)
{ {
SetFullscreenMode(); SetFullscreenMode();
} }