summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qdesktopwidget.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-04-05 14:19:06 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-06-18 10:15:26 +0200
commiteed9a8fbd300dafb2802b6c09c018fbda4e13ef1 (patch)
treef7dd03d516d76be452336c1c086438ade2544b40 /src/widgets/kernel/qdesktopwidget.cpp
parentcd563b3497a608a91794a7a086e5fbf248e77998 (diff)
Add accessors for QWindow and QScreen to QWidgetPrivate
Rewrite the existing accessor QWidgetPrivate::windowHandle() to accept a mode enumeration that has an "Any" convenience. Based on that, add QWidgetPrivate::associatedScreen(), which is seful in many places where scaling is performed. Prototypically simplify the code. Task-number: QTBUG-62094 Task-number: QTBUG-73231 Change-Id: I516288363d329bce9bc94e4951106f9357bc6cde Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets/kernel/qdesktopwidget.cpp')
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index d17c7eb36c..ac0cfcf2f5 100644
--- a/src/widgets/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
@@ -321,20 +321,12 @@ int QDesktopWidgetPrivate::screenNumber(const QWidget *w)
if (screens.isEmpty()) // This should never happen
return primaryScreen();
- const QWindow *winHandle = w->windowHandle();
- if (!winHandle) {
- if (const QWidget *nativeParent = w->nativeParentWidget())
- winHandle = nativeParent->windowHandle();
- }
-
// If there is more than one virtual desktop
if (screens.count() != screens.constFirst()->virtualSiblings().count()) {
// Find the root widget, get a QScreen from it and use the
// virtual siblings for checking the window position.
- if (winHandle) {
- if (const QScreen *winScreen = winHandle->screen())
- screens = winScreen->virtualSiblings();
- }
+ if (const QScreen *winScreen = qt_widget_private(const_cast<QWidget *>(w))->associatedScreen())
+ screens = winScreen->virtualSiblings();
}
// Get the screen number from window position using screen geometry