From 95a08a711e18c7d994085dff6c1d4df065fb273e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 23 Jan 2018 16:47:01 +0100 Subject: Windows QPA: Suppress bogus resize events when using native menus Account for the (not yet created) native menu height when handling the initial resize message. Complements 7849aa6e96aa923fca5523afc8cf88edcc0bcf90. Task-number: QTBUG-65917 Task-number: QTBUG-55967 Change-Id: I65c75d796634ecf1a90a72fef8ff3e6e89de11c4 Reviewed-by: Oliver Wolff Reviewed-by: J-P Nurmi --- src/plugins/platforms/windows/qwindowscontext.cpp | 6 ++++-- src/plugins/platforms/windows/qwindowswindow.cpp | 6 ++++-- src/plugins/platforms/windows/qwindowswindow.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 9912e03cb9..07efac3117 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -996,8 +996,10 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::QuerySizeHints: d->m_creationContext->applyToMinMaxInfo(reinterpret_cast(lParam)); return true; - case QtWindows::ResizeEvent: - d->m_creationContext->obtainedGeometry.setSize(QSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); + case QtWindows::ResizeEvent: { + const QSize size(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) - d->m_creationContext->menuHeight); + d->m_creationContext->obtainedGeometry.setSize(size); + } return true; case QtWindows::MoveEvent: d->m_creationContext->obtainedGeometry.moveTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 1d81fa9cd5..995b1a2582 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1027,8 +1027,10 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, const QMargins effectiveMargins = margins + customMargins; frameWidth = effectiveMargins.left() + geometry.width() + effectiveMargins.right(); frameHeight = effectiveMargins.top() + geometry.height() + effectiveMargins.bottom(); - if (QWindowsMenuBar::menuBarOf(w) != nullptr) - frameHeight += GetSystemMetrics(SM_CYMENU); + if (QWindowsMenuBar::menuBarOf(w) != nullptr) { + menuHeight = GetSystemMetrics(SM_CYMENU); + frameHeight += menuHeight; + } const bool isDefaultPosition = !frameX && !frameY && w->isTopLevel(); if (!QWindowsGeometryHint::positionIncludesFrame(w) && !isDefaultPosition) { frameX -= effectiveMargins.left(); diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 414d4a92f8..4e1f49be3b 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -101,6 +101,7 @@ struct QWindowCreationContext int frameY = CW_USEDEFAULT; int frameWidth = CW_USEDEFAULT; int frameHeight = CW_USEDEFAULT; + int menuHeight = 0; }; struct QWindowsWindowData -- cgit v1.2.3