From 7c255ea79e03d16417c6b7cb34ab76dd23dfc659 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sun, 25 Oct 2020 09:57:11 +0800 Subject: [PATCH] Minor tweaks. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- examples/common.pri | 2 +- lib.pro | 2 +- winnativeeventfilter.cpp | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/common.pri b/examples/common.pri index e894d82..1319968 100644 --- a/examples/common.pri +++ b/examples/common.pri @@ -10,7 +10,7 @@ win32 { _CRT_SECURE_NO_WARNINGS CONFIG += windeployqt CONFIG -= embed_manifest_exe - LIBS += -luser32 -lshell32 -lgdi32 -ldwmapi -lshcore -ld2d1 + LIBS += -luser32 -lshell32 -lgdi32 -ldwmapi -lshcore -ld2d1 -luxtheme RC_FILE = $$PWD/windows.rc OTHER_FILES += $$PWD/windows.manifest } diff --git a/lib.pro b/lib.pro index 81ec4b6..d2dd0db 100644 --- a/lib.pro +++ b/lib.pro @@ -25,7 +25,7 @@ win32 { SOURCES += winnativeeventfilter.cpp LINK_TO_SYSTEM_DLL { DEFINES += WNEF_LINK_SYSLIB - LIBS += -luser32 -lshell32 -lgdi32 -ldwmapi -lshcore -ld2d1 + LIBS += -luser32 -lshell32 -lgdi32 -ldwmapi -lshcore -ld2d1 -luxtheme } RC_FILE = framelesshelper.rc } else { diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index c5f8929..1f362fd 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -500,6 +500,7 @@ using WNEF_CORE_DATA = struct _WNEF_CORE_DATA WNEF_GENERATE_WINAPI(PostMessageW, BOOL, HWND, UINT, WPARAM, LPARAM) WNEF_GENERATE_WINAPI(GetMessagePos, DWORD) WNEF_GENERATE_WINAPI(SystemParametersInfoW, BOOL, UINT, UINT, PVOID, UINT) + WNEF_GENERATE_WINAPI(DwmGetColorizationColor, HRESULT, DWORD *, BOOL *) #endif // WNEF_LINK_SYSLIB @@ -638,6 +639,7 @@ using WNEF_CORE_DATA = struct _WNEF_CORE_DATA WNEF_RESOLVE_WINAPI(Shell32, SHAppBarMessage) WNEF_RESOLVE_WINAPI(Kernel32, GetCurrentProcess) // Available since Windows Vista. + WNEF_RESOLVE_WINAPI(Dwmapi, DwmGetColorizationColor) WNEF_RESOLVE_WINAPI(User32, IsProcessDPIAware) WNEF_RESOLVE_WINAPI(Dwmapi, DwmGetWindowAttribute) WNEF_RESOLVE_WINAPI(Dwmapi, DwmIsCompositionEnabled) @@ -2518,16 +2520,19 @@ bool WinNativeEventFilter::colorizationEnabled() QColor WinNativeEventFilter::colorizationColor() { - /* +#if 1 DWORD color = 0; BOOL opaqueBlend = FALSE; - return SUCCEEDED(DwmGetColorizationColor(&color, &opaqueBlend)) ? QColor::fromRgba(color) - : Qt::white; - */ + return SUCCEEDED( + WNEF_EXECUTE_WINAPI_RETURN(DwmGetColorizationColor, E_FAIL, &color, &opaqueBlend)) + ? QColor::fromRgba(color) + : Qt::white; +#else bool ok = false; const QSettings registry(g_sDwmRegistryKey, QSettings::NativeFormat); const quint64 color = registry.value(QLatin1String("ColorizationColor"), 0).toULongLong(&ok); return ok ? QColor::fromRgba(color) : Qt::white; +#endif } bool WinNativeEventFilter::lightThemeEnabled()