From 36ea1890c8d1b6084a5bc2e80093878af400810a Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Wed, 16 Jul 2014 15:53:33 +0200 Subject: [PATCH] Let the Renderer decide when to exit fullscreen. This ensures the transition from/to exclusive mode happens while the RenderFrame is fullscreen. This prevents fullscreen loops and relieves us of having to restore the window size after we exit fullscreen. --- Source/Core/Core/Host.h | 1 + Source/Core/DolphinWX/Frame.cpp | 18 +++++++++++++++++- Source/Core/DolphinWX/Globals.h | 1 + Source/Core/DolphinWX/Main.cpp | 7 +++++++ Source/Core/DolphinWX/MainAndroid.cpp | 3 +++ Source/Core/DolphinWX/MainNoGUI.cpp | 3 +++ Source/Core/VideoBackends/D3D/D3DBase.cpp | 3 --- Source/Core/VideoBackends/D3D/Render.cpp | 9 ++++++++- 8 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index 32061242f2..fe9ff11a6d 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -31,6 +31,7 @@ void Host_Message(int Id); void Host_NotifyMapLoaded(); void Host_RefreshDSPDebuggerWindow(); void Host_RequestRenderWindowSize(int width, int height); +void Host_RequestFullscreen(bool fullscreen); void Host_SetStartupDebuggingParameters(); void Host_SetWiiMoteConnectionState(int _State); void Host_ShowJitResults(unsigned int address); diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 4c258d5453..25a09d13e1 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -640,6 +640,11 @@ void CFrame::OnHostMessage(wxCommandEvent& event) } break; + case IDM_FULLSCREENREQUEST: + if (m_RenderFrame != nullptr) + m_RenderFrame->ShowFullScreen(event.GetInt() == 0 ? false : true); + break; + case WM_USER_CREATE: if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) m_RenderParent->SetCursor(wxCURSOR_BLANK); @@ -1185,7 +1190,18 @@ void CFrame::DoFullscreen(bool bF) [window toggleFullScreen:nil]; } #else - m_RenderFrame->ShowFullScreen(bF, wxFULLSCREEN_ALL); + if (bF) + { + m_RenderFrame->ShowFullScreen(true, wxFULLSCREEN_ALL); + } + else if (!g_ActiveConfig.backend_info.bSupportsExclusiveFullscreen || + SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain || + g_ActiveConfig.bForceBorderlessFullscreen) + { + // Exiting exclusive fullscreen should be done from a Renderer callback. + // Therefore we don't exit fullscreen from here if we support exclusive mode. + m_RenderFrame->ShowFullScreen(false, wxFULLSCREEN_ALL); + } #endif if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) diff --git a/Source/Core/DolphinWX/Globals.h b/Source/Core/DolphinWX/Globals.h index 401f4265ad..2a8fc02854 100644 --- a/Source/Core/DolphinWX/Globals.h +++ b/Source/Core/DolphinWX/Globals.h @@ -256,6 +256,7 @@ enum IDM_WINDOWSIZEREQUEST, IDM_STOPPED, IDM_HOST_MESSAGE, + IDM_FULLSCREENREQUEST, IDM_MPANEL, ID_STATUSBAR, diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index ad6d049635..712aca5895 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -627,6 +627,13 @@ void Host_RequestRenderWindowSize(int width, int height) main_frame->GetEventHandler()->AddPendingEvent(event); } +void Host_RequestFullscreen(bool fullscreen) +{ + wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_FULLSCREENREQUEST); + event.SetInt(fullscreen ? 1 : 0); + main_frame->GetEventHandler()->AddPendingEvent(event); +} + void Host_SetStartupDebuggingParameters() { SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter; diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index d24be7f954..cdbc2a0785 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -94,6 +94,9 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) } void Host_RequestRenderWindowSize(int width, int height) {} + +void Host_RequestFullscreen(bool fullscreen) {} + void Host_SetStartupDebuggingParameters() { } diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index 351d818c2c..ee532f702a 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -88,6 +88,9 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) } void Host_RequestRenderWindowSize(int width, int height) {} + +void Host_RequestFullscreen(bool fullscreen) {} + void Host_SetStartupDebuggingParameters() { SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter; diff --git a/Source/Core/VideoBackends/D3D/D3DBase.cpp b/Source/Core/VideoBackends/D3D/D3DBase.cpp index 1d03e9b33b..21226e442c 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBase.cpp @@ -440,9 +440,6 @@ void Reset() // release all back buffer references SAFE_RELEASE(backbuf); - // apply fullscreen state - D3D::swapchain->SetFullscreenState(g_ActiveConfig.bFullscreen, nullptr); - // resize swapchain buffers RECT client; GetClientRect(hWnd, &client); diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index a7b2c56212..ae23516d5c 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -975,11 +975,18 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl s_LastAA != g_ActiveConfig.iMultisampleMode) { s_LastAA = g_ActiveConfig.iMultisampleMode; - s_last_fullscreen_mode = fullscreen; PixelShaderCache::InvalidateMSAAShaders(); if (windowResized || fullscreen_changed) { + // apply fullscreen state + if (fullscreen_changed) + { + s_last_fullscreen_mode = fullscreen; + D3D::swapchain->SetFullscreenState(fullscreen, nullptr); + Host_RequestFullscreen(fullscreen); + } + // TODO: Aren't we still holding a reference to the back buffer right now? D3D::Reset(); SAFE_RELEASE(s_screenshot_texture);