From 3eccd9c8a4dd99f3ec36ea44a2d4331ae6ad6922 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Wed, 9 Sep 2015 10:35:48 +0200 Subject: [PATCH] Prevent context menus from overlapping panels CHANGELOG: Context menus of applets within a panel no longer overlap the applet REVIEW: 124981 --- .../qml/plasmoid/containmentinterface.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 104581d33..772031f86 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -885,7 +885,20 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event) if (window() && window()->mouseGrabberItem()) { window()->mouseGrabberItem()->ungrabMouse(); } - desktopMenu.exec(event->globalPos()); + + QPoint pos = event->globalPos(); + if (window() && applet && m_containment->containmentType() == Plasma::Types::PanelContainment) { + desktopMenu.adjustSize(); + + if (QScreen *screen = window()->screen()) { + const QRect geo = screen->availableGeometry(); + + pos = QPoint(qBound(geo.left(), pos.x(), geo.right() - desktopMenu.width()), + qBound(geo.top(), pos.y(), geo.bottom() - desktopMenu.height())); + } + } + + desktopMenu.exec(pos); event->setAccepted(true); }