diff --git a/DDrawCompat/Gdi/Gdi.cpp b/DDrawCompat/Gdi/Gdi.cpp index 80f363e..700e6a1 100644 --- a/DDrawCompat/Gdi/Gdi.cpp +++ b/DDrawCompat/Gdi/Gdi.cpp @@ -1,3 +1,6 @@ +#include + +#include #include #include #include @@ -15,6 +18,12 @@ namespace { + HRESULT WINAPI dwmEnableComposition([[maybe_unused]] UINT uCompositionAction) + { + LOG_FUNC("DwmEnableComposition", uCompositionAction); + return LOG_RESULT(0); + } + BOOL CALLBACK redrawWindowCallback(HWND hwnd, LPARAM lParam) { DWORD windowPid = 0; @@ -29,6 +38,17 @@ namespace namespace Gdi { + void checkDesktopComposition() + { + BOOL isEnabled = FALSE; + HRESULT result = DwmIsCompositionEnabled(&isEnabled); + LOG_DEBUG << "DwmIsCompositionEnabled: " << Compat::hex(result) << " " << isEnabled; + if (!isEnabled) + { + LOG_ONCE("Warning: Desktop composition is disabled. This is not supported."); + } + } + void dllThreadDetach() { WinProc::dllThreadDetach(); @@ -37,6 +57,11 @@ namespace Gdi void installHooks() { +#pragma warning (disable : 4995) + HOOK_FUNCTION(dwmapi, DwmEnableComposition, dwmEnableComposition); +#pragma warning (default : 4995) + + checkDesktopComposition(); DisableProcessWindowsGhosting(); DcFunctions::installHooks(); diff --git a/DDrawCompat/Gdi/Gdi.h b/DDrawCompat/Gdi/Gdi.h index ad44b1a..746d434 100644 --- a/DDrawCompat/Gdi/Gdi.h +++ b/DDrawCompat/Gdi/Gdi.h @@ -10,6 +10,7 @@ namespace Gdi typedef void(*WindowPosChangeNotifyFunc)(); + void checkDesktopComposition(); void dllThreadDetach(); void installHooks(); bool isDisplayDc(HDC dc); diff --git a/DDrawCompat/Gdi/WinProc.cpp b/DDrawCompat/Gdi/WinProc.cpp index 7a0041d..95efb3c 100644 --- a/DDrawCompat/Gdi/WinProc.cpp +++ b/DDrawCompat/Gdi/WinProc.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -55,14 +56,16 @@ namespace switch (uMsg) { case WM_DISPLAYCHANGE: - { if (0 != wParam) { return 0; } wParam = Win32::DisplayMode::getBpp(); break; - } + + case WM_DWMCOMPOSITIONCHANGED: + Gdi::checkDesktopComposition(); + break; case WM_GETMINMAXINFO: onGetMinMaxInfo(*reinterpret_cast(lParam)); diff --git a/DDrawCompat/Gdi/Window.cpp b/DDrawCompat/Gdi/Window.cpp index 34a0b08..656b7c1 100644 --- a/DDrawCompat/Gdi/Window.cpp +++ b/DDrawCompat/Gdi/Window.cpp @@ -159,6 +159,9 @@ namespace void updatePosition(Window& window, const RECT& oldWindowRect, const RECT& oldClientRect, const Gdi::Region& oldVisibleRegion, Gdi::Region& invalidatedRegion) { + LOG_FUNC("Window::updatePosition", window.hwnd, oldWindowRect, oldClientRect, + static_cast(oldVisibleRegion), static_cast(invalidatedRegion)); + const bool isClientOriginChanged = window.clientRect.left - window.windowRect.left != oldClientRect.left - oldWindowRect.left || window.clientRect.top - window.windowRect.top != oldClientRect.top - oldWindowRect.top; diff --git a/DDrawCompat/Win32/DisplayMode.cpp b/DDrawCompat/Win32/DisplayMode.cpp index 4ee377c..dec79d8 100644 --- a/DDrawCompat/Win32/DisplayMode.cpp +++ b/DDrawCompat/Win32/DisplayMode.cpp @@ -3,6 +3,9 @@ #include #include +#include +#include + #include #include #include @@ -252,8 +255,11 @@ namespace Compat::removeShim(user32, "EnumDisplaySettingsExA"); Compat::removeShim(user32, "EnumDisplaySettingsExW"); - HOOK_FUNCTION(apphelp, DWM8And16Bit_IsShimApplied_CallOut, dwm8And16BitIsShimAppliedCallOut); - HOOK_FUNCTION(apphelp, SE_COM_HookInterface, seComHookInterface); + if (IsWindows8OrGreater()) + { + HOOK_FUNCTION(apphelp, DWM8And16Bit_IsShimApplied_CallOut, dwm8And16BitIsShimAppliedCallOut); + HOOK_FUNCTION(apphelp, SE_COM_HookInterface, seComHookInterface); + } } BOOL WINAPI dwm8And16BitIsShimAppliedCallOut()