diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-05 14:19:06 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-18 10:15:26 +0200 |
commit | eed9a8fbd300dafb2802b6c09c018fbda4e13ef1 (patch) | |
tree | f7dd03d516d76be452336c1c086438ade2544b40 /src/widgets/styles/qwindowsstyle.cpp | |
parent | cd563b3497a608a91794a7a086e5fbf248e77998 (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/styles/qwindowsstyle.cpp')
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 7b5da9bfa8..3c0478b84e 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -380,23 +380,12 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm) return QWindowsStylePrivate::InvalidMetric; } -static QWindow *windowOf(const QWidget *w) +static QScreen *screenOf(const QWidget *w) { - QWindow *result = nullptr; if (w) { - result = w->windowHandle(); - if (!result) { - if (const QWidget *np = w->nativeParentWidget()) - result = np->windowHandle(); - } + if (auto screen = qt_widget_private(const_cast<QWidget *>(w))->associatedScreen()) + return screen; } - return result; -} - -static QScreen *screenOf(const QWidget *w) -{ - if (const QWindow *window = windowOf(w)) - return window->screen(); return QGuiApplication::primaryScreen(); } |