diff options
author | Thorbjørn Lund Martsum <tmartsum@gmail.com> | 2019-05-22 09:32:05 +0200 |
---|---|---|
committer | Thorbjørn Lund Martsum <tmartsum@gmail.com> | 2019-05-22 11:22:26 +0200 |
commit | 48f7f65dc34a9ef97d6b4cbca5fc251a7127f1a9 (patch) | |
tree | 803f699caae9505ed8db21e2a1c639d8a25147da /src | |
parent | d661a22ae283c604e9e95eceeaf4e6b47e7e1753 (diff) |
QMenu size fix - Mark items dirty on screen change
It seems like an optimization on the itemsDirty flag
caused a bug to be re-introduced. When a popup is shown
on a new screen, the itemsDirty must however be set to
ensure that new correct sizes are calculated.
Task-number: QTBUG-59794
Change-Id: Ifb5c233b1f9d4d38bd0cd7a9a71cc32ad3212f8c
Reviewed-by: Morten Kristensen <msk@nullpointer.dk>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 9 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget_p.h | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 7 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 53d87c6113..59053f3539 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2580,14 +2580,15 @@ void QWidgetPrivate::createWinId() /*! \internal Ensures that the widget is set on the screen point is on. This is handy getting a correct -size hint before a resize in e.g QMenu and QToolTip +size hint before a resize in e.g QMenu and QToolTip. +Returns if the screen was changed. */ -void QWidgetPrivate::setScreenForPoint(const QPoint &pos) +bool QWidgetPrivate::setScreenForPoint(const QPoint &pos) { Q_Q(QWidget); if (!q->isWindow()) - return; + return false; // Find the screen for pos and make the widget undertand it is on that screen. const QScreen *currentScreen = windowHandle() ? windowHandle()->screen() : nullptr; QScreen *actualScreen = QGuiApplication::screenAt(pos); @@ -2596,7 +2597,9 @@ void QWidgetPrivate::setScreenForPoint(const QPoint &pos) createWinId(); if (windowHandle()) windowHandle()->setScreen(actualScreen); + return true; } + return false; } /*! diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 7e4ea2cc0c..ae50624c04 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -355,7 +355,7 @@ public: void createRecursively(); void createWinId(); - void setScreenForPoint(const QPoint &pos); + bool setScreenForPoint(const QPoint &pos); void createTLExtra(); void createExtra(); diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index a8cca2ae3a..5b1f609b7e 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -73,6 +73,7 @@ #endif #include "qpushbutton.h" #include "qtooltip.h" +#include <qwindow.h> #include <private/qpushbutton_p.h> #include <private/qaction_p.h> #include <private/qguiapplication_p.h> @@ -2356,8 +2357,10 @@ void QMenu::popup(const QPoint &p, QAction *atAction) d->motions = 0; d->doChildEffects = true; d->updateLayoutDirection(); - // Ensure that we get correct sizeHints by placing this window on the right screen. - d->setScreenForPoint(p); + + // Ensure that we get correct sizeHints by placing this window on the correct screen. + if (d->setScreenForPoint(p)) + d->itemsDirty = true; const bool contextMenu = d->isContextMenu(); if (d->lastContextMenu != contextMenu) { |