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 <DDraw/Surfaces/PrimarySurface.h>
|
||||||
#include <Gdi/Caret.h>
|
#include <Gdi/Caret.h>
|
||||||
#include <Gdi/Cursor.h>
|
#include <Gdi/Cursor.h>
|
||||||
@ -15,6 +18,12 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
HRESULT WINAPI dwmEnableComposition([[maybe_unused]] UINT uCompositionAction)
|
||||||
|
{
|
||||||
|
LOG_FUNC("DwmEnableComposition", uCompositionAction);
|
||||||
|
return LOG_RESULT(0);
|
||||||
|
}
|
||||||
|
|
||||||
BOOL CALLBACK redrawWindowCallback(HWND hwnd, LPARAM lParam)
|
BOOL CALLBACK redrawWindowCallback(HWND hwnd, LPARAM lParam)
|
||||||
{
|
{
|
||||||
DWORD windowPid = 0;
|
DWORD windowPid = 0;
|
||||||
@ -29,6 +38,17 @@ namespace
|
|||||||
|
|
||||||
namespace Gdi
|
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()
|
void dllThreadDetach()
|
||||||
{
|
{
|
||||||
WinProc::dllThreadDetach();
|
WinProc::dllThreadDetach();
|
||||||
@ -37,6 +57,11 @@ namespace Gdi
|
|||||||
|
|
||||||
void installHooks()
|
void installHooks()
|
||||||
{
|
{
|
||||||
|
#pragma warning (disable : 4995)
|
||||||
|
HOOK_FUNCTION(dwmapi, DwmEnableComposition, dwmEnableComposition);
|
||||||
|
#pragma warning (default : 4995)
|
||||||
|
|
||||||
|
checkDesktopComposition();
|
||||||
DisableProcessWindowsGhosting();
|
DisableProcessWindowsGhosting();
|
||||||
|
|
||||||
DcFunctions::installHooks();
|
DcFunctions::installHooks();
|
||||||
|
@ -10,6 +10,7 @@ namespace Gdi
|
|||||||
|
|
||||||
typedef void(*WindowPosChangeNotifyFunc)();
|
typedef void(*WindowPosChangeNotifyFunc)();
|
||||||
|
|
||||||
|
void checkDesktopComposition();
|
||||||
void dllThreadDetach();
|
void dllThreadDetach();
|
||||||
void installHooks();
|
void installHooks();
|
||||||
bool isDisplayDc(HDC dc);
|
bool isDisplayDc(HDC dc);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <Gdi/CompatDc.h>
|
#include <Gdi/CompatDc.h>
|
||||||
#include <Gdi/Cursor.h>
|
#include <Gdi/Cursor.h>
|
||||||
#include <Gdi/Dc.h>
|
#include <Gdi/Dc.h>
|
||||||
|
#include <Gdi/Gdi.h>
|
||||||
#include <Gdi/PresentationWindow.h>
|
#include <Gdi/PresentationWindow.h>
|
||||||
#include <Gdi/ScrollBar.h>
|
#include <Gdi/ScrollBar.h>
|
||||||
#include <Gdi/ScrollFunctions.h>
|
#include <Gdi/ScrollFunctions.h>
|
||||||
@ -55,14 +56,16 @@ namespace
|
|||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_DISPLAYCHANGE:
|
case WM_DISPLAYCHANGE:
|
||||||
{
|
|
||||||
if (0 != wParam)
|
if (0 != wParam)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
wParam = Win32::DisplayMode::getBpp();
|
wParam = Win32::DisplayMode::getBpp();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case WM_DWMCOMPOSITIONCHANGED:
|
||||||
|
Gdi::checkDesktopComposition();
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO:
|
||||||
onGetMinMaxInfo(*reinterpret_cast<MINMAXINFO*>(lParam));
|
onGetMinMaxInfo(*reinterpret_cast<MINMAXINFO*>(lParam));
|
||||||
|
@ -159,6 +159,9 @@ namespace
|
|||||||
void updatePosition(Window& window, const RECT& oldWindowRect, const RECT& oldClientRect,
|
void updatePosition(Window& window, const RECT& oldWindowRect, const RECT& oldClientRect,
|
||||||
const Gdi::Region& oldVisibleRegion, Gdi::Region& invalidatedRegion)
|
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 =
|
const bool isClientOriginChanged =
|
||||||
window.clientRect.left - window.windowRect.left != oldClientRect.left - oldWindowRect.left ||
|
window.clientRect.left - window.windowRect.left != oldClientRect.left - oldWindowRect.left ||
|
||||||
window.clientRect.top - window.windowRect.top != oldClientRect.top - oldWindowRect.top;
|
window.clientRect.top - window.windowRect.top != oldClientRect.top - oldWindowRect.top;
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <VersionHelpers.h>
|
||||||
|
|
||||||
#include <Common/Comparison.h>
|
#include <Common/Comparison.h>
|
||||||
#include <Common/CompatPtr.h>
|
#include <Common/CompatPtr.h>
|
||||||
#include <Common/Hook.h>
|
#include <Common/Hook.h>
|
||||||
@ -252,8 +255,11 @@ namespace
|
|||||||
Compat::removeShim(user32, "EnumDisplaySettingsExA");
|
Compat::removeShim(user32, "EnumDisplaySettingsExA");
|
||||||
Compat::removeShim(user32, "EnumDisplaySettingsExW");
|
Compat::removeShim(user32, "EnumDisplaySettingsExW");
|
||||||
|
|
||||||
HOOK_FUNCTION(apphelp, DWM8And16Bit_IsShimApplied_CallOut, dwm8And16BitIsShimAppliedCallOut);
|
if (IsWindows8OrGreater())
|
||||||
HOOK_FUNCTION(apphelp, SE_COM_HookInterface, seComHookInterface);
|
{
|
||||||
|
HOOK_FUNCTION(apphelp, DWM8And16Bit_IsShimApplied_CallOut, dwm8And16BitIsShimAppliedCallOut);
|
||||||
|
HOOK_FUNCTION(apphelp, SE_COM_HookInterface, seComHookInterface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI dwm8And16BitIsShimAppliedCallOut()
|
BOOL WINAPI dwm8And16BitIsShimAppliedCallOut()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user