summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qplatformwindow.cpp
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2015-10-30 15:58:10 +0100
committerAleix Pol Gonzalez <aleixpol@kde.org>2015-11-16 16:01:03 +0000
commitd2792d2ed90e1e2789aa80f1667d6e67cd35af66 (patch)
treeac06248842a9f8b5f7c7c3b83a6ed30a78fc6bb5 /src/gui/kernel/qplatformwindow.cpp
parentd0f57439d02582cf7564d1509d13f715eadc7f05 (diff)
Fix screenForGeometry on a corner case
QRect only deals with integers, and I had a window set on the corner and without a size. When this screen was created, it was reported to be on the wrong screen, thus created there wrong. The reason for this is that ::center is not prepared for this use. QRect(QPoint(500,500), QSize()).center() is QRect(499, 499) Change-Id: I24e57182f84873306f180749e96368d6da1147a9 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qplatformwindow.cpp')
-rw-r--r--src/gui/kernel/qplatformwindow.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index ea3b75c81c..8757715c0d 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -484,7 +484,9 @@ QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) co
{
QPlatformScreen *currentScreen = screen();
QPlatformScreen *fallback = currentScreen;
- QPoint center = newGeometry.center();
+ //QRect::center can return a value outside the rectangle if it's empty
+ const QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center();
+
if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) {
Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) {
if (screen->geometry().contains(center))