From 975e5009c176eb378daa5c8f74cd4cffb64ff459 Mon Sep 17 00:00:00 2001 From: Bhushan Shah Date: Thu, 26 Mar 2015 21:20:11 +0530 Subject: [PATCH] Fix one pixel gap between screenedge and right placed vertical panel Appearantly right() / bottomRight() / topRight() returns values with 1 pixel x off for historical reasons and hence 1px gap. This causes the autohide panel not hiding automatically. BUG: 339323 BUG: 340549 FIXED-IN: 5.3 REVIEW: 123136 --- shell/panelview.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shell/panelview.cpp b/shell/panelview.cpp index abdda86f1..5dd60b216 100644 --- a/shell/panelview.cpp +++ b/shell/panelview.cpp @@ -427,7 +427,7 @@ QRect PanelView::geometryByDistance(int distance) const position = QPoint(QPoint(s->geometry().center().x(), s->geometry().top()) + QPoint(m_offset - size().width()/2, distance)); break; case Qt::AlignRight: - position = QPoint(s->geometry().topRight() - QPoint(m_offset + size().width(), distance)); + position = QPoint(QPoint(s->geometry().x() + s->geometry().width(), s->geometry().y()) - QPoint(m_offset + size().width(), distance)); break; case Qt::AlignLeft: default: @@ -441,7 +441,7 @@ QRect PanelView::geometryByDistance(int distance) const position = QPoint(QPoint(s->geometry().left(), s->geometry().center().y()) + QPoint(distance, m_offset - size().height()/2)); break; case Qt::AlignRight: - position = QPoint(s->geometry().bottomLeft() - QPoint(distance, m_offset + size().height())); + position = QPoint(QPoint(s->geometry().left(), s->geometry().y() + s->geometry().height()) - QPoint(distance, m_offset + size().height())); break; case Qt::AlignLeft: default: @@ -452,14 +452,15 @@ QRect PanelView::geometryByDistance(int distance) const case Plasma::Types::RightEdge: switch (m_alignment) { case Qt::AlignCenter: - position = QPoint(QPoint(s->geometry().right(), s->geometry().center().y()) - QPoint(thickness() + distance, 0) + QPoint(0, m_offset - size().height()/2)); + // Never use rect.right(); for historical reasons it returns left() + width() - 1; see http://doc.qt.io/qt-5/qrect.html#right + position = QPoint(QPoint(s->geometry().x() + s->geometry().width(), s->geometry().center().y()) - QPoint(thickness() + distance, 0) + QPoint(0, m_offset - size().height()/2)); break; case Qt::AlignRight: - position = QPoint(s->geometry().bottomRight() - QPoint(thickness() + distance, 0) - QPoint(0, m_offset + size().height())); + position = QPoint(QPoint(s->geometry().x() + s->geometry().width(), s->geometry().y() + s->geometry().height()) - QPoint(thickness() + distance, 0) - QPoint(0, m_offset + size().height())); break; case Qt::AlignLeft: default: - position = QPoint(s->geometry().topRight() - QPoint(thickness() + distance, 0) + QPoint(0, m_offset)); + position = QPoint(QPoint(s->geometry().x() + s->geometry().width(), s->geometry().y()) - QPoint(thickness() + distance, 0) + QPoint(0, m_offset)); } break;