diff options
author | Thorbjørn Lund Martsum <tmartsum@gmail.com> | 2022-05-17 09:36:54 +0200 |
---|---|---|
committer | Thorbjørn Lund Martsum <tmartsum@gmail.com> | 2022-05-23 21:12:06 +0200 |
commit | 468b33d8f86a6d127365518ae2d49211bc7cc7d7 (patch) | |
tree | 9d2001c4265a369bff943b4e745ed156fb7f2a7a /src/widgets/widgets/qmenu.cpp | |
parent | 6b02c85f874886e7f5a467a8b63f0ca995b995b7 (diff) |
Fix QMenu size on first show
QWidget::metric is used to calculate the size of the menu, but it
only respects a sceen from a Window handle, so we need to make
sure such a thing is created.
Task-number: QTBUG-103309
Pick-to: 6.2 6.3
Change-Id: Ie73e362cdcb3b59f46ad51c4901fdbeda7258baa
Reviewed-by: Morten Kristensen <me@mortens.dev>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmenu.cpp')
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 8e62928f41..adf538b37a 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -2315,6 +2315,15 @@ void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction po lastContextMenu = contextMenu; } + // Until QWidget::metric accepts the screen set on a widget (without having a window handle) + // we need to make sure we get a window handle. This must be done near here because + // we want the screen to be correctly set and items to be marked dirty. + // (and screen set could 'fail' on oldscreen == newScreen if created before causing the + // itemsDirty not to be set though needed to get the correct size on first show). + if (!windowHandle()) { + createWinId(); + } + #if QT_CONFIG(menubar) // if this menu is part of a chain attached to a QMenuBar, set the // _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type |