diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-05-28 10:17:32 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-28 19:56:50 +0200 |
commit | 81e981a704116ca7b1b619a2c1e8db837046d2cf (patch) | |
tree | 97ec083266ca22031470ac63d13094571c62af81 /src/gui | |
parent | 85a6446164531ad400e1e2a62a42353c85571a2c (diff) |
Fix QPlatformWindow::initialGeometry() to not touch large windows.
Do not touch windows whose geometry (including the unknown frame
size) is likely to be larger than the screen.
Remove fix-up in the Windows plugin.
Task-number: QTBUG-30142
Task-number: QTBUG-31071
Change-Id: I13a8ffb9fb9d8c71d35de75094275388fa427f2c
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index d23cfde172..4c0d68e7c1 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -510,15 +510,21 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, } } if (w->isTopLevel() && qt_window_private(const_cast<QWindow*>(w))->positionAutomatic) { - const QWindow *tp = w->transientParent(); - if (tp) { - // A transient window should be centered w.r.t. its transient parent. - rect.moveCenter(tp->geometry().center()); - } else { - // Center the window on the screen. (Only applicable on platforms - // which do not provide a better way.) - QPlatformScreen *scr = QPlatformScreen::platformScreenForWindow(w); - rect.moveCenter(scr->availableGeometry().center()); + if (const QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(w)) { + const QRect availableGeometry = platformScreen->availableGeometry(); + // Center unless the geometry ( + unknown window frame) is too large for the screen). + if (rect.height() < (availableGeometry.height() * 8) / 9 + && rect.width() < (availableGeometry.width() * 8) / 9) { + const QWindow *tp = w->transientParent(); + if (tp) { + // A transient window should be centered w.r.t. its transient parent. + rect.moveCenter(tp->geometry().center()); + } else { + // Center the window on the screen. (Only applicable on platforms + // which do not provide a better way.) + rect.moveCenter(availableGeometry.center()); + } + } } } return rect; |