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

Restore main window, last active popup and GDI on WM_ACTIVATEAPP

Fixes an issue with Fallout's window disappearing from the taskbar every other
time it's minimized.
Also fixes StarCraft's Save Screen Capture dialog being hidden after the main
window is restored.
This commit is contained in:
narzoul 2016-05-10 00:04:21 +02:00
parent fef2598e5f
commit 2717b095ec

View File

@ -19,6 +19,16 @@ namespace
void activateApp(IDirectDraw7& dd)
{
if (!(g_fullScreenCooperativeFlags & DDSCL_NOWINDOWCHANGES))
{
ShowWindow(g_fullScreenCooperativeWindow, SW_RESTORE);
HWND lastActivePopup = GetLastActivePopup(g_fullScreenCooperativeWindow);
if (lastActivePopup && lastActivePopup != g_fullScreenCooperativeWindow)
{
BringWindowToTop(lastActivePopup);
}
}
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetCooperativeLevel(
&dd, g_fullScreenCooperativeWindow, g_fullScreenCooperativeFlags);
if (CompatPrimarySurface::isDisplayModeChanged)
@ -27,12 +37,19 @@ namespace
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetDisplayMode(
&dd, dm.width, dm.height, 32, dm.refreshRate, 0);
}
CompatGdi::enableEmulation();
if (CompatPrimarySurface::surface)
{
CompatDirectDrawSurface<IDirectDrawSurface7>::s_origVtable.Restore(
CompatPrimarySurface::surface);
CompatDirectDrawSurface<IDirectDrawSurface7>::fixSurfacePtrs(
*CompatPrimarySurface::surface);
CompatGdi::invalidate(nullptr);
}
}
void deactivateApp(IDirectDraw7& dd)
{
CompatGdi::disableEmulation();
if (CompatPrimarySurface::isDisplayModeChanged)
{
CompatDirectDraw<IDirectDraw7>::s_origVtable.RestoreDisplayMode(&dd);
@ -66,10 +83,18 @@ namespace
{
Compat::LogEnter("handleActivateApp", isActivated);
const bool isActiveChanged = g_isActive != isActivated;
if (isActivated == g_isActive)
{
return;
}
g_isActive = isActivated;
if (isActiveChanged && g_fullScreenDirectDraw)
if (!isActivated)
{
CompatGdi::disableEmulation();
}
if (g_fullScreenDirectDraw)
{
IDirectDraw7* dd = nullptr;
g_fullScreenDirectDraw->lpVtbl->QueryInterface(
@ -87,6 +112,11 @@ namespace
CompatDirectDraw<IDirectDraw7>::s_origVtable.Release(dd);
}
if (isActivated)
{
CompatGdi::enableEmulation();
}
Compat::LogLeave("handleActivateApp", isActivated);
}
}