diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-02-14 11:45:13 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-02-19 19:48:15 +0000 |
commit | 655e8623afed01de63ce43f55227fb019e800fe9 (patch) | |
tree | 38fa7671f36a3dc2d5e40a112c0313ca01a7d44f /src/widgets/widgets/qsplashscreen.cpp | |
parent | 93a78799c3df7c8859b2d9addad45bb4a535dc97 (diff) |
Fix QSplashscreen positioning on Android
Android does not use QPlatformWindow::initialGeometry(),
so the underlying assumption of 56e92dfdf255231aff0034d2e197fd096da7f0c0
was wrong. Try to explicitly find a screen and default to primary.
Fixes: QTBUG-73794
Change-Id: Iba3e70657a60babfcedf751335ca55cb971a4f99
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/widgets/widgets/qsplashscreen.cpp')
-rw-r--r-- | src/widgets/widgets/qsplashscreen.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index 4af4f90119..bf6bf1c7c9 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -289,8 +289,7 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap) // 1) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on // QSplashScreen(QWidget *, QPixmap). // 2) If a widget with associated QWindow is found, use that -// 3) When nothing can be found, do not position the widget, allowing for -// QPlatformWindow::initialGeometry() to center it over the cursor +// 3) When nothing can be found, try to center it over the cursor static inline int screenNumberOf(const QDesktopScreenWidget *dsw) { @@ -307,7 +306,15 @@ const QScreen *QSplashScreenPrivate::screenFor(const QWidget *w) if (QWindow *window = p->windowHandle()) return window->screen(); } - return nullptr; +#if QT_CONFIG(cursor) + // Note: We could rely on QPlatformWindow::initialGeometry() to center it + // over the cursor, but not all platforms (namely Android) use that. + if (QGuiApplication::screens().size() > 1) { + if (auto screenAtCursor = QGuiApplication::screenAt(QCursor::pos())) + return screenAtCursor; + } +#endif // cursor + return QGuiApplication::primaryScreen(); } void QSplashScreenPrivate::setPixmap(const QPixmap &p, const QScreen *screen) |