Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
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
// Qt-Security score:significant reason:default
4
5
#
include
"qwaylandpointergestures_p.h"
6
#
include
"qwaylanddisplay_p.h"
7
#
include
"qwaylandinputdevice_p.h"
8
#
include
"qwaylandsurface_p.h"
9
10
QT_BEGIN_NAMESPACE
11
12
namespace
QtWaylandClient
{
13
14
QWaylandPointerGestures
::
QWaylandPointerGestures
(
QWaylandDisplay
*
display
,
uint
id
,
uint
version
)
15
:
zwp_pointer_gestures_v1
(
display
->
wl_registry
(),
id
,
qMin
(
version
,
uint
(1)))
16
{
17
}
18
19
QWaylandPointerGestures
::~
QWaylandPointerGestures
()
noexcept
20
{
21
if
(
version
() >=
ZWP_POINTER_GESTURES_V1_RELEASE_SINCE_VERSION
)
22
release
();
23
else
24
zwp_pointer_gestures_v1_destroy
(
object
());
25
}
26
27
QWaylandPointerGestureSwipe
*
28
QWaylandPointerGestures
::
createPointerGestureSwipe
(
QWaylandInputDevice
*
device
)
29
{
30
return
new
QWaylandPointerGestureSwipe
(
device
,
get_swipe_gesture
(
device
->
pointer
()->
wl_pointer
()));
31
}
32
33
QWaylandPointerGesturePinch
*
34
QWaylandPointerGestures
::
createPointerGesturePinch
(
QWaylandInputDevice
*
device
)
35
{
36
return
new
QWaylandPointerGesturePinch
(
device
,
get_pinch_gesture
(
device
->
pointer
()->
wl_pointer
()));
37
}
38
39
QWaylandPointerGestureSwipe
::
QWaylandPointerGestureSwipe
(
QWaylandInputDevice
*
p
, ::
zwp_pointer_gesture_swipe_v1
*
object
)
40
:
QtWayland
::
zwp_pointer_gesture_swipe_v1
(
object
)
41
,
mParent
(
p
)
42
{
43
}
44
45
QWaylandPointerGestureSwipe
::~
QWaylandPointerGestureSwipe
()
46
{
47
destroy
();
48
}
49
50
void
QWaylandPointerGestureSwipe
::
zwp_pointer_gesture_swipe_v1_begin
(
uint32_t
serial
,
uint32_t
time
,
51
struct
::wl_surface *
surface
,
52
uint32_t
fingers
)
53
{
54
#
ifndef
QT_NO_GESTURES
55
mFocus
=
QWaylandSurface
::
fromWlSurface
(
surface
);
56
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
57
return
;
58
}
59
mParent
->
mSerial
=
serial
;
60
mFingers
=
fingers
;
61
62
const
auto
*
pointer
=
mParent
->
pointer
();
63
64
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_begin @ "
65
<<
pointer
->
mSurfacePos
<<
"fingers"
<<
fingers
;
66
67
auto
e
=
QWaylandPointerGestureSwipeEvent
(
mFocus
,
Qt
::
GestureStarted
,
time
,
68
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
69
QPointF
());
70
71
if
(
auto
ww
=
mFocus
->
waylandWindow
()) {
72
ww
->
handleSwipeGesture
(
mParent
,
e
);
73
}
74
#
endif
75
}
76
77
void
QWaylandPointerGestureSwipe
::
zwp_pointer_gesture_swipe_v1_update
(
uint32_t
time
,
78
wl_fixed_t
dx
,
wl_fixed_t
dy
)
79
{
80
#
ifndef
QT_NO_GESTURES
81
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
82
return
;
83
}
84
const
auto
*
pointer
=
mParent
->
pointer
();
85
86
const
QPointF
delta
=
QPointF
(
wl_fixed_to_double
(
dx
),
wl_fixed_to_double
(
dy
));
87
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_update @ "
88
<<
pointer
->
mSurfacePos
<<
"delta"
<<
delta
;
89
90
auto
e
=
QWaylandPointerGestureSwipeEvent
(
mFocus
,
Qt
::
GestureUpdated
,
time
,
91
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
delta
);
92
93
if
(
auto
ww
=
mFocus
->
waylandWindow
()) {
94
ww
->
handleSwipeGesture
(
mParent
,
e
);
95
}
96
#
endif
97
}
98
99
void
QWaylandPointerGestureSwipe
::
zwp_pointer_gesture_swipe_v1_end
(
uint32_t
serial
,
uint32_t
time
,
100
int32_t
cancelled
)
101
{
102
#
ifndef
QT_NO_GESTURES
103
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
104
return
;
105
}
106
mParent
->
mSerial
=
serial
;
107
const
auto
*
pointer
=
mParent
->
pointer
();
108
109
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_end @ "
110
<<
pointer
->
mSurfacePos
<< (
cancelled
?
"CANCELED"
:
""
);
111
112
auto
gestureType
=
cancelled
?
Qt
::
GestureFinished
:
Qt
::
GestureCanceled
;
113
114
auto
e
=
QWaylandPointerGestureSwipeEvent
(
mFocus
,
gestureType
,
time
,
115
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
116
QPointF
());
117
118
if
(
auto
ww
=
mFocus
->
waylandWindow
()) {
119
ww
->
handleSwipeGesture
(
mParent
,
e
);
120
}
121
122
mFocus
.
clear
();
123
mFingers
= 0;
124
#
endif
125
}
126
127
QWaylandPointerGesturePinch
::
QWaylandPointerGesturePinch
(
QWaylandInputDevice
*
p
, ::
zwp_pointer_gesture_pinch_v1
*
object
)
128
:
QtWayland
::
zwp_pointer_gesture_pinch_v1
(
object
)
129
,
mParent
(
p
)
130
{
131
}
132
133
QWaylandPointerGesturePinch
::~
QWaylandPointerGesturePinch
()
134
{
135
destroy
();
136
}
137
138
void
QWaylandPointerGesturePinch
::
zwp_pointer_gesture_pinch_v1_begin
(
uint32_t
serial
,
uint32_t
time
,
139
struct
::wl_surface *
surface
,
140
uint32_t
fingers
)
141
{
142
#
ifndef
QT_NO_GESTURES
143
mFocus
=
QWaylandSurface
::
fromWlSurface
(
surface
);
144
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
145
return
;
146
}
147
mParent
->
mSerial
=
serial
;
148
mFingers
=
fingers
;
149
mLastScale
= 1;
150
const
auto
*
pointer
=
mParent
->
pointer
();
151
152
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_pinch_v1_begin @ "
153
<<
pointer
->
mSurfacePos
<<
"fingers"
<<
fingers
;
154
155
auto
e
=
QWaylandPointerGesturePinchEvent
(
mFocus
,
Qt
::
GestureStarted
,
time
,
156
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
157
QPointF
(), 0, 0);
158
159
if
(
auto
ww
=
mFocus
->
waylandWindow
()) {
160
ww
->
handlePinchGesture
(
mParent
,
e
);
161
}
162
#
endif
163
}
164
165
void
QWaylandPointerGesturePinch
::
zwp_pointer_gesture_pinch_v1_update
(
uint32_t
time
,
166
wl_fixed_t
dx
,
wl_fixed_t
dy
,
167
wl_fixed_t
scale
,
168
wl_fixed_t
rotation
)
169
{
170
#
ifndef
QT_NO_GESTURES
171
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
172
return
;
173
}
174
const
auto
*
pointer
=
mParent
->
pointer
();
175
176
const
qreal
rscale
=
wl_fixed_to_double
(
scale
);
177
const
qreal
rot
=
wl_fixed_to_double
(
rotation
);
178
const
QPointF
delta
=
QPointF
(
wl_fixed_to_double
(
dx
),
wl_fixed_to_double
(
dy
));
179
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_pinch_v1_update @ "
180
<<
pointer
->
mSurfacePos
<<
"delta"
<<
delta
181
<<
"scale"
<<
mLastScale
<<
"->"
<<
rscale
182
<<
"delta"
<<
rscale
-
mLastScale
<<
"rot"
<<
rot
;
183
184
auto
e
=
QWaylandPointerGesturePinchEvent
(
mFocus
,
Qt
::
GestureUpdated
,
time
,
185
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
186
delta
,
rscale
-
mLastScale
,
rot
);
187
188
if
(
auto
ww
=
mFocus
->
waylandWindow
()) {
189
ww
->
handlePinchGesture
(
mParent
,
e
);
190
}
191
192
mLastScale
=
rscale
;
193
#
endif
194
}
195
196
void
QWaylandPointerGesturePinch
::
zwp_pointer_gesture_pinch_v1_end
(
uint32_t
serial
,
uint32_t
time
,
197
int32_t
cancelled
)
198
{
199
#
ifndef
QT_NO_GESTURES
200
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
201
return
;
202
}
203
mParent
->
mSerial
=
serial
;
204
const
auto
*
pointer
=
mParent
->
pointer
();
205
206
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_end @ "
207
<<
pointer
->
mSurfacePos
<< (
cancelled
?
"CANCELED"
:
""
);
208
209
auto
gestureType
=
cancelled
?
Qt
::
GestureFinished
:
Qt
::
GestureCanceled
;
210
211
auto
e
=
QWaylandPointerGesturePinchEvent
(
mFocus
,
gestureType
,
time
,
212
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
213
QPointF
(), 0, 0);
214
215
if
(
auto
ww
=
mFocus
->
waylandWindow
()) {
216
ww
->
handlePinchGesture
(
mParent
,
e
);
217
}
218
mFocus
.
clear
();
219
mFingers
= 0;
220
mLastScale
= 1;
221
#
endif
222
}
223
224
}
// namespace QtWaylandClient
225
226
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
qtbase
src
plugins
platforms
wayland
qwaylandpointergestures.cpp
Generated on
for Qt by
1.18.0