diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-03-09 11:07:42 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-03-13 15:11:00 +0000 |
commit | 1d403ef81a2b9b19383f45b27d53149e122d65d8 (patch) | |
tree | 97d1b371fdfebb547b87cf099da4541f2c31f7ce /src/plugins/platforms/windows/qwindowsmenu.cpp | |
parent | d8ab719c0890195cfce0fb6d4c76b3664d6f3a9d (diff) |
Windows QPA: Fix broken frame geometry when moving windows with native menus
QWindowsWindow::updateFullFrameMargins() which is called
from the screen changed handling does not take native menus
into account.
Since the size of the menu is not known when using
EnableNonClientDpiScaling(), obtaining the correct frame
size requires triggering a WM_NCCALCSIZE message. Extract
the helper forceNcCalcSize() from QWindowsMenu and
use that from updateFullFrameMargins() in case menus are present.
Amends d2fd9b1b9818b3ec88487967e010f66e92952f55.
Fixes: QTBUG-82580
Change-Id: I306f1faf84e26c88608cb22ffd42eccc848905c3
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsmenu.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsmenu.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index d20edd685e..221e4ff6ec 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -794,20 +794,13 @@ QWindowsMenuBar *QWindowsMenuBar::menuBarOf(const QWindow *notYetCreatedWindow) ? qobject_cast<QWindowsMenuBar *>(menuBarV.value<QObject *>()) : nullptr; } -static inline void forceNcCalcSize(HWND hwnd) -{ - // Force WM_NCCALCSIZE to adjust margin: Does not appear to work? - SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, - SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); -} - void QWindowsMenuBar::install(QWindowsWindow *window) { const HWND hwnd = window->handle(); const BOOL result = SetMenu(hwnd, m_hMenuBar); if (result) { window->setMenuBar(this); - forceNcCalcSize(hwnd); + QWindowsContext::forceNcCalcSize(hwnd); } } @@ -817,7 +810,7 @@ void QWindowsMenuBar::removeFromWindow() const HWND hwnd = window->handle(); SetMenu(hwnd, nullptr); window->setMenuBar(nullptr); - forceNcCalcSize(hwnd); + QWindowsContext::forceNcCalcSize(hwnd); } } |