summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandquickitem.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2016-07-06 14:33:53 +0200
committerJohan Helsing <johan.helsing@qt.io>2016-07-11 07:45:24 +0000
commit28bee1e6b4bec3e9ea952de132530e9409463684 (patch)
tree035411e3f5b6908534136e9e2e8f533ced120838 /src/compositor/compositor_api/qwaylandquickitem.cpp
parenta8a3573eb4bfa59bad6aa9b2ceef4393b39f0792 (diff)
Fix drag-and-drop for QML compositors
Dragging within the same client was broken because handleStartDrag called setInputEventsEnabled(false), which meant the surface was ignored as a target for the drag. With this change, input events are not disabled, and wl_data_device.motion events are sent to the source surface like they should. Also wl_pointer.leave and enter are sent before and after the drag. Change-Id: Ife46ca3a9d44a660a5cf029093842adb0e3eca7c Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandquickitem.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index 15525259c..203b9ac44 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -512,17 +512,18 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event)
Q_D(QWaylandQuickItem);
if (d->shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos());
- } else if (d->isDragging) {
- QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- QWaylandQuickOutput *currentOutput = qobject_cast<QWaylandQuickOutput *>(view()->output());
- //TODO: also check if dragging onto other outputs
- QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->localPos())));
- QWaylandSurface *targetSurface = targetItem ? targetItem->surface() : nullptr;
- if (targetSurface) {
- QPointF position = mapToItem(targetItem, event->localPos());
- QPointF surfacePosition = targetItem->mapToSurface(position);
- inputDevice->drag()->dragMove(targetSurface, surfacePosition);
+ if (d->isDragging) {
+ QWaylandQuickOutput *currentOutput = qobject_cast<QWaylandQuickOutput *>(view()->output());
+ //TODO: also check if dragging onto other outputs
+ QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->localPos())));
+ QWaylandSurface *targetSurface = targetItem ? targetItem->surface() : nullptr;
+ if (targetSurface) {
+ QPointF position = mapToItem(targetItem, event->localPos());
+ QPointF surfacePosition = targetItem->mapToSurface(position);
+ inputDevice->drag()->dragMove(targetSurface, surfacePosition);
+ }
+ } else {
+ inputDevice->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos());
}
} else {
emit mouseMove(event->windowPos());
@@ -538,12 +539,12 @@ void QWaylandQuickItem::mouseReleaseEvent(QMouseEvent *event)
Q_D(QWaylandQuickItem);
if (d->shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseReleaseEvent(event->button());
- } else if (d->isDragging) {
- d->isDragging = false;
- setInputEventsEnabled(true);
- QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->drag()->drop();
+ if (d->isDragging) {
+ d->isDragging = false;
+ inputDevice->drag()->drop();
+ } else {
+ inputDevice->sendMouseReleaseEvent(event->button());
+ }
} else {
emit mouseRelease();
event->ignore();
@@ -1202,8 +1203,8 @@ void QWaylandQuickItem::handleDragStarted(QWaylandDrag *drag)
{
Q_D(QWaylandQuickItem);
Q_ASSERT(drag->origin() == surface());
+ drag->inputDevice()->setMouseFocus(nullptr);
d->isDragging = true;
- setInputEventsEnabled(false);
}
QT_END_NAMESPACE