summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/D3D/Render.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/VideoBackends/D3D/Render.cpp')
-rw-r--r--Source/Core/VideoBackends/D3D/Render.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp
index 5644eae9fb..fd8e406ff2 100644
--- a/Source/Core/VideoBackends/D3D/Render.cpp
+++ b/Source/Core/VideoBackends/D3D/Render.cpp
@@ -41,13 +41,11 @@ namespace DX11
{
static u32 s_last_multisample_mode = 0;
+static bool s_last_stereo_mode = false;
+static bool s_last_xfb_mode = false;
static Television s_television;
-static bool s_last_fullscreen_mode = false;
-static bool s_last_stereo_mode = 0;
-static bool s_last_xfb_mode = false;
-
ID3D11Buffer* access_efb_cbuf = nullptr;
ID3D11BlendState* clearblendstates[4] = {nullptr};
ID3D11DepthStencilState* cleardepthstates[3] = {nullptr};
@@ -230,7 +228,6 @@ Renderer::Renderer(void *&window_handle)
s_last_multisample_mode = g_ActiveConfig.iMultisampleMode;
s_last_efb_scale = g_ActiveConfig.iEFBScale;
- s_last_fullscreen_mode = g_ActiveConfig.bFullscreen;
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
s_last_xfb_mode = g_ActiveConfig.bUseRealXFB;
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height);
@@ -866,20 +863,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
const bool fullscreen = g_ActiveConfig.bFullscreen &&
!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain;
- bool fullscreen_changed = s_last_fullscreen_mode != fullscreen;
-
- bool fullscreen_state;
- if (SUCCEEDED(D3D::GetFullscreenState(&fullscreen_state)))
- {
- if (fullscreen_state != fullscreen && Host_RendererHasFocus())
- {
- // The current fullscreen state does not match the configuration,
- // this may happen when the renderer frame loses focus. When the
- // render frame is in focus again we can re-apply the configuration.
- fullscreen_changed = true;
- }
- }
-
bool xfbchanged = s_last_xfb_mode != g_ActiveConfig.bUseRealXFB;
if (FramebufferManagerBase::LastXfbWidth() != fbStride || FramebufferManagerBase::LastXfbHeight() != fbHeight)
@@ -894,6 +877,35 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
// Flip/present backbuffer to frontbuffer here
D3D::Present();
+ // Check exclusive fullscreen state
+ bool exclusive_mode, fullscreen_changed = false;
+ if (SUCCEEDED(D3D::GetFullscreenState(&exclusive_mode)))
+ {
+ if (fullscreen && !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
if (xfbchanged ||
windowResized ||
@@ -910,17 +922,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
{
// Apply fullscreen state
if (fullscreen_changed)
- {
- s_last_fullscreen_mode = fullscreen;
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);