diff --git a/DDrawCompat/DDraw/DirectDraw.cpp b/DDrawCompat/DDraw/DirectDraw.cpp index 8f6119a..9dfbf03 100644 --- a/DDrawCompat/DDraw/DirectDraw.cpp +++ b/DDrawCompat/DDraw/DirectDraw.cpp @@ -199,7 +199,7 @@ namespace } } - if (Config::Settings::AltTabFix::OFF == Config::altTabFix.get()) + if (Config::Settings::AltTabFix::KEEPVIDMEM != Config::altTabFix.get()) { return LOG_RESULT(g_origDDrawWindowProc(hwnd, WM_ACTIVATEAPP, wParam, lParam)); } @@ -211,7 +211,7 @@ namespace { auto lcl = DDraw::DirectDrawSurface::getInt(*surface.getDDS()).lpLcl; if (!(lcl->dwFlags & DDRAWISURF_INVALID) && - (keepPrimary || !(surface.getOrigCaps() & DDSCAPS_PRIMARYSURFACE))) + (keepPrimary || !surface.isPrimary())) { lcl->dwFlags |= DDRAWISURF_INVALID; surfacesToRestore.insert(lcl); @@ -236,7 +236,7 @@ namespace auto realPrimary(DDraw::RealPrimarySurface::getSurface()); if (realPrimary) { - realPrimary->Restore(realPrimary); + DDraw::RealPrimarySurface::restore(); auto gdiResource = DDraw::PrimarySurface::getGdiResource(); if (gdiResource) { diff --git a/DDrawCompat/DDraw/Surfaces/PrimarySurface.cpp b/DDrawCompat/DDraw/Surfaces/PrimarySurface.cpp index b5f71f0..02215bf 100644 --- a/DDrawCompat/DDraw/Surfaces/PrimarySurface.cpp +++ b/DDrawCompat/DDraw/Surfaces/PrimarySurface.cpp @@ -274,6 +274,13 @@ namespace DDraw { resource->setAsPrimary(); } + + auto surf = DDraw::Surface::getSurface(*surface); + if (surf) + { + surf->setAsPrimary(); + } + CompatPtr next; result = surface->GetAttachedSurface(surface, &caps, &next.getRef()); next.swap(surface); diff --git a/DDrawCompat/DDraw/Surfaces/Surface.cpp b/DDrawCompat/DDraw/Surfaces/Surface.cpp index c82b118..7408869 100644 --- a/DDrawCompat/DDraw/Surfaces/Surface.cpp +++ b/DDrawCompat/DDraw/Surfaces/Surface.cpp @@ -52,6 +52,7 @@ namespace DDraw , m_refCount(0) , m_sizeOverride{} , m_sysMemBuffer(nullptr, &heapFree) + , m_isPrimary(false) { g_surfaces.insert(this); } diff --git a/DDrawCompat/DDraw/Surfaces/Surface.h b/DDrawCompat/DDraw/Surfaces/Surface.h index df01a05..8476c89 100644 --- a/DDrawCompat/DDraw/Surfaces/Surface.h +++ b/DDrawCompat/DDraw/Surfaces/Surface.h @@ -43,8 +43,10 @@ namespace DDraw template SurfaceImpl* getImpl() const; + bool isPrimary() const { return m_isPrimary; } virtual void restore(); + void setAsPrimary() { m_isPrimary = true; } void setSizeOverride(DWORD width, DWORD height); protected: @@ -71,5 +73,6 @@ namespace DDraw DWORD m_refCount; SIZE m_sizeOverride; std::unique_ptr m_sysMemBuffer; + bool m_isPrimary; }; }