Prevent context menus from overlapping panels

CHANGELOG: Context menus of applets within a panel no longer overlap the applet

REVIEW: 124981
This commit is contained in:
Kai Uwe Broulik 2015-09-09 10:35:48 +02:00
parent e07778d97b
commit 3eccd9c8a4

View File

@ -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);
}