D3D: Further improve exclusive fullscreen state checking.

This commit is contained in:
Jules Blok 2015-01-05 00:01:22 +01:00
parent b7e056c74d
commit 399b6248d1

View file

@ -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);