1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Fixed broken presentation after fullscreen to windowed switch

Fixes frozen screen before main menu in The X-Files Game.
This commit is contained in:
narzoul 2024-06-29 16:26:29 +02:00
parent 60476f44ed
commit ec686bfb69
4 changed files with 33 additions and 0 deletions

View File

@ -149,6 +149,10 @@ namespace
if (wasFullscreen != isFullscreen)
{
tagSurface->setFullscreenWindow(isFullscreen ? hWnd : nullptr);
if (!isFullscreen)
{
DDraw::PrimarySurface::setWindowedCooperativeLevel();
}
}
}
}

View File

@ -299,6 +299,29 @@ namespace DDraw
}
}
void PrimarySurface::setWindowedCooperativeLevel()
{
LOG_FUNC("PrimarySurface::setWindowedCooperativeLevel");
if (!g_primarySurface)
{
return;
}
RealPrimarySurface::restore();
if (FAILED(g_primarySurface->IsLost(g_primarySurface)))
{
return;
}
auto surface = Surface::getSurface(*g_primarySurface);
if (surface)
{
onLost();
surface->restore();
}
}
void PrimarySurface::updateFrontResource()
{
g_frontResource = DirectDrawSurface::getDriverResourceHandle(*g_primarySurface);

View File

@ -29,6 +29,7 @@ namespace DDraw
static DWORD getOrigCaps();
static void onLost();
static void setAsRenderTarget();
static void setWindowedCooperativeLevel();
static void updatePalette();
template <typename TSurface>

View File

@ -153,6 +153,11 @@ namespace DDraw
template <typename TSurface>
HRESULT PrimarySurfaceImpl<TSurface>::Flip(TSurface* This, TSurface* lpDDSurfaceTargetOverride, DWORD dwFlags)
{
if (!RealPrimarySurface::isFullscreen())
{
return DDERR_NOEXCLUSIVEMODE;
}
RealPrimarySurface::setUpdateReady();
RealPrimarySurface::flush();
RealPrimarySurface::waitForFlip(m_data->getDDS());