mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Workaround for VirtualizeDesktopPainting shim
This commit is contained in:
parent
403037c0da
commit
c1b35e0434
@ -178,7 +178,7 @@ namespace Gdi
|
|||||||
|
|
||||||
HDC getDc(HDC origDc, bool useMetaRgn)
|
HDC getDc(HDC origDc, bool useMetaRgn)
|
||||||
{
|
{
|
||||||
if (!origDc || OBJ_DC != GetObjectType(origDc) || DT_RASDISPLAY != GetDeviceCaps(origDc, TECHNOLOGY))
|
if (!isDisplayDc(origDc))
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,14 @@ namespace Gdi
|
|||||||
|
|
||||||
void installHooks()
|
void installHooks()
|
||||||
{
|
{
|
||||||
g_screenDc = GetDC(nullptr);
|
// 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();
|
||||||
@ -60,7 +67,7 @@ namespace Gdi
|
|||||||
|
|
||||||
bool isDisplayDc(HDC dc)
|
bool isDisplayDc(HDC dc)
|
||||||
{
|
{
|
||||||
return dc && OBJ_DC == GetObjectType(dc) && DT_RASDISPLAY == GetDeviceCaps(dc, TECHNOLOGY) &&
|
return dc && OBJ_DC == GetObjectType(dc) && DT_RASDISPLAY == CALL_ORIG_FUNC(GetDeviceCaps)(dc, TECHNOLOGY) &&
|
||||||
!(GetWindowLongPtr(CALL_ORIG_FUNC(WindowFromDC)(dc), GWL_EXSTYLE) & WS_EX_LAYERED);
|
!(GetWindowLongPtr(CALL_ORIG_FUNC(WindowFromDC)(dc), GWL_EXSTYLE) & WS_EX_LAYERED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,15 +132,6 @@ namespace
|
|||||||
|
|
||||||
LRESULT WINAPI defWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI defWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (WM_CREATE == msg)
|
|
||||||
{
|
|
||||||
auto className = reinterpret_cast<CREATESTRUCTW*>(lParam)->lpszClass;
|
|
||||||
if (reinterpret_cast<DWORD>(className) > 0xFFFF &&
|
|
||||||
0 == lstrcmpW(className, L"CompatWindowDesktopReplacement"))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return defPaintProc(hwnd, msg, wParam, lParam, CALL_ORIG_FUNC(DefWindowProcW), "defWindowProcW");
|
return defPaintProc(hwnd, msg, wParam, lParam, CALL_ORIG_FUNC(DefWindowProcW), "defWindowProcW");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "Common/Hook.h"
|
#include "Common/Hook.h"
|
||||||
#include "DDraw/DirectDraw.h"
|
#include "DDraw/DirectDraw.h"
|
||||||
#include "DDraw/ScopedThreadLock.h"
|
#include "DDraw/ScopedThreadLock.h"
|
||||||
|
#include "Gdi/Gdi.h"
|
||||||
#include "Win32/DisplayMode.h"
|
#include "Win32/DisplayMode.h"
|
||||||
|
|
||||||
BOOL WINAPI DWM8And16Bit_IsShimApplied_CallOut() { return FALSE; };
|
BOOL WINAPI DWM8And16Bit_IsShimApplied_CallOut() { return FALSE; };
|
||||||
@ -279,8 +280,7 @@ namespace
|
|||||||
int WINAPI getDeviceCaps(HDC hdc, int nIndex)
|
int WINAPI getDeviceCaps(HDC hdc, int nIndex)
|
||||||
{
|
{
|
||||||
LOG_FUNC("GetDeviceCaps", hdc, nIndex);
|
LOG_FUNC("GetDeviceCaps", hdc, nIndex);
|
||||||
if (hdc && BITSPIXEL == nIndex &&
|
if (BITSPIXEL == nIndex && Gdi::isDisplayDc(hdc))
|
||||||
DT_RASDISPLAY == GetDeviceCaps(hdc, TECHNOLOGY) && OBJ_DC == GetObjectType(hdc))
|
|
||||||
{
|
{
|
||||||
return LOG_RESULT(g_currentBpp);
|
return LOG_RESULT(g_currentBpp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user