Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-03-30 21:48:41 +08:00
parent b9b2e54427
commit 973435e5df
2 changed files with 7 additions and 1 deletions

View File

@ -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.

View File

@ -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;