Index: applethandle.cpp =================================================================== --- applethandle.cpp (revision 740767) +++ applethandle.cpp (working copy) @@ -30,6 +30,8 @@ #include "applet.h" #include "containment.h" +#include "corona.h" +#include "applet.h" #include "theme.h" namespace Plasma @@ -83,6 +85,7 @@ QPointF newPos = transform().inverted().map(m_applet->pos()); m_applet->setParentItem(m_containment); + m_applet->installSceneEventFilter(m_containment); m_applet->setPos(mapToParent(newPos)); m_applet->setTransform(matrix); } @@ -246,6 +249,31 @@ else if (m_pressedButton == MoveButton) { QPointF delta = event->pos()-event->lastPos(); setPos(pos()+delta); + // test for containment change + if (!m_containment->sceneBoundingRect().contains(event->scenePos())) { + // see which containment it belongs to + Corona * corona = qobject_cast(scene()); + if (corona) { + QList containments = corona->containments(); + for (int i = 0; i < containments.size(); ++i) { + if (containments[i]->sceneBoundingRect().contains(event->scenePos())) { + // add the applet to the new containment + // and take it from the old one + QPointF scenePosition = scenePos(); + kDebug() << "moving to other containment with position" << event->pos() << event->scenePos(); + kDebug() << "position before reparenting" << pos() << scenePos(); + m_applet->removeSceneEventFilter(m_containment); + m_containment = containments[i]; + //m_containment->addChild(m_applet); + setParentItem(containments[i]); + setPos(m_containment->mapFromScene(scenePosition)); + m_applet->installSceneEventFilter(m_containment); + update(); + break; + } + } + } + } } else if (m_pressedButton == RotateButton) { if (_k_distanceForPoint(event->pos()-event->lastPos()) <= 1.0) { return; Index: containment.cpp =================================================================== --- containment.cpp (revision 740767) +++ containment.cpp (working copy) @@ -608,7 +608,9 @@ switch (event->type()) { case QEvent::GraphicsSceneHoverEnter: + kDebug() << "got hoverenterEvent" << d->immutable << " " << applet->isImmutable(); if (!d->immutable && !applet->isImmutable() && !d->handles.contains(applet)) { + kDebug() << "generated applet handle"; AppletHandle *handle = new AppletHandle(this, applet); d->handles[applet] = handle; connect(handle, SIGNAL(disappearDone(AppletHandle*)),