mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Block DwmEnableComposition
Fixes main menu flickering in Rogue Spear on Windows 7 (#126)
This commit is contained in:
parent
177b81921a
commit
fa8dec88c5
@ -1,3 +1,6 @@
|
||||
#include <dwmapi.h>
|
||||
|
||||
#include <Common/Hook.h>
|
||||
#include <DDraw/Surfaces/PrimarySurface.h>
|
||||
#include <Gdi/Caret.h>
|
||||
#include <Gdi/Cursor.h>
|
||||
@ -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();
|
||||
|
@ -10,6 +10,7 @@ namespace Gdi
|
||||
|
||||
typedef void(*WindowPosChangeNotifyFunc)();
|
||||
|
||||
void checkDesktopComposition();
|
||||
void dllThreadDetach();
|
||||
void installHooks();
|
||||
bool isDisplayDc(HDC dc);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <Gdi/CompatDc.h>
|
||||
#include <Gdi/Cursor.h>
|
||||
#include <Gdi/Dc.h>
|
||||
#include <Gdi/Gdi.h>
|
||||
#include <Gdi/PresentationWindow.h>
|
||||
#include <Gdi/ScrollBar.h>
|
||||
#include <Gdi/ScrollFunctions.h>
|
||||
@ -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<MINMAXINFO*>(lParam));
|
||||
|
@ -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<HRGN>(oldVisibleRegion), static_cast<HRGN>(invalidatedRegion));
|
||||
|
||||
const bool isClientOriginChanged =
|
||||
window.clientRect.left - window.windowRect.left != oldClientRect.left - oldWindowRect.left ||
|
||||
window.clientRect.top - window.windowRect.top != oldClientRect.top - oldWindowRect.top;
|
||||
|
@ -3,6 +3,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
#include <Common/Comparison.h>
|
||||
#include <Common/CompatPtr.h>
|
||||
#include <Common/Hook.h>
|
||||
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user