From acb8016e65bee17bd26be47595b73d99013e681b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 6 Feb 2015 16:29:12 +0100 Subject: [PATCH] make checkOffscreenPosition multiscreen aware on a multiscreen setup, the window can be off in multiple directions CCBUG: 336193 REVIEW: 124122 --- geometry.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/geometry.cpp b/geometry.cpp index 5b02a46247..f83ac7886a 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1225,13 +1225,15 @@ void Client::checkWorkspacePosition(QRect oldGeometry, int oldDesktop) void Client::checkOffscreenPosition(QRect* geom, const QRect& screenArea) { - if (geom->x() > screenArea.right()) { - int screenWidth = screenArea.width(); - geom->moveLeft(screenWidth - (screenWidth / 4)); + if (geom->left() > screenArea.right()) { + geom->moveLeft(screenArea.right() - screenArea.width()/4); + } else if (geom->right() < screenArea.left()) { + geom->moveRight(screenArea.left() + screenArea.width()/4); } - if (geom->y() > screenArea.bottom()) { - int screenHeight = screenArea.height(); - geom->moveBottom(screenHeight - (screenHeight / 4)); + if (geom->top() > screenArea.bottom()) { + geom->moveTop(screenArea.bottom() - screenArea.height()/4); + } else if (geom->bottom() < screenArea.top()) { + geom->moveBottom(screenArea.top() + screenArea.width()/4); } }