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

Fixed AltTabFix=keepvidmem(1) not keeping back buffers

See issue .
This commit is contained in:
narzoul 2024-05-22 22:40:48 +02:00
parent 24bb72138d
commit 291e50acf3
4 changed files with 14 additions and 3 deletions

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

@ -274,6 +274,13 @@ namespace DDraw
{
resource->setAsPrimary();
}
auto surf = DDraw::Surface::getSurface(*surface);
if (surf)
{
surf->setAsPrimary();
}
CompatPtr<IDirectDrawSurface7> next;
result = surface->GetAttachedSurface(surface, &caps, &next.getRef());
next.swap(surface);

@ -52,6 +52,7 @@ namespace DDraw
, m_refCount(0)
, m_sizeOverride{}
, m_sysMemBuffer(nullptr, &heapFree)
, m_isPrimary(false)
{
g_surfaces.insert(this);
}

@ -43,8 +43,10 @@ namespace DDraw
template <typename TSurface>
SurfaceImpl<TSurface>* 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<void, void(*)(void*)> m_sysMemBuffer;
bool m_isPrimary;
};
}