Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qwaylandpointergestures.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "qwaylanddisplay_p.h"
7
9
10namespace QtWaylandClient {
11
13 : zwp_pointer_gestures_v1(display->wl_registry(), id, qMin(version, uint(1)))
14{
15}
16
19{
21}
22
25{
27}
28
30 : mParent(p)
31{
32}
33
35{
36 destroy();
37}
38
40 struct ::wl_surface *surface,
41 uint32_t fingers)
42{
43#ifndef QT_NO_GESTURES
45 if (!mFocus) {
46 return;
47 }
48 mParent->mSerial = serial;
49 mFingers = fingers;
50
51 const auto* pointer = mParent->pointer();
52
53 qCDebug(lcQpaWaylandInput) << "zwp_pointer_gesture_swipe_v1_begin @ "
54 << pointer->mSurfacePos << "fingers" << fingers;
55
57 pointer->mSurfacePos, pointer->mGlobalPos, mFingers,
58 QPointF());
59
60 mFocus->handleSwipeGesture(mParent, e);
61#endif
62}
63
65 wl_fixed_t dx, wl_fixed_t dy)
66{
67#ifndef QT_NO_GESTURES
68 if (!mFocus) {
69 return;
70 }
71 const auto* pointer = mParent->pointer();
72
73 const QPointF delta = QPointF(wl_fixed_to_double(dx), wl_fixed_to_double(dy));
74 qCDebug(lcQpaWaylandInput) << "zwp_pointer_gesture_swipe_v1_update @ "
75 << pointer->mSurfacePos << "delta" << delta;
76
78 pointer->mSurfacePos, pointer->mGlobalPos, mFingers, delta);
79
80 mFocus->handleSwipeGesture(mParent, e);
81#endif
82}
83
85 int32_t cancelled)
86{
87#ifndef QT_NO_GESTURES
88 if (!mFocus) {
89 return;
90 }
91 mParent->mSerial = serial;
92 const auto* pointer = mParent->pointer();
93
94 qCDebug(lcQpaWaylandInput) << "zwp_pointer_gesture_swipe_v1_end @ "
95 << pointer->mSurfacePos << (cancelled ? "CANCELED" : "");
96
98
99 auto e = QWaylandPointerGestureSwipeEvent(mFocus, gestureType, time,
100 pointer->mSurfacePos, pointer->mGlobalPos, mFingers,
101 QPointF());
102
103 mFocus->handleSwipeGesture(mParent, e);
104
105 mFocus.clear();
106 mFingers = 0;
107#endif
108}
109
111 : mParent(p)
112{
113}
114
116{
117 destroy();
118}
119
121 struct ::wl_surface *surface,
122 uint32_t fingers)
123{
124#ifndef QT_NO_GESTURES
126 if (!mFocus) {
127 return;
128 }
129 mParent->mSerial = serial;
130 mFingers = fingers;
131 mLastScale = 1;
132 const auto* pointer = mParent->pointer();
133
134 qCDebug(lcQpaWaylandInput) << "zwp_pointer_gesture_pinch_v1_begin @ "
135 << pointer->mSurfacePos << "fingers" << fingers;
136
138 pointer->mSurfacePos, pointer->mGlobalPos, mFingers,
139 QPointF(), 0, 0);
140
141 mFocus->handlePinchGesture(mParent, e);
142#endif
143}
144
146 wl_fixed_t dx, wl_fixed_t dy,
147 wl_fixed_t scale,
148 wl_fixed_t rotation)
149{
150#ifndef QT_NO_GESTURES
151 if (!mFocus) {
152 return;
153 }
154 const auto* pointer = mParent->pointer();
155
156 const qreal rscale = wl_fixed_to_double(scale);
157 const qreal rot = wl_fixed_to_double(rotation);
158 const QPointF delta = QPointF(wl_fixed_to_double(dx), wl_fixed_to_double(dy));
159 qCDebug(lcQpaWaylandInput) << "zwp_pointer_gesture_pinch_v1_update @ "
160 << pointer->mSurfacePos << "delta" << delta
161 << "scale" << mLastScale << "->" << rscale
162 << "delta" << rscale - mLastScale << "rot" << rot;
163
165 pointer->mSurfacePos, pointer->mGlobalPos, mFingers,
166 delta, rscale - mLastScale, rot);
167
168 mFocus->handlePinchGesture(mParent, e);
169
170 mLastScale = rscale;
171#endif
172}
173
175 int32_t cancelled)
176{
177#ifndef QT_NO_GESTURES
178 if (!mFocus) {
179 return;
180 }
181 mParent->mSerial = serial;
182 const auto* pointer = mParent->pointer();
183
184 qCDebug(lcQpaWaylandInput) << "zwp_pointer_gesture_swipe_v1_end @ "
185 << pointer->mSurfacePos << (cancelled ? "CANCELED" : "");
186
188
189 auto e = QWaylandPointerGesturePinchEvent(mFocus, gestureType, time,
190 pointer->mSurfacePos, pointer->mGlobalPos, mFingers,
191 QPointF(), 0, 0);
192
193 mFocus->handlePinchGesture(mParent, e);
194
195 mFocus.clear();
196 mFingers = 0;
197 mLastScale = 1;
198#endif
199}
200
201} // namespace QtWaylandClient
202
bool cancelled
Definition btgcdtimer.mm:27
IOBluetoothDevice * device
\inmodule QtCore\reentrant
Definition qpoint.h:214
void zwp_pointer_gesture_pinch_v1_update(uint32_t time, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t scale, wl_fixed_t rotation) override
void zwp_pointer_gesture_pinch_v1_begin(uint32_t serial, uint32_t time, struct ::wl_surface *surface, uint32_t fingers) override
void zwp_pointer_gesture_pinch_v1_end(uint32_t serial, uint32_t time, int32_t cancelled) override
void zwp_pointer_gesture_swipe_v1_begin(uint32_t serial, uint32_t time, struct ::wl_surface *surface, uint32_t fingers) override
void zwp_pointer_gesture_swipe_v1_end(uint32_t serial, uint32_t time, int32_t cancelled) override
void zwp_pointer_gesture_swipe_v1_update(uint32_t time, wl_fixed_t dx, wl_fixed_t dy) override
QWaylandPointerGesturePinch * createPointerGesturePinch(QWaylandInputDevice *device)
QWaylandPointerGestureSwipe * createPointerGestureSwipe(QWaylandInputDevice *device)
QWaylandPointerGestures(QWaylandDisplay *display, uint id, uint version)
static QWaylandWindow * fromWlSurface(::wl_surface *surface)
double e
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
@ GestureCanceled
@ GestureStarted
@ GestureUpdated
@ GestureFinished
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
GLenum GLuint id
[7]
GLsizei const void * pointer
Definition qopenglext.h:384
GLfloat GLfloat p
[1]
GLenum GLenum GLenum GLenum GLenum scale
unsigned int uint
Definition qtypes.h:29
double qreal
Definition qtypes.h:92