diff options
Diffstat (limited to 'src/plugins/platforms/windows/qwindowswindow.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 0b4bb9b09d..5768800947 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -801,7 +801,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, const QRect &geometry, const QMargins &cm, DWORD style_, DWORD exStyle_) : - geometryHint(w, cm), style(style_), exStyle(exStyle_), + geometryHint(w, cm), window(w), style(style_), exStyle(exStyle_), requestedGeometry(geometry), obtainedGeometry(geometry), margins(QWindowsGeometryHint::frame(style, exStyle)), customMargins(cm), frameX(CW_USEDEFAULT), frameY(CW_USEDEFAULT), @@ -1783,16 +1783,14 @@ void QWindowsWindow::propagateSizeHints() qCDebug(lcQpaWindows) << __FUNCTION__ << this << window(); } -bool QWindowsWindow::handleGeometryChanging(MSG *message) const +bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &marginsDp) { #ifndef Q_OS_WINCE - QWindow *qWin = window(); - if (!qWin->isTopLevel()) + if (!qWindow->isTopLevel()) // Implement hasHeightForWidth(). return false; WINDOWPOS *windowPos = reinterpret_cast<WINDOWPOS *>(message->lParam); if ((windowPos->flags & (SWP_NOCOPYBITS | SWP_NOSIZE))) return false; - const QMargins marginsDp = frameMarginsDp(); const QRect suggestedFrameGeometryDp(windowPos->x, windowPos->y, windowPos->cx, windowPos->cy); const qreal factor = QWindowsScaling::factor(); @@ -1800,7 +1798,7 @@ bool QWindowsWindow::handleGeometryChanging(MSG *message) const const QRectF suggestedGeometry = QRectF(QPointF(suggestedGeometryDp.topLeft()) / factor, QSizeF(suggestedGeometryDp.size()) / factor); const QRectF correctedGeometryF = - qt_window_private(qWin)->closestAcceptableGeometry(suggestedGeometry); + qt_window_private(const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(suggestedGeometry); if (!correctedGeometryF.isValid()) return false; const QRect correctedFrameGeometryDp @@ -1820,6 +1818,12 @@ bool QWindowsWindow::handleGeometryChanging(MSG *message) const #endif } +bool QWindowsWindow::handleGeometryChanging(MSG *message) const +{ + const QMargins marginsDp = window()->isTopLevel() ? frameMarginsDp() : QMargins(); + return QWindowsWindow::handleGeometryChangingMessage(message, window(), marginsDp); +} + QMargins QWindowsWindow::frameMarginsDp() const { // Frames are invalidated by style changes (window state, flags). @@ -1827,7 +1831,12 @@ QMargins QWindowsWindow::frameMarginsDp() const // event sequences, introduce a dirty flag mechanism to be able // to cache results. if (testFlag(FrameDirty)) { - m_data.frame = QWindowsGeometryHint::frame(style(), exStyle()); + // Always skip calculating style-dependent margins for windows claimed to be frameless. + // This allows users to remove the margins by handling WM_NCCALCSIZE with WS_THICKFRAME set + // to ensure Areo snap still works (QTBUG-40578). + m_data.frame = window()->flags() & Qt::FramelessWindowHint + ? QMargins(0, 0, 0, 0) + : QWindowsGeometryHint::frame(style(), exStyle()); clearFlag(FrameDirty); } return m_data.frame + m_data.customMargins; |