QPA: Prevent QPlatformWindow::initialGeometry() from returning invalid geometries
When trying to find the screen, the function would always try to determine the screen by checking parents, despite QWindowPrivate::positionAutomatic being false. Determine the screen from the initial geometry when QWindowPrivate::positionAutomatic is false. Bail out when positionAutomatic and resizeAutomatic are false. Fixes: QTBUG-75940 Change-Id: I3cd1b16feab16c89d29856cf3e1bccf2c89280c7 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
This commit is contained in:
parent
eea6c920c9
commit
6fb2b4b271
@ -705,14 +705,20 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w,
|
|||||||
w, defaultWidth, defaultHeight);
|
w, defaultWidth, defaultHeight);
|
||||||
return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor));
|
return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor));
|
||||||
}
|
}
|
||||||
const QScreen *screen = effectiveScreen(w);
|
const auto *wp = qt_window_private(const_cast<QWindow*>(w));
|
||||||
|
const bool position = wp->positionAutomatic && w->type() != Qt::Popup;
|
||||||
|
if (!position && !wp->resizeAutomatic)
|
||||||
|
return initialGeometry;
|
||||||
|
const QScreen *screen = wp->positionAutomatic
|
||||||
|
? effectiveScreen(w)
|
||||||
|
: QGuiApplication::screenAt(initialGeometry.center());
|
||||||
if (!screen)
|
if (!screen)
|
||||||
return initialGeometry;
|
return initialGeometry;
|
||||||
const auto *wp = qt_window_private(const_cast<QWindow*>(w));
|
// initialGeometry refers to window's screen
|
||||||
QRect rect(QHighDpi::fromNativePixels(initialGeometry, w));
|
QRect rect(QHighDpi::fromNativePixels(initialGeometry, w));
|
||||||
if (wp->resizeAutomatic)
|
if (wp->resizeAutomatic)
|
||||||
rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight));
|
rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight));
|
||||||
if (wp->positionAutomatic && w->type() != Qt::Popup) {
|
if (position) {
|
||||||
const QRect availableGeometry = screen->availableGeometry();
|
const QRect availableGeometry = screen->availableGeometry();
|
||||||
// Center unless the geometry ( + unknown window frame) is too large for the screen).
|
// Center unless the geometry ( + unknown window frame) is too large for the screen).
|
||||||
if (rect.height() < (availableGeometry.height() * 8) / 9
|
if (rect.height() < (availableGeometry.height() * 8) / 9
|
||||||
|
Loading…
x
Reference in New Issue
Block a user