From 3eb0b27d00fc292413734b5701e423e2b29f7749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sat, 21 Sep 2013 00:42:21 +0200 Subject: [PATCH] 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 --- effects/windowgeometry/windowgeometry.cpp | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/effects/windowgeometry/windowgeometry.cpp b/effects/windowgeometry/windowgeometry.cpp index fca5bda351..5f3176f1eb 100644 --- a/effects/windowgeometry/windowgeometry.cpp +++ b/effects/windowgeometry/windowgeometry.cpp @@ -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();