Add native fullscreen support for OS X.
This commit is contained in:
parent
9f8841e960
commit
39965e894d
|
@ -398,11 +398,24 @@ CFrame::~CFrame()
|
||||||
|
|
||||||
bool CFrame::RendererIsFullscreen()
|
bool CFrame::RendererIsFullscreen()
|
||||||
{
|
{
|
||||||
|
bool fullscreen = false;
|
||||||
|
|
||||||
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
|
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))
|
void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
|
||||||
|
@ -979,7 +992,18 @@ void CFrame::DoFullscreen(bool bF)
|
||||||
{
|
{
|
||||||
ToggleDisplayMode(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);
|
m_RenderFrame->ShowFullScreen(bF, wxFULLSCREEN_ALL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
|
||||||
{
|
{
|
||||||
if (bF)
|
if (bF)
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "CDUtils.h"
|
#include "CDUtils.h"
|
||||||
#include "Debugger/CodeWindow.h"
|
#include "Debugger/CodeWindow.h"
|
||||||
#include "LogWindow.h"
|
#include "LogWindow.h"
|
||||||
|
|
|
@ -798,9 +798,6 @@ void CFrame::ToggleDisplayMode(bool bFullscreen)
|
||||||
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
|
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
m_XRRConfig->ToggleDisplayMode(bFullscreen);
|
m_XRRConfig->ToggleDisplayMode(bFullscreen);
|
||||||
#elif defined __APPLE__
|
#elif defined __APPLE__
|
||||||
NSView* view = (NSView *)m_RenderFrame->GetHandle();
|
|
||||||
[[view window] toggleFullScreen:[view window]];
|
|
||||||
|
|
||||||
if(bFullscreen)
|
if(bFullscreen)
|
||||||
CGDisplayHideCursor(CGMainDisplayID());
|
CGDisplayHideCursor(CGMainDisplayID());
|
||||||
else
|
else
|
||||||
|
@ -867,6 +864,13 @@ void CFrame::StartGame(const std::string& filename)
|
||||||
m_RenderFrame->Show();
|
m_RenderFrame->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
NSView *view = (NSView *) m_RenderFrame->GetHandle();
|
||||||
|
NSWindow *window = [view window];
|
||||||
|
|
||||||
|
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||||
|
#endif
|
||||||
|
|
||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
|
||||||
DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
|
DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
|
||||||
|
@ -1022,10 +1026,22 @@ void CFrame::DoStop()
|
||||||
m_RenderParent->SetCursor(wxNullCursor);
|
m_RenderParent->SetCursor(wxNullCursor);
|
||||||
DoFullscreen(false);
|
DoFullscreen(false);
|
||||||
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
|
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
|
||||||
|
{
|
||||||
m_RenderFrame->Destroy();
|
m_RenderFrame->Destroy();
|
||||||
|
}
|
||||||
else
|
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
|
// Make sure the window is not longer set to stay on top
|
||||||
m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP);
|
m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP);
|
||||||
|
}
|
||||||
m_RenderParent = NULL;
|
m_RenderParent = NULL;
|
||||||
|
|
||||||
// Clean framerate indications from the status bar.
|
// Clean framerate indications from the status bar.
|
||||||
|
|
|
@ -253,6 +253,8 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
|
||||||
wxFlexGridSizer* const szr_display = new wxFlexGridSizer(2, 5, 5);
|
wxFlexGridSizer* const szr_display = new wxFlexGridSizer(2, 5, 5);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if !defined(__APPLE__)
|
||||||
// display resolution
|
// display resolution
|
||||||
{
|
{
|
||||||
wxArrayString res_list = GetListOfResolutions();
|
wxArrayString res_list = GetListOfResolutions();
|
||||||
|
@ -274,6 +276,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
|
||||||
choice_display_resolution->Disable();
|
choice_display_resolution->Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// aspect-ratio
|
// aspect-ratio
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue