[webkit-qt] Drag and Drop in DRT

Robert Hogan lists at roberthogan.net
Thu Mar 25 15:18:10 PDT 2010


As you may know Drag and Drop is broken in DRT. After a bit of trial and 
error it's pretty apparent to me that this is because the event loop 
created by the call to drag->exec() in DragClientQt.cpp is preventing  
sendEvent/postEvent(QEvent::MouseButtonRelease) in EventSenderQt.cpp from 
'getting through' to QWebView.

As it stands EventSenderQt.cpp creates an event loop to wait around for the 
drag operation to return, but this also gets deadlocked with the event loop 
in drag->exec().

So I tried removing the event loop and just doing a sendEvent() on each of 
the mouseMove(), mouseDown(), mouseMove(), mouseUp() operations but of 
course they were getting delivered out of sequence.

So instead I just added them all to EventSender's queue and postEvent()'d 
them one after the other. The eventfilter() in EventSender shows all of 
them getting processed except for the final MouseUp() which doesn't show up 
at all, even with a QTest::Wait() directly after it was sent.

I then removed the drag->exec() from DragClientQt.cpp just to see what 
would happen to the events then - they all got processed in eventfilter() 
in EventSenderQt including the final mouseUp()!

So drag->exec(), and the event loop it creates is the culprit somehow. The 
eventfilter() in dndx11.cpp has:

    } else if (e->type() == QEvent::MouseButtonRelease) {
        DEBUG("pre drop");
        qApp->removeEventFilter(this);
        if (willDrop)
            drop();
        else
            cancel();
        DEBUG("drop, resetting object");
        beingCancelled = false;
        eventLoop->exit();
        return true;
    }

In all of the steps described above, physically pressing the mouse button 
would result in the dragged text getting dropped, so there seems to be 
something especially wrong with calling sendEvent()/postEvent() with the 
same event information as a physical button click.

What's so special about events called from postEvent()/sendEvent() that 
means they don't get received by webcore ?

I get the feeling I'm missing something very simple.


More information about the webkit-qt mailing list