From c0b89870b9799c07afb75971d0ae7c4f3a637b52 Mon Sep 17 00:00:00 2001 From: Alex Fiestas Date: Thu, 28 Jul 2011 22:18:41 +0200 Subject: [PATCH] Move the "noOffscreensWindow" into a method so we can reuse it --- client.h | 2 ++ geometry.cpp | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/client.h b/client.h index fca0297ee0..93510ec818 100644 --- a/client.h +++ b/client.h @@ -572,6 +572,8 @@ private: Time readUserCreationTime() const; void startupIdChanged(); + void checkOffscreenPosition (QRect& geom, const QRect& screenArea); + Window client; Window wrapper; KDecoration* decoration; diff --git a/geometry.cpp b/geometry.cpp index af6ce8c50c..b64db47630 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1157,15 +1157,7 @@ void Client::checkWorkspacePosition(const QRect &geo) newGeom.x() + newGeom.width() - 1)); } - if (newGeom.x() > screenArea.right()) { - int screenWidth = screenArea.width(); - newGeom.moveLeft(screenWidth - (screenWidth / 4)); - } - if (newGeom.y() > screenArea.bottom()) { - int screenHeight = screenArea.height(); - newGeom.moveBottom(screenHeight - (screenHeight / 4)); - } - + checkOffscreenPosition(newGeom, screenArea); // Obey size hints. TODO: We really should make sure it stays in the right place newGeom.setSize(adjustedSize(newGeom.size())); @@ -1174,6 +1166,18 @@ void Client::checkWorkspacePosition(const QRect &geo) } } +void Client::checkOffscreenPosition(QRect& geom, const QRect& screenArea) +{ + if (geom.x() > screenArea.right()) { + int screenWidth = screenArea.width(); + geom.moveLeft(screenWidth - (screenWidth / 4)); + } + if (geom.y() > screenArea.bottom()) { + int screenHeight = screenArea.height(); + geom.moveBottom(screenHeight - (screenHeight / 4)); + } +} + // Try to be smart about keeping the clients visible. // If the client was fully inside the workspace before, try to keep // it still inside the workarea, possibly moving it or making it smaller if possible,