diff --git a/DDrawCompat/Gdi/Gdi.cpp b/DDrawCompat/Gdi/Gdi.cpp index dede8c4..c5cc25a 100644 --- a/DDrawCompat/Gdi/Gdi.cpp +++ b/DDrawCompat/Gdi/Gdi.cpp @@ -12,8 +12,6 @@ namespace { - HDC g_screenDc = nullptr; - BOOL CALLBACK redrawWindowCallback(HWND hwnd, LPARAM lParam) { DWORD windowPid = 0; @@ -35,11 +33,6 @@ namespace Gdi DcCache::dllThreadDetach(); } - HDC getScreenDc() - { - return g_screenDc; - } - HRGN getVisibleWindowRgn(HWND hwnd) { return DcFunctions::getVisibleWindowRgn(hwnd); @@ -47,15 +40,6 @@ namespace Gdi void installHooks() { - // Workaround for VirtualizeDesktopPainting shim, which doesn't seem to handle BitBlt - // from screen DC to screen DC correctly - auto getDc = reinterpret_cast(Compat::getProcAddress(GetModuleHandle("user32"), "GetDC")); - if (!getDc) - { - getDc = &GetDC; - } - g_screenDc = getDc(nullptr); - DcFunctions::installHooks(); PaintHandlers::installHooks(); Palette::installHooks(); @@ -112,7 +96,6 @@ namespace Gdi Window::uninstallHooks(); Dc::dllProcessDetach(); DcCache::dllProcessDetach(); - CALL_ORIG_FUNC(ReleaseDC)(nullptr, g_screenDc); } void watchWindowPosChanges(WindowPosChangeNotifyFunc notifyFunc) diff --git a/DDrawCompat/Gdi/Gdi.h b/DDrawCompat/Gdi/Gdi.h index c53d678..da0691f 100644 --- a/DDrawCompat/Gdi/Gdi.h +++ b/DDrawCompat/Gdi/Gdi.h @@ -9,7 +9,6 @@ namespace Gdi typedef void(*WindowPosChangeNotifyFunc)(); void dllThreadDetach(); - HDC getScreenDc(); HRGN getVisibleWindowRgn(HWND hwnd); void installHooks(); bool isDisplayDc(HDC dc); diff --git a/DDrawCompat/Gdi/WinProc.cpp b/DDrawCompat/Gdi/WinProc.cpp index bffc011..d149eaa 100644 --- a/DDrawCompat/Gdi/WinProc.cpp +++ b/DDrawCompat/Gdi/WinProc.cpp @@ -187,6 +187,15 @@ namespace void onCreateWindow(HWND hwnd) { + char className[64] = {}; + GetClassName(hwnd, className, sizeof(className)); + if (std::string(className) == "CompatWindowDesktopReplacement") + { + // Disable VirtualizeDesktopPainting shim + SendNotifyMessage(hwnd, WM_CLOSE, 0, 0); + return; + } + hookThread(GetWindowThreadProcessId(hwnd, nullptr)); disableDwmAttributes(hwnd); removeDropShadow(hwnd); diff --git a/DDrawCompat/Gdi/Window.cpp b/DDrawCompat/Gdi/Window.cpp index 2236821..8967f02 100644 --- a/DDrawCompat/Gdi/Window.cpp +++ b/DDrawCompat/Gdi/Window.cpp @@ -248,12 +248,13 @@ namespace Gdi { if (m_windowRect.left != oldWindowRect.left || m_windowRect.top != oldWindowRect.top) { - HDC screenDc = Gdi::getScreenDc(); + HDC screenDc = GetDC(nullptr); SelectClipRgn(screenDc, preservedRegion); BitBlt(screenDc, m_windowRect.left, m_windowRect.top, oldWindowRect.right - oldWindowRect.left, oldWindowRect.bottom - oldWindowRect.top, screenDc, oldWindowRect.left, oldWindowRect.top, SRCCOPY); SelectClipRgn(screenDc, nullptr); + ReleaseDC(nullptr, screenDc); } m_invalidatedRegion -= preservedRegion; }