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

Do not minimize on deactivation if DDSCL_NOWINDOWCHANGES is set

Fixes alt-tabbing issues in Age of Wonders 2 that was making it difficult
to properly activate the minimized game.
This commit is contained in:
narzoul 2016-05-08 20:03:46 +02:00
parent 639d0ce8fb
commit fef2598e5f

View File

@ -17,6 +17,35 @@ namespace
void handleActivateApp(bool isActivated); void handleActivateApp(bool isActivated);
void activateApp(IDirectDraw7& dd)
{
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetCooperativeLevel(
&dd, g_fullScreenCooperativeWindow, g_fullScreenCooperativeFlags);
if (CompatPrimarySurface::isDisplayModeChanged)
{
const CompatPrimarySurface::DisplayMode& dm = CompatPrimarySurface::displayMode;
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetDisplayMode(
&dd, dm.width, dm.height, 32, dm.refreshRate, 0);
}
CompatGdi::enableEmulation();
}
void deactivateApp(IDirectDraw7& dd)
{
CompatGdi::disableEmulation();
if (CompatPrimarySurface::isDisplayModeChanged)
{
CompatDirectDraw<IDirectDraw7>::s_origVtable.RestoreDisplayMode(&dd);
}
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetCooperativeLevel(
&dd, g_fullScreenCooperativeWindow, DDSCL_NORMAL);
if (!(g_fullScreenCooperativeFlags & DDSCL_NOWINDOWCHANGES))
{
ShowWindow(g_fullScreenCooperativeWindow, SW_SHOWMINNOACTIVE);
}
}
LRESULT CALLBACK callWndProc(int nCode, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK callWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{ {
auto ret = reinterpret_cast<CWPSTRUCT*>(lParam); auto ret = reinterpret_cast<CWPSTRUCT*>(lParam);
@ -48,26 +77,11 @@ namespace
if (isActivated) if (isActivated)
{ {
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetCooperativeLevel( activateApp(*dd);
dd, g_fullScreenCooperativeWindow, g_fullScreenCooperativeFlags);
if (CompatPrimarySurface::isDisplayModeChanged)
{
const CompatPrimarySurface::DisplayMode& dm = CompatPrimarySurface::displayMode;
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetDisplayMode(
dd, dm.width, dm.height, 32, dm.refreshRate, 0);
}
CompatGdi::enableEmulation();
} }
else else
{ {
CompatGdi::disableEmulation(); deactivateApp(*dd);
if (CompatPrimarySurface::isDisplayModeChanged)
{
CompatDirectDraw<IDirectDraw7>::s_origVtable.RestoreDisplayMode(dd);
}
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetCooperativeLevel(
dd, g_fullScreenCooperativeWindow, DDSCL_NORMAL);
ShowWindow(g_fullScreenCooperativeWindow, SW_MINIMIZE);
} }
CompatDirectDraw<IDirectDraw7>::s_origVtable.Release(dd); CompatDirectDraw<IDirectDraw7>::s_origVtable.Release(dd);