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

Alternative workaround for VirtualizeDesktopPainting shim

Fixes blue filled rectangle covering whole screen when exit confirmation
dialog is displayed in The Longest Journey.
This commit is contained in:
narzoul 2020-04-04 20:49:04 +02:00
parent e9ecc5adbe
commit 13f3b0ced7
4 changed files with 11 additions and 19 deletions

View File

@ -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<decltype(GetDC)*>(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)

View File

@ -9,7 +9,6 @@ namespace Gdi
typedef void(*WindowPosChangeNotifyFunc)();
void dllThreadDetach();
HDC getScreenDc();
HRGN getVisibleWindowRgn(HWND hwnd);
void installHooks();
bool isDisplayDc(HDC dc);

View File

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

View File

@ -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;
}