From 60768a0af9f8773a46990e40051ac692521af055 Mon Sep 17 00:00:00 2001
From: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Date: Mon, 27 May 2013 13:41:15 +0200
Subject: [PATCH] Windows: Respect geometry set before native window creation

Task-number: QTBUG-31071
Change-Id: Idab21c5996d1dc31b0a6fab4960c3c48a50d4966
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
---
 src/plugins/platforms/windows/qwindowswindow.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 73c78f00903..8ce6dcc9e77 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -503,10 +503,14 @@ QWindowsWindow::WindowData
     const QWindowCreationContextPtr context(new QWindowCreationContext(w, rect, data.customMargins, style, exStyle));
     QWindowsContext::instance()->setWindowCreationContext(context);
 
-    if (context->frameX < 0)
-        context->frameX = 0;
-    if (context->frameY < 0)
-        context->frameY = 0;
+    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()
-- 
GitLab