Add native fullscreen support for OS X.

This commit is contained in:
Grant Paul
2013-03-31 09:08:29 -07:00
parent 9f8841e960
commit 39965e894d
4 changed files with 52 additions and 5 deletions

View File

@ -798,9 +798,6 @@ void CFrame::ToggleDisplayMode(bool bFullscreen)
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
m_XRRConfig->ToggleDisplayMode(bFullscreen);
#elif defined __APPLE__
NSView* view = (NSView *)m_RenderFrame->GetHandle();
[[view window] toggleFullScreen:[view window]];
if(bFullscreen)
CGDisplayHideCursor(CGMainDisplayID());
else
@ -867,6 +864,13 @@ void CFrame::StartGame(const std::string& filename)
m_RenderFrame->Show();
}
#if defined(__APPLE__)
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
#endif
wxBeginBusyCursor();
DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
@ -1022,10 +1026,22 @@ void CFrame::DoStop()
m_RenderParent->SetCursor(wxNullCursor);
DoFullscreen(false);
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{
m_RenderFrame->Destroy();
}
else
{
#if defined(__APPLE__)
// Disable the full screen button when not in a game.
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];
[window setCollectionBehavior:NSWindowCollectionBehaviorDefault];
#endif
// Make sure the window is not longer set to stay on top
m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP);
}
m_RenderParent = NULL;
// Clean framerate indications from the status bar.