diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-04-12 20:52:19 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2018-04-18 06:06:30 +0000 |
commit | 531a767040782007181bb13583fe69b4ba4b1ba3 (patch) | |
tree | 286002a4e69b9b8cc6df5843249be7e718ac85d4 | |
parent | d96b8afd40f83075c4f76edd0cf80b4fe05b74fa (diff) | |
download | qtwayland-531a767040782007181bb13583fe69b4ba4b1ba3.tar.gz |
Compositor QML API: Add QWaylandQuickItem::sendMouseMoveEvent
QWaylandSeat::sendMouseMoveEvent can't be exposed to QML, because it
requires a QWaylandView, which is not available from QML.
[ChangeLog][Compositor] QWaylandQuickItem::sendMouseMoveEvent was added
to allow sending generated mouse move events from QML.
Change-Id: I5793444a3367863980d2feca78ea56de5da231ad
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem.cpp | 13 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 752e4a42..eb61d4ba 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -1315,6 +1315,19 @@ void QWaylandQuickItem::raise() stackAfter(top); } +void QWaylandQuickItem::sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat) +{ + if (seat == nullptr) + seat = compositor()->defaultSeat(); + + if (!seat) { + qWarning() << "No seat, can't send mouse event"; + return; + } + + seat->sendMouseMoveEvent(view(), position); +} + /*! * \internal * diff --git a/src/compositor/compositor_api/qwaylandquickitem.h b/src/compositor/compositor_api/qwaylandquickitem.h index 047fdeb6..0aa863f5 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.h +++ b/src/compositor/compositor_api/qwaylandquickitem.h @@ -151,6 +151,7 @@ public Q_SLOTS: void setPaintEnabled(bool paintEnabled); void raise(); void lower(); + void sendMouseMoveEvent(const QPointF &position, QWaylandSeat *seat = nullptr); private Q_SLOTS: void surfaceMappedChanged(); |