7#include <QGuiApplication>
11#include <KWayland/Client/connection_thread.h>
12#include <KWayland/Client/pointer.h>
13#include <KWayland/Client/pointergestures.h>
14#include <KWayland/Client/registry.h>
15#include <KWayland/Client/seat.h>
36 return m_progressScale;
49 Pointer *m_pointer =
nullptr;
50 PointerGestures *m_pointerGestures =
nullptr;
51 PointerPinchGesture *m_gesture =
nullptr;
54 qreal m_progressScale = 1.0;
66 QQuickItem::componentComplete();
70void PinchGesture::initWayland()
72 auto c = ConnectionThread::fromApplication(
this);
73 Registry *r =
new Registry(c);
76 connect(r, &Registry::interfacesAnnounced,
this,
78 const auto gi = r->interface(Registry::Interface::PointerGesturesUnstableV1);
82 m_pointerGestures = r->createPointerGestures(gi.name, gi.version,
this);
85 const auto si = r->interface(Registry::Interface::Seat);
89 auto seat = r->createSeat(si.name, si.version,
this);
90 connect(seat, &Seat::hasKeyboardChanged,
this,
91 [
this, seat](
bool hasPointer) {
93 m_pointer =
seat->createPointer(
this);
108void PinchGesture::setupGesture()
110 if (m_gesture || !m_pointerGestures || !m_pointer) {
113 m_gesture = m_pointerGestures->createPinchGesture(m_pointer,
this);
114 connect(m_gesture, &PointerPinchGesture::updated,
this,
115 [
this](
const QSizeF &delta, qreal
scale) {
116 m_progressScale =
scale;
119 connect(m_gesture, &PointerPinchGesture::ended,
this,
121 m_scale = m_scale * m_progressScale;
122 m_progressScale = 1.0;
123 Q_EMIT scaleChanged();
126 connect(m_gesture, &PointerPinchGesture::cancelled,
this,
128 m_progressScale = 1.0;
133int main(
int argc,
char *argv[])
135 qputenv(
"QT_QPA_PLATFORM", QByteArrayLiteral(
"wayland"));
136 QGuiApplication app(argc, argv);
138 qmlRegisterType<PinchGesture>(
"org.kde.kwin.tests", 1, 0,
"PinchGesture");
141 view.setSource(QUrl::fromLocalFile(QStringLiteral(DIR) + QStringLiteral(
"/pointergesturestest.qml")));
148#include "pointergesturestest.moc"
qreal progressScale() const
void progressScaleChanged()
void componentComplete() override
PinchGesture(QQuickItem *parent=nullptr)
KWayland::Client::Seat * seat