diff --git a/platform.cpp b/platform.cpp
index 0a29a7f289..b37bb338fb 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -261,6 +261,70 @@ void Platform::touchUp(qint32 id, quint32 time)
input()->processTouchUp(id, time);
}
+void Platform::processSwipeGestureBegin(int fingerCount, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->pointer()->processSwipeGestureBegin(fingerCount, time);
+}
+
+void Platform::processSwipeGestureUpdate(const QSizeF &delta, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->pointer()->processSwipeGestureUpdate(delta, time);
+}
+
+void Platform::processSwipeGestureEnd(quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->pointer()->processSwipeGestureEnd(time);
+}
+
+void Platform::processSwipeGestureCancelled(quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->pointer()->processSwipeGestureCancelled(time);
+}
+
+void Platform::processPinchGestureBegin(int fingerCount, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->pointer()->processPinchGestureBegin(fingerCount, time);
+}
+
+void Platform::processPinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->pointer()->processPinchGestureUpdate(scale, angleDelta, delta, time);
+}
+
+void Platform::processPinchGestureEnd(quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->pointer()->processPinchGestureEnd(time);
+}
+
+void Platform::processPinchGestureCancelled(quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->pointer()->processPinchGestureCancelled(time);
+}
+
void Platform::repaint(const QRect &rect)
{
if (!Compositor::self()) {
diff --git a/platform.h b/platform.h
index f4eb5fca26..7855e3dd14 100644
--- a/platform.h
+++ b/platform.h
@@ -303,6 +303,15 @@ public Q_SLOTS:
void touchCancel();
void touchFrame();
+ void processSwipeGestureBegin(int fingerCount, quint32 time);
+ void processSwipeGestureUpdate(const QSizeF &delta, quint32 time);
+ void processSwipeGestureEnd(quint32 time);
+ void processSwipeGestureCancelled(quint32 time);
+ void processPinchGestureBegin(int fingerCount, quint32 time);
+ void processPinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time);
+ void processPinchGestureEnd(quint32 time);
+ void processPinchGestureCancelled(quint32 time);
+
Q_SIGNALS:
void screensQueried();
void initFailed();
diff --git a/plugins/platforms/wayland/wayland_backend.cpp b/plugins/platforms/wayland/wayland_backend.cpp
index 32aec22e33..16b0d776ff 100644
--- a/plugins/platforms/wayland/wayland_backend.cpp
+++ b/plugins/platforms/wayland/wayland_backend.cpp
@@ -38,6 +38,7 @@ along with this program. If not, see .
#include
#include
#include
+#include
#include
#include
#include
@@ -120,6 +121,7 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
[this](bool hasPointer) {
if (hasPointer && !m_pointer) {
m_pointer = m_seat->createPointer(this);
+ setupPointerGestures();
connect(m_pointer, &Pointer::entered, this,
[this](quint32 serial) {
m_enteredSerial = serial;
@@ -219,6 +221,10 @@ WaylandSeat::~WaylandSeat()
void WaylandSeat::destroyPointer()
{
+ delete m_pinchGesture;
+ m_pinchGesture = nullptr;
+ delete m_swipeGesture;
+ m_swipeGesture = nullptr;
delete m_pointer;
m_pointer = nullptr;
}
@@ -271,6 +277,61 @@ void WaylandSeat::setInstallCursor(bool install)
m_installCursor = install;
}
+void WaylandSeat::setupPointerGestures()
+{
+ if (!m_pointer || !m_gesturesInterface) {
+ return;
+ }
+ if (m_pinchGesture || m_swipeGesture) {
+ return;
+ }
+ m_pinchGesture = m_gesturesInterface->createPinchGesture(m_pointer, this);
+ m_swipeGesture = m_gesturesInterface->createSwipeGesture(m_pointer, this);
+ connect(m_pinchGesture, &PointerPinchGesture::started, m_backend,
+ [this] (quint32 serial, quint32 time) {
+ Q_UNUSED(serial);
+ m_backend->processPinchGestureBegin(m_pinchGesture->fingerCount(), time);
+ }
+ );
+ connect(m_pinchGesture, &PointerPinchGesture::updated, m_backend,
+ [this] (const QSizeF &delta, qreal scale, qreal rotation, quint32 time) {
+ m_backend->processPinchGestureUpdate(scale, rotation, delta, time);
+ }
+ );
+ connect(m_pinchGesture, &PointerPinchGesture::ended, m_backend,
+ [this] (quint32 serial, quint32 time) {
+ Q_UNUSED(serial)
+ m_backend->processPinchGestureEnd(time);
+ }
+ );
+ connect(m_pinchGesture, &PointerPinchGesture::cancelled, m_backend,
+ [this] (quint32 serial, quint32 time) {
+ Q_UNUSED(serial)
+ m_backend->processPinchGestureCancelled(time);
+ }
+ );
+
+ connect(m_swipeGesture, &PointerSwipeGesture::started, m_backend,
+ [this] (quint32 serial, quint32 time) {
+ Q_UNUSED(serial)
+ m_backend->processSwipeGestureBegin(m_swipeGesture->fingerCount(), time);
+ }
+ );
+ connect(m_swipeGesture, &PointerSwipeGesture::updated, m_backend, &Platform::processSwipeGestureUpdate);
+ connect(m_swipeGesture, &PointerSwipeGesture::ended, m_backend,
+ [this] (quint32 serial, quint32 time) {
+ Q_UNUSED(serial)
+ m_backend->processSwipeGestureEnd(time);
+ }
+ );
+ connect(m_swipeGesture, &PointerSwipeGesture::cancelled, m_backend,
+ [this] (quint32 serial, quint32 time) {
+ Q_UNUSED(serial)
+ m_backend->processSwipeGestureCancelled(time);
+ }
+ );
+}
+
WaylandBackend::WaylandBackend(QObject *parent)
: Platform(parent)
, m_display(nullptr)
@@ -355,6 +416,19 @@ void WaylandBackend::init()
}
);
connect(m_registry, &Registry::interfacesAnnounced, this, &WaylandBackend::createSurface);
+ connect(m_registry, &Registry::interfacesAnnounced, this,
+ [this] {
+ if (!m_seat) {
+ return;
+ }
+ const auto gi = m_registry->interface(Registry::Interface::PointerGesturesUnstableV1);
+ if (gi.name == 0) {
+ return;
+ }
+ auto gesturesInterface = m_registry->createPointerGestures(gi.name, gi.version, m_seat.data());
+ m_seat->installGesturesInterface(gesturesInterface);
+ }
+ );
if (!deviceIdentifier().isEmpty()) {
m_connectionThreadObject->setSocketName(deviceIdentifier());
}
diff --git a/plugins/platforms/wayland/wayland_backend.h b/plugins/platforms/wayland/wayland_backend.h
index cf81764fdc..3241e7a15a 100644
--- a/plugins/platforms/wayland/wayland_backend.h
+++ b/plugins/platforms/wayland/wayland_backend.h
@@ -49,6 +49,9 @@ class EventQueue;
class Keyboard;
class Pointer;
class PointerConstraints;
+class PointerGestures;
+class PointerSwipeGesture;
+class PointerPinchGesture;
class Registry;
class Seat;
class Shell;
@@ -88,15 +91,24 @@ public:
return m_pointer;
}
+ void installGesturesInterface(KWayland::Client::PointerGestures *gesturesInterface) {
+ m_gesturesInterface = gesturesInterface;
+ setupPointerGestures();
+ }
+
private:
void destroyPointer();
void destroyKeyboard();
void destroyTouch();
+ void setupPointerGestures();
KWayland::Client::Seat *m_seat;
KWayland::Client::Pointer *m_pointer;
KWayland::Client::Keyboard *m_keyboard;
KWayland::Client::Touch *m_touch;
KWayland::Client::Surface *m_cursor;
+ KWayland::Client::PointerGestures *m_gesturesInterface = nullptr;
+ KWayland::Client::PointerPinchGesture *m_pinchGesture = nullptr;
+ KWayland::Client::PointerSwipeGesture *m_swipeGesture = nullptr;
uint32_t m_enteredSerial;
WaylandBackend *m_backend;
bool m_installCursor;