diff --git a/framelesshelper_win32.cpp b/framelesshelper_win32.cpp index 483757a..48096cb 100644 --- a/framelesshelper_win32.cpp +++ b/framelesshelper_win32.cpp @@ -154,7 +154,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me // Anyway, we should skip it in this case. return false; } - const QWindow *window = Utilities::findWindow(reinterpret_cast(msg->hwnd)); + const QWindow * const window = Utilities::findWindow(reinterpret_cast(msg->hwnd)); if (!window || !window->property(Constants::kFramelessModeFlag).toBool()) { return false; } @@ -675,6 +675,12 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me windowPos->flags |= SWP_NOCOPYBITS; } break; #endif + case WM_DPICHANGED: { + // The DPI has changed, we need to update the internal window frame + // recorded in Windows QPA. + Utilities::updateQtFrameMargins(const_cast(window), true); + Utilities::triggerFrameChange(reinterpret_cast(msg->hwnd)); + } break; default: break; } diff --git a/framelesshelper_windows.h b/framelesshelper_windows.h index 6d53db4..a32e725 100644 --- a/framelesshelper_windows.h +++ b/framelesshelper_windows.h @@ -90,6 +90,10 @@ #define WM_DWMCOLORIZATIONCOLORCHANGED (0x0320) #endif +#ifndef WM_DPICHANGED +#define WM_DPICHANGED (0x02E0) +#endif + #ifndef SM_CXPADDEDBORDER #define SM_CXPADDEDBORDER (92) #endif diff --git a/framelessquickhelper.cpp b/framelessquickhelper.cpp index 59a4732..00d37f1 100644 --- a/framelessquickhelper.cpp +++ b/framelessquickhelper.cpp @@ -96,6 +96,9 @@ void FramelessQuickHelper::showMinimized() { #ifdef Q_OS_WINDOWS // Work-around a QtQuick bug: https://bugreports.qt.io/browse/QTBUG-69711 + // Don't use "SW_SHOWMINIMIZED" because it will activate the current + // window instead of the next window in the Z order, that's not the + // native behavior of Windows applications. ShowWindow(reinterpret_cast(window()->winId()), SW_MINIMIZE); #else window()->showMinimized();