From 0afd8efd8c0135b1105422f888c524da0dc4922f Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Tue, 1 Sep 2009 18:42:26 +0000 Subject: [PATCH] give contextmenuevent a chance to run this is icky and depends on scene()->sendEvent but we need it to know whether the containment plugin has child items expecting a contextmenuevent, before we eat the event. by the time contextmenuevent runs normally it's too late. svn path=/trunk/KDE/kdelibs/; revision=1018486 --- containment.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/containment.cpp b/containment.cpp index 12b3eb65a..1b940fd7a 100644 --- a/containment.cpp +++ b/containment.cpp @@ -519,10 +519,31 @@ void Containment::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void Containment::mousePressEvent(QGraphicsSceneMouseEvent *event) { event->ignore(); + kDebug(); if (d->appletAt(event->scenePos())) { return; //no unexpected click-throughs } + QGraphicsItem *item = scene()->itemAt(event->scenePos()); + if (event->button() == Qt::RightButton && item != this) { + //fake a contextmenuevent in case something in the containment plugin is expecting it + QGraphicsSceneContextMenuEvent contextEvent; + contextEvent.setReason(QGraphicsSceneContextMenuEvent::Mouse); + contextEvent.setPos(event->pos()); + contextEvent.setScenePos(event->scenePos()); + contextEvent.setScreenPos(event->screenPos()); + contextEvent.setModifiers(event->modifiers()); + contextEvent.setWidget(event->widget()); + + scene()->sendEvent(item, contextEvent); + if (contextEvent.isAccepted()) { + kDebug() << "context-accepted"; + event->accept(); + return; + } + kDebug() << "context not accepted"; + } + if (d->wallpaper && d->wallpaper->isInitialized() && !event->isAccepted()) { d->wallpaper->mousePressEvent(event); } @@ -578,12 +599,13 @@ void Containment::showDropZone(const QPoint pos) void Containment::showContextMenu(const QPointF &containmentPos, const QPoint &screenPos) { + kDebug(); d->showContextMenu(mapToScene(containmentPos), screenPos, false, false); } void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { - //kDebug() << "let's see if we manage to get a context menu here, huh"; + kDebug() << "let's see if we manage to get a context menu here, huh"; if (!isContainment() || !scene() || !KAuthorized::authorizeKAction("desktop_contextmenu")) { Applet::contextMenuEvent(event); return;