diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-05-16 20:43:34 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-06-08 20:29:49 +0200 |
commit | 44fb925f50471ebc23dcccfaa4e9d9873b05d205 (patch) | |
tree | e4e212052b66242ff94aa98f6df7b15dbeb945f7 /src/widgets/widgets/qmenu.cpp | |
parent | a061a646429c6e9d695458fc0ecb0021a30e12ee (diff) |
Phase 2 of removing QDesktopWidget
Remove QDestopWidget public header, simplify the implementation that
maintains a Qt::Desktop type QWidget for each QScreen, and turn
QWidget's initial target screen into a QScreen pointer.
QApplication::desktop() now takes an optional QScreen pointer, and
returns a QWidget pointer, so that applications and widgets can get
access to the root widget for a specific screen without having to
resort to private APIs.
QDesktopWidgetPrivate implementations to look up a screen for an index,
widget, or point are now all inline functions that thinly wrap
QGuiApplication::screens/screenAt calls. We should consider adding those
as convenience APIs to QScreen instead.
Note that QWidget::screen is assumed to return a valid pointer; there is
code that handles the case that it returns nullptr (but also code that
trusts that it never is nullptr), so this needs to be defined, verified
with tests, and asserted. We can then simplify the code further.
Change-Id: Ifc89be65a0dce265b6729feaf54121c35137cb94
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/widgets/widgets/qmenu.cpp')
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index fdfa9b327f..b578f476e9 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -54,7 +54,6 @@ #include "qmacnativewidget_mac.h" #endif #include "qapplication.h" -#include "qdesktopwidget.h" #ifndef QT_NO_ACCESSIBILITY # include "qaccessible.h" #endif @@ -324,8 +323,8 @@ QRect QMenuPrivate::popupGeometry() const { Q_Q(const QMenu); return useFullScreenForPopup() - ? QDesktopWidgetPrivate::screenGeometry(q) - : QDesktopWidgetPrivate::availableGeometry(q); + ? QWidgetPrivate::screenGeometry(q) + : QWidgetPrivate::availableScreenGeometry(q); } QRect QMenuPrivate::popupGeometry(int screen) const @@ -2385,15 +2384,12 @@ void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction po // Ensure that we get correct sizeHints by placing this window on the correct screen. // However if the QMenu was constructed with a QDesktopScreenWidget as its parent, // then initialScreenIndex was set, so we should respect that for the lifetime of this menu. - // Use d->popupScreen to remember, because initialScreenIndex will be reset after the first showing. // However if eventLoop exists, then exec() already did this by calling createWinId(); so leave it alone. (QTBUG-76162) if (!eventLoop) { bool screenSet = false; - const int screenIndex = topData()->initialScreenIndex; - if (screenIndex >= 0) - popupScreen = screenIndex; - if (auto s = QGuiApplication::screens().value(popupScreen)) { - if (setScreen(s)) + QScreen *screen = topData()->initialScreen; + if (screen) { + if (setScreen(screen)) itemsDirty = true; screenSet = true; } else if (QMenu *parentMenu = qobject_cast<QMenu *>(parent)) { |