diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2014-12-02 14:19:02 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2014-12-04 20:18:13 +0100 |
commit | 50d29a695adc783a49de2c980d55663e27e9da35 (patch) | |
tree | ecfb7db45a33d5ca81a00240a79b30e01fc9d498 | |
parent | 247607a1af0253576b3330075fdcbb3d5c4cca00 (diff) |
Windows: Handle WM_WINDOWPOSCHANGING during window creation.
Fix warnings:
QWindowsContext::windowsProc: No Qt Window found for event 0x46 (WM_WINDOWPOSCHANGING), hwnd=0x0xde0408.
occurring when using Active X controls.
Factor out message handling to a static function which can be used
during window creation when QWindowsWindow does not yet exist.
Task-number: QTBUG-36318
Change-Id: I3ce56fd377e3392b0dd22d3d26a7048065380f13
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 3 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 16 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.h | 2 |
3 files changed, 15 insertions, 6 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 4f1a1a375f..13a3d044a0 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -952,6 +952,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, return true; case QtWindows::CalculateSize: return QWindowsGeometryHint::handleCalculateSize(d->m_creationContext->customMargins, msg, result); + case QtWindows::GeometryChangingEvent: + return QWindowsWindow::handleGeometryChangingMessage(&msg, d->m_creationContext->window, + d->m_creationContext->margins + d->m_creationContext->customMargins); default: break; } diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 0b4bb9b09d..48ffd84f98 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). diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index a63a9f56e3..9822ebce45 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -84,6 +84,7 @@ struct QWindowCreationContext #endif QWindowsGeometryHint geometryHint; + const QWindow *window; DWORD style; DWORD exStyle; QRect requestedGeometry; @@ -183,6 +184,7 @@ public: void windowEvent(QEvent *event); void propagateSizeHints() Q_DECL_OVERRIDE; + static bool handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &marginsDp); bool handleGeometryChanging(MSG *message) const; QMargins frameMarginsDp() const; QMargins frameMargins() const Q_DECL_OVERRIDE { return frameMarginsDp() / QWindowsScaling::factor(); } |