From 898052f3d5957d65b82fe35e266cdc47cb5c3bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Fri, 30 Sep 2011 16:37:42 +0200 Subject: [PATCH] better window position when moving a window between screens --- workspace.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/workspace.cpp b/workspace.cpp index 443bb6acc2..61d7723274 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1743,8 +1743,13 @@ void Workspace::sendClientToScreen(Client* c, int screen) QRect old_sarea = clientArea(MaximizeArea, c); QRect sarea = clientArea(MaximizeArea, screen, c->desktop()); QRect oldgeom = c->geometry(); - c->setGeometry(sarea.x() - old_sarea.x() + c->x(), sarea.y() - old_sarea.y() + c->y(), - c->size().width(), c->size().height()); + QRect geom = c->geometry(); + // move the window to have the same relative position to the center of the screen + // (i.e. one near the middle of the right edge will also end up near the middle of the right edge) + geom.moveCenter( + QPoint(( geom.center().x() - old_sarea.center().x()) * sarea.width() / old_sarea.width() + sarea.center().x(), + ( geom.center().y() - old_sarea.center().y()) * sarea.height() / old_sarea.height() + sarea.center().y())); + c->setGeometry( geom ); c->checkWorkspacePosition( oldgeom ); ClientList transients_stacking_order = ensureStackingOrder(c->transients()); for (ClientList::ConstIterator it = transients_stacking_order.constBegin();