From 399b6248d1042eedc545630b8b2752c148377b88 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Mon, 5 Jan 2015 00:01:22 +0100 Subject: [PATCH] D3D: Further improve exclusive fullscreen state checking. --- Source/Core/VideoBackends/D3D/Render.cpp | 37 ++++++++++++++---------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index f24e86a5d2..fd8e406ff2 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -878,17 +878,32 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co D3D::Present(); // Check exclusive fullscreen state - bool fullscreen_state, fullscreen_changed = false; - if (SUCCEEDED(D3D::GetFullscreenState(&fullscreen_state))) + bool exclusive_mode, fullscreen_changed = false; + if (SUCCEEDED(D3D::GetFullscreenState(&exclusive_mode))) { - if (fullscreen_state != fullscreen) + if (fullscreen && !exclusive_mode) { - // The current fullscreen state does not match the configuration, - // either we switched fullscreen settings or the render frame - // lost focus. When the render frame is in focus we can apply - // exclusive mode. + // Exclusive fullscreen is enabled in the configuration, but we're + // not in exclusive mode. Either exclusive fullscreen was turned on + // or the render frame lost focus. When the render frame is in focus + // we can apply exclusive mode. fullscreen_changed = Host_RendererHasFocus(); } + else if (!fullscreen) + { + if (exclusive_mode) + { + // Exclusive fullscreen is disabled, but we're still in exclusive mode. + fullscreen_changed = true; + } + else if (!g_ActiveConfig.bBorderlessFullscreen && Host_RendererIsFullscreen()) + { + // Exclusive fullscreen is disabled and we are no longer in exclusive + // mode. Thus we can now safely notify the UI to exit fullscreen. But + // we should only do so if borderless fullscreen mode is disabled. + Host_RequestFullscreen(false); + } + } } // Resize the back buffers NOW to avoid flickering @@ -907,16 +922,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co { // Apply fullscreen state if (fullscreen_changed) - { D3D::SetFullscreenState(fullscreen); - // Notify the host that it is safe to exit fullscreen - if (!fullscreen) - { - Host_RequestFullscreen(false); - } - } - // TODO: Aren't we still holding a reference to the back buffer right now? D3D::Reset(); SAFE_RELEASE(s_screenshot_texture);