better window position when moving a window between screens

This commit is contained in:
Luboš Luňák 2011-09-30 16:37:42 +02:00
parent 1030bcd7f3
commit 898052f3d5

View file

@ -1743,8 +1743,13 @@ void Workspace::sendClientToScreen(Client* c, int screen)
QRect old_sarea = clientArea(MaximizeArea, c); QRect old_sarea = clientArea(MaximizeArea, c);
QRect sarea = clientArea(MaximizeArea, screen, c->desktop()); QRect sarea = clientArea(MaximizeArea, screen, c->desktop());
QRect oldgeom = c->geometry(); QRect oldgeom = c->geometry();
c->setGeometry(sarea.x() - old_sarea.x() + c->x(), sarea.y() - old_sarea.y() + c->y(), QRect geom = c->geometry();
c->size().width(), c->size().height()); // 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 ); c->checkWorkspacePosition( oldgeom );
ClientList transients_stacking_order = ensureStackingOrder(c->transients()); ClientList transients_stacking_order = ensureStackingOrder(c->transients());
for (ClientList::ConstIterator it = transients_stacking_order.constBegin(); for (ClientList::ConstIterator it = transients_stacking_order.constBegin();