summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qplatformwindow.cpp24
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp9
2 files changed, 15 insertions, 18 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;
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 8ce6dcc9e7..9d817c2043 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -503,15 +503,6 @@ QWindowsWindow::WindowData
const QWindowCreationContextPtr context(new QWindowCreationContext(w, rect, data.customMargins, style, exStyle));
QWindowsContext::instance()->setWindowCreationContext(context);
- QRect screenGeometry;
- if (QScreen *screen = w->screen())
- screenGeometry = screen->availableVirtualGeometry();
-
- if (context->frameX < screenGeometry.left())
- context->frameX = screenGeometry.left();
- if (context->frameY < screenGeometry.top())
- context->frameY = screenGeometry.top();
-
if (QWindowsContext::verboseWindows)
qDebug().nospace()
<< "CreateWindowEx: " << w << *this