From 973435e5df9b973b9b8c56380cd19bf0ce2841aa Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 30 Mar 2020 21:48:41 +0800 Subject: [PATCH] Update. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- winnativeeventfilter.cpp | 7 ++++++- winnativeeventfilter.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index e504bf7..cd89601 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -300,7 +300,7 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, break; } case WM_THEMECHANGED: { - data->themeEnabled = IsThemeActive(); + handleThemeChanged(data); break; } case WM_WINDOWPOSCHANGED: { @@ -360,6 +360,7 @@ void WinNativeEventFilter::init(LPWINDOW data) { SetLayeredWindowAttributes(data->hwnd, RGB(255, 0, 255), 0, LWA_COLORKEY); // Make sure our window has the frame shadow. handleDwmCompositionChanged(data); + handleThemeChanged(data); // Tell the window to redraw itself. SetWindowPos(data->hwnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | @@ -444,6 +445,10 @@ void WinNativeEventFilter::handleDwmCompositionChanged(LPWINDOW data) { updateRegion(data); } +void WinNativeEventFilter::handleThemeChanged(LPWINDOW data) { + data->themeEnabled = IsThemeActive(); +} + UINT WinNativeEventFilter::getDpiForWindow(HWND handle) const { const auto getScreenDpi = [this]() -> UINT { // Available since Windows 7. diff --git a/winnativeeventfilter.h b/winnativeeventfilter.h index 60b6f09..e370c3c 100644 --- a/winnativeeventfilter.h +++ b/winnativeeventfilter.h @@ -38,6 +38,7 @@ private: void init(LPWINDOW data); void updateRegion(LPWINDOW data); void handleDwmCompositionChanged(LPWINDOW data); + void handleThemeChanged(LPWINDOW data); UINT getDpiForWindow(HWND handle) const; qreal getDprForWindow(HWND handle) const; int getSystemMetricsForWindow(HWND handle, int index) const;