From 0b9f5d68d241aafa8a41c9433460ea5bfd9a34b6 Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Thu, 28 Jul 2011 18:53:21 +0200 Subject: [PATCH] Correctly display popups when using multiple screens If there are multiple screens with different resolutions or which are not alligned the same way then it could happen that popups at the edge were drawn (partially) offscreen. This patch fixes that issue. REVIEW:102118 BUG:256835 FIXED-IN:4.7.1 (cherry picked from commit c50f180f29a5d46093e0172baf71f6dcf9f23281) --- corona.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/corona.cpp b/corona.cpp index 048d68ebf..055af4e00 100644 --- a/corona.cpp +++ b/corona.cpp @@ -571,26 +571,6 @@ QPoint Corona::popupPosition(const QGraphicsItem *item, const QSize &s, Qt::Alig break; } - switch (loc) { - case BottomEdge: - pos.setY(v->geometry().y() - s.height()); - break; - case TopEdge: - pos.setY(v->geometry().bottom()); - break; - case LeftEdge: - pos.setX(v->geometry().right()); - break; - case RightEdge: - pos.setX(v->geometry().x() - s.width()); - break; - default: - if (pos.y() - s.height() > 0) { - pos.ry() = pos.y() - s.height(); - } else { - pos.ry() = pos.y() + (int)actualItem->boundingRect().size().height() + 1; - } - } //are we out of screen? int screen = ((pv && pv->containment()) ? pv->containment()->screen() : -1); @@ -605,6 +585,28 @@ QPoint Corona::popupPosition(const QGraphicsItem *item, const QSize &s, Qt::Alig } QRect screenRect = screenGeometry(screen); + + switch (loc) { + case BottomEdge: + pos.setY(v->geometry().y() - s.height()); + break; + case TopEdge: + pos.setY(v->geometry().bottom()); + break; + case LeftEdge: + pos.setX(v->geometry().right()); + break; + case RightEdge: + pos.setX(v->geometry().x() - s.width()); + break; + default: + if (pos.y() - s.height() > screenRect.top()) { + pos.ry() = pos.y() - s.height(); + } else { + pos.ry() = pos.y() + (int)actualItem->boundingRect().size().height() + 1; + } + } + //kDebug() << "==> rect for" << screen << "is" << screenRect; if (loc != LeftEdge && pos.x() + s.width() > screenRect.right()) {