windowgeometry effect, keep hint inside screen

and use passed geometry parameter to position the labels
(required with resize effect because the actual geometry is
not updated)

REVIEW: 112849
This commit is contained in:
Thomas Lübking 2013-09-21 00:42:21 +02:00
parent 3f5ef10c8e
commit 3eb0b27d00

View file

@ -150,8 +150,15 @@ void WindowGeometry::slotWindowStepUserMovedResized(EffectWindow *w, const QRect
myExtraDirtyArea = QRect();
myCurrentGeometry = geometry;
QPoint center = geometry.center();
const QRect &r = geometry;
const QRect &r2 = myOriginalGeometry;
const QRect screen = effects->clientArea(ScreenArea, center, w->desktop());
QRect expandedGeometry = w->expandedGeometry();
expandedGeometry = geometry.adjusted(expandedGeometry.x() - w->x(),
expandedGeometry.y() - w->y(),
expandedGeometry.right() - w->geometry().right(),
expandedGeometry.bottom() - w->geometry().bottom());
// sufficient for moves, resizes calculated otherwise
int dx = r.x() - r2.x();
@ -162,7 +169,9 @@ void WindowGeometry::slotWindowStepUserMovedResized(EffectWindow *w, const QRect
myMeasure[0]->setText( i18nc(myCoordString_1, r.x(), r.y(), number(dx), number(dy) ) );
else
myMeasure[0]->setText( i18nc(myCoordString_0, r.x(), r.y() ) );
myMeasure[0]->setPosition(w->expandedGeometry().topLeft() + QPoint(6,6)); // "6" is magic number because the unstyled effectframe has 5px padding
QPoint pos = expandedGeometry.topLeft();
pos = QPoint(qMax(pos.x(), screen.x()), qMax(pos.y(), screen.y()));
myMeasure[0]->setPosition(pos + QPoint(6,6)); // "6" is magic number because the unstyled effectframe has 5px padding
// center ----------------------
if (w->isUserResize()) {
@ -183,15 +192,22 @@ void WindowGeometry::slotWindowStepUserMovedResized(EffectWindow *w, const QRect
dy = r.bottom() - r2.bottom();
} else
myMeasure[1]->setText( i18nc(myCoordString_0, number(dx), number(dy) ) );
myMeasure[1]->setPosition(geometry.center());
const int cdx = myMeasure[1]->geometry().width() / 2 + 3; // "3" = 6/2 is magic number because
const int cdy = myMeasure[1]->geometry().height() / 2 + 3; // the unstyled effectframe has 5px padding
center = QPoint(qMax(center.x(), screen.x() + cdx),
qMax(center.y(), screen.y() + cdy));
center = QPoint(qMin(center.x(), screen.right() - cdx),
qMin(center.y(), screen.bottom() - cdy));
myMeasure[1]->setPosition(center);
// lower right ----------------------
if (w->isUserResize())
myMeasure[2]->setText( i18nc(myCoordString_1, r.right(), r.bottom(), number(dx), number(dy) ) );
else
myMeasure[2]->setText( i18nc(myCoordString_0, r.right(), r.bottom() ) );
myMeasure[2]->setPosition(w->expandedGeometry().bottomRight() - QPoint(6,6)); // "6" is magic number because the unstyled effectframe has 5px padding
pos = expandedGeometry.bottomRight();
pos = QPoint(qMin(pos.x(), screen.right()), qMin(pos.y(), screen.bottom()));
myMeasure[2]->setPosition(pos - QPoint(6,6)); // "6" is magic number because the unstyled effectframe has 5px padding
myExtraDirtyArea |= myMeasure[0]->geometry();
myExtraDirtyArea |= myMeasure[1]->geometry();