Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add native fullscreen support for OS X.
  • Loading branch information
grp committed Apr 4, 2013
1 parent 9f8841e commit 39965e8
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
28 changes: 26 additions & 2 deletions Source/Core/DolphinWX/Src/Frame.cpp
Expand Up @@ -398,11 +398,24 @@ CFrame::~CFrame()

bool CFrame::RendererIsFullscreen()
{
bool fullscreen = false;

if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
{
return m_RenderFrame->IsFullScreen();
fullscreen = m_RenderFrame->IsFullScreen();
}
return false;

#if defined(__APPLE__)
if (m_RenderFrame != NULL)
{
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];

fullscreen = (([window styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask);
}
#endif

return fullscreen;
}

void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
Expand Down Expand Up @@ -979,7 +992,18 @@ void CFrame::DoFullscreen(bool bF)
{
ToggleDisplayMode(bF);

#if defined(__APPLE__)
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];

if (bF != RendererIsFullscreen())
{
[window toggleFullScreen:nil];
}
#else
m_RenderFrame->ShowFullScreen(bF, wxFULLSCREEN_ALL);
#endif

if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{
if (bF)
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/DolphinWX/Src/Frame.h
Expand Up @@ -29,6 +29,10 @@
#include <string>
#include <vector>

#ifdef __APPLE__
#include <Cocoa/Cocoa.h>
#endif

#include "CDUtils.h"
#include "Debugger/CodeWindow.h"
#include "LogWindow.h"
Expand Down
22 changes: 19 additions & 3 deletions Source/Core/DolphinWX/Src/FrameTools.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/DolphinWX/Src/VideoConfigDiag.cpp
Expand Up @@ -253,6 +253,8 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
wxFlexGridSizer* const szr_display = new wxFlexGridSizer(2, 5, 5);

{

#if !defined(__APPLE__)
// display resolution
{
wxArrayString res_list = GetListOfResolutions();
Expand All @@ -274,6 +276,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
choice_display_resolution->Disable();
}
}
#endif

// aspect-ratio
{
Expand Down

0 comments on commit 39965e8

Please sign in to comment.