From d2fd9b1b9818b3ec88487967e010f66e92952f55 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 6 May 2019 15:06:52 +0200 Subject: Windows QPA: Fix window frame calculation in multi-monitor setups When introducing EnableNonClientDpiScaling() for QTBUG-53255, the window frame calculation was not adapted. That is, window frames were calculated from the style for the primary screen only, causing - minimum size constraints not being calculated correctly for applications on secondary screens when populating the MINMAXINFO structure. - warnings about not being able to apply a geometry when moving fixed size windows across screens. The calculation of the frames for propagating size hints is also no longer required after 3035400f36731c400adb9204b94e9afe346a71b7, which retrieves them from the WM_NCCALCSIZE message; QWindowsWindow::fullFrameMargins() can be used instead. For newly created windows, use the newly added AdjustWindowRectExForDpi() function to calculate the initial frame size. Change QWindowsGeometryHint from a class to a collection of static functions and add overloads to calculate the frame. In checkForScreenChanged(), update the margins until WM_NCCALCSIZE is received. Task-number: QTBUG-67777 Task-number: QTBUG-65580 Task-number: QTBUG-53255 Change-Id: Iff2d382b2b316adec6c1a0622ae8015dba6de371 Reviewed-by: Oliver Wolff Reviewed-by: Andre de la Rocha --- src/plugins/platforms/windows/qwindowswindow.h | 31 ++++++++++++-------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'src/plugins/platforms/windows/qwindowswindow.h') diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 2675990cf1..5e44511e5d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -59,24 +59,23 @@ class QDebug; struct QWindowsGeometryHint { - QWindowsGeometryHint() = default; - explicit QWindowsGeometryHint(const QWindow *w, const QMargins &customMargins); - static QMargins frame(DWORD style, DWORD exStyle); + static QMargins frameOnPrimaryScreen(DWORD style, DWORD exStyle); + static QMargins frameOnPrimaryScreen(HWND hwnd); + static QMargins frame(DWORD style, DWORD exStyle, qreal dpi); + static QMargins frame(HWND hwnd, DWORD style, DWORD exStyle); + static QMargins frame(const QWindow *w, const QRect &geometry, + DWORD style, DWORD exStyle); static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result); - void applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXINFO *mmi) const; - void applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const; - bool validSize(const QSize &s) const; - + static void applyToMinMaxInfo(const QWindow *w, const QMargins &margins, + MINMAXINFO *mmi); + static void frameSizeConstraints(const QWindow *w, const QMargins &margins, + QSize *minimumSize, QSize *maximumSize); static inline QPoint mapToGlobal(HWND hwnd, const QPoint &); static inline QPoint mapToGlobal(const QWindow *w, const QPoint &); static inline QPoint mapFromGlobal(const HWND hwnd, const QPoint &); static inline QPoint mapFromGlobal(const QWindow *w, const QPoint &); static bool positionIncludesFrame(const QWindow *w); - - QSize minimumSize; - QSize maximumSize; - QMargins customMargins; }; struct QWindowCreationContext @@ -85,13 +84,9 @@ struct QWindowCreationContext const QRect &geometryIn, const QRect &geometry, const QMargins &customMargins, DWORD style, DWORD exStyle); - void applyToMinMaxInfo(MINMAXINFO *mmi) const - { geometryHint.applyToMinMaxInfo(style, exStyle, mmi); } + void applyToMinMaxInfo(MINMAXINFO *mmi) const; - QWindowsGeometryHint geometryHint; const QWindow *window; - DWORD style; - DWORD exStyle; QRect requestedGeometryIn; // QWindow scaled QRect requestedGeometry; // after QPlatformWindow::initialGeometry() QRect obtainedGeometry; @@ -221,7 +216,8 @@ public: HasBorderInFullScreen = 0x200000, WithinDpiChanged = 0x400000, VulkanSurface = 0x800000, - ResizeMoveActive = 0x1000000 + ResizeMoveActive = 0x1000000, + DisableNonClientScaling = 0x2000000 }; QWindowsWindow(QWindow *window, const QWindowsWindowData &data); @@ -262,6 +258,7 @@ public: QMargins frameMargins() const override; QMargins fullFrameMargins() const override; void setFullFrameMargins(const QMargins &newMargins); + void updateFullFrameMargins(); void setOpacity(qreal level) override; void setMask(const QRegion ®ion) override; -- cgit v1.2.3