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:
parent
e9ecc5adbe
commit
13f3b0ced7
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
HDC g_screenDc = nullptr;
|
|
||||||
|
|
||||||
BOOL CALLBACK redrawWindowCallback(HWND hwnd, LPARAM lParam)
|
BOOL CALLBACK redrawWindowCallback(HWND hwnd, LPARAM lParam)
|
||||||
{
|
{
|
||||||
DWORD windowPid = 0;
|
DWORD windowPid = 0;
|
||||||
@ -35,11 +33,6 @@ namespace Gdi
|
|||||||
DcCache::dllThreadDetach();
|
DcCache::dllThreadDetach();
|
||||||
}
|
}
|
||||||
|
|
||||||
HDC getScreenDc()
|
|
||||||
{
|
|
||||||
return g_screenDc;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRGN getVisibleWindowRgn(HWND hwnd)
|
HRGN getVisibleWindowRgn(HWND hwnd)
|
||||||
{
|
{
|
||||||
return DcFunctions::getVisibleWindowRgn(hwnd);
|
return DcFunctions::getVisibleWindowRgn(hwnd);
|
||||||
@ -47,15 +40,6 @@ namespace Gdi
|
|||||||
|
|
||||||
void installHooks()
|
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();
|
DcFunctions::installHooks();
|
||||||
PaintHandlers::installHooks();
|
PaintHandlers::installHooks();
|
||||||
Palette::installHooks();
|
Palette::installHooks();
|
||||||
@ -112,7 +96,6 @@ namespace Gdi
|
|||||||
Window::uninstallHooks();
|
Window::uninstallHooks();
|
||||||
Dc::dllProcessDetach();
|
Dc::dllProcessDetach();
|
||||||
DcCache::dllProcessDetach();
|
DcCache::dllProcessDetach();
|
||||||
CALL_ORIG_FUNC(ReleaseDC)(nullptr, g_screenDc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void watchWindowPosChanges(WindowPosChangeNotifyFunc notifyFunc)
|
void watchWindowPosChanges(WindowPosChangeNotifyFunc notifyFunc)
|
||||||
|
@ -9,7 +9,6 @@ namespace Gdi
|
|||||||
typedef void(*WindowPosChangeNotifyFunc)();
|
typedef void(*WindowPosChangeNotifyFunc)();
|
||||||
|
|
||||||
void dllThreadDetach();
|
void dllThreadDetach();
|
||||||
HDC getScreenDc();
|
|
||||||
HRGN getVisibleWindowRgn(HWND hwnd);
|
HRGN getVisibleWindowRgn(HWND hwnd);
|
||||||
void installHooks();
|
void installHooks();
|
||||||
bool isDisplayDc(HDC dc);
|
bool isDisplayDc(HDC dc);
|
||||||
|
@ -187,6 +187,15 @@ namespace
|
|||||||
|
|
||||||
void onCreateWindow(HWND hwnd)
|
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));
|
hookThread(GetWindowThreadProcessId(hwnd, nullptr));
|
||||||
disableDwmAttributes(hwnd);
|
disableDwmAttributes(hwnd);
|
||||||
removeDropShadow(hwnd);
|
removeDropShadow(hwnd);
|
||||||
|
@ -248,12 +248,13 @@ namespace Gdi
|
|||||||
{
|
{
|
||||||
if (m_windowRect.left != oldWindowRect.left || m_windowRect.top != oldWindowRect.top)
|
if (m_windowRect.left != oldWindowRect.left || m_windowRect.top != oldWindowRect.top)
|
||||||
{
|
{
|
||||||
HDC screenDc = Gdi::getScreenDc();
|
HDC screenDc = GetDC(nullptr);
|
||||||
SelectClipRgn(screenDc, preservedRegion);
|
SelectClipRgn(screenDc, preservedRegion);
|
||||||
BitBlt(screenDc, m_windowRect.left, m_windowRect.top,
|
BitBlt(screenDc, m_windowRect.left, m_windowRect.top,
|
||||||
oldWindowRect.right - oldWindowRect.left, oldWindowRect.bottom - oldWindowRect.top,
|
oldWindowRect.right - oldWindowRect.left, oldWindowRect.bottom - oldWindowRect.top,
|
||||||
screenDc, oldWindowRect.left, oldWindowRect.top, SRCCOPY);
|
screenDc, oldWindowRect.left, oldWindowRect.top, SRCCOPY);
|
||||||
SelectClipRgn(screenDc, nullptr);
|
SelectClipRgn(screenDc, nullptr);
|
||||||
|
ReleaseDC(nullptr, screenDc);
|
||||||
}
|
}
|
||||||
m_invalidatedRegion -= preservedRegion;
|
m_invalidatedRegion -= preservedRegion;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user