Move the "noOffscreensWindow" into a method so we can reuse it

This commit is contained in:
Alex Fiestas 2011-07-28 22:18:41 +02:00
parent e79cf50087
commit c0b89870b9
2 changed files with 15 additions and 9 deletions

View file

@ -572,6 +572,8 @@ private:
Time readUserCreationTime() const;
void startupIdChanged();
void checkOffscreenPosition (QRect& geom, const QRect& screenArea);
Window client;
Window wrapper;
KDecoration* decoration;

View file

@ -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,