Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
);
31
}
32
33
QWaylandPointerGesturePinch
*
34
QWaylandPointerGestures
::
createPointerGesturePinch
(
QWaylandInputDevice
*
device
)
35
{
36
return
new
QWaylandPointerGesturePinch
(
device
);
37
}
38
39
QWaylandPointerGestureSwipe
::
QWaylandPointerGestureSwipe
(
QWaylandInputDevice
*
p
)
40
:
mParent
(
p
)
41
{
42
}
43
44
QWaylandPointerGestureSwipe
::~
QWaylandPointerGestureSwipe
()
45
{
46
destroy
();
47
}
48
49
void
QWaylandPointerGestureSwipe
::
zwp_pointer_gesture_swipe_v1_begin
(
uint32_t
serial
,
uint32_t
time
,
50
struct
::wl_surface *
surface
,
51
uint32_t
fingers
)
52
{
53
#
ifndef
QT_NO_GESTURES
54
mFocus
=
QWaylandSurface
::
fromWlSurface
(
surface
);
55
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
56
return
;
57
}
58
mParent
->
mSerial
=
serial
;
59
mFingers
=
fingers
;
60
61
const
auto
*
pointer
=
mParent
->
pointer
();
62
63
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_begin @ "
64
<<
pointer
->
mSurfacePos
<<
"fingers"
<<
fingers
;
65
66
auto
e
=
QWaylandPointerGestureSwipeEvent
(
mFocus
,
Qt
::
GestureStarted
,
time
,
67
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
68
QPointF
());
69
70
mFocus
->
waylandWindow
()->
handleSwipeGesture
(
mParent
,
e
);
71
#
endif
72
}
73
74
void
QWaylandPointerGestureSwipe
::
zwp_pointer_gesture_swipe_v1_update
(
uint32_t
time
,
75
wl_fixed_t
dx
,
wl_fixed_t
dy
)
76
{
77
#
ifndef
QT_NO_GESTURES
78
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
79
return
;
80
}
81
const
auto
*
pointer
=
mParent
->
pointer
();
82
83
const
QPointF
delta
=
QPointF
(
wl_fixed_to_double
(
dx
),
wl_fixed_to_double
(
dy
));
84
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_update @ "
85
<<
pointer
->
mSurfacePos
<<
"delta"
<<
delta
;
86
87
auto
e
=
QWaylandPointerGestureSwipeEvent
(
mFocus
,
Qt
::
GestureUpdated
,
time
,
88
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
delta
);
89
90
mFocus
->
waylandWindow
()->
handleSwipeGesture
(
mParent
,
e
);
91
#
endif
92
}
93
94
void
QWaylandPointerGestureSwipe
::
zwp_pointer_gesture_swipe_v1_end
(
uint32_t
serial
,
uint32_t
time
,
95
int32_t
cancelled
)
96
{
97
#
ifndef
QT_NO_GESTURES
98
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
99
return
;
100
}
101
mParent
->
mSerial
=
serial
;
102
const
auto
*
pointer
=
mParent
->
pointer
();
103
104
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_end @ "
105
<<
pointer
->
mSurfacePos
<< (
cancelled
?
"CANCELED"
:
""
);
106
107
auto
gestureType
=
cancelled
?
Qt
::
GestureFinished
:
Qt
::
GestureCanceled
;
108
109
auto
e
=
QWaylandPointerGestureSwipeEvent
(
mFocus
,
gestureType
,
time
,
110
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
111
QPointF
());
112
113
mFocus
->
waylandWindow
()->
handleSwipeGesture
(
mParent
,
e
);
114
115
mFocus
.
clear
();
116
mFingers
= 0;
117
#
endif
118
}
119
120
QWaylandPointerGesturePinch
::
QWaylandPointerGesturePinch
(
QWaylandInputDevice
*
p
)
121
:
mParent
(
p
)
122
{
123
}
124
125
QWaylandPointerGesturePinch
::~
QWaylandPointerGesturePinch
()
126
{
127
destroy
();
128
}
129
130
void
QWaylandPointerGesturePinch
::
zwp_pointer_gesture_pinch_v1_begin
(
uint32_t
serial
,
uint32_t
time
,
131
struct
::wl_surface *
surface
,
132
uint32_t
fingers
)
133
{
134
#
ifndef
QT_NO_GESTURES
135
mFocus
=
QWaylandSurface
::
fromWlSurface
(
surface
);
136
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
137
return
;
138
}
139
mParent
->
mSerial
=
serial
;
140
mFingers
=
fingers
;
141
mLastScale
= 1;
142
const
auto
*
pointer
=
mParent
->
pointer
();
143
144
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_pinch_v1_begin @ "
145
<<
pointer
->
mSurfacePos
<<
"fingers"
<<
fingers
;
146
147
auto
e
=
QWaylandPointerGesturePinchEvent
(
mFocus
,
Qt
::
GestureStarted
,
time
,
148
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
149
QPointF
(), 0, 0);
150
151
mFocus
->
waylandWindow
()->
handlePinchGesture
(
mParent
,
e
);
152
#
endif
153
}
154
155
void
QWaylandPointerGesturePinch
::
zwp_pointer_gesture_pinch_v1_update
(
uint32_t
time
,
156
wl_fixed_t
dx
,
wl_fixed_t
dy
,
157
wl_fixed_t
scale
,
158
wl_fixed_t
rotation
)
159
{
160
#
ifndef
QT_NO_GESTURES
161
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
162
return
;
163
}
164
const
auto
*
pointer
=
mParent
->
pointer
();
165
166
const
qreal
rscale
=
wl_fixed_to_double
(
scale
);
167
const
qreal
rot
=
wl_fixed_to_double
(
rotation
);
168
const
QPointF
delta
=
QPointF
(
wl_fixed_to_double
(
dx
),
wl_fixed_to_double
(
dy
));
169
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_pinch_v1_update @ "
170
<<
pointer
->
mSurfacePos
<<
"delta"
<<
delta
171
<<
"scale"
<<
mLastScale
<<
"->"
<<
rscale
172
<<
"delta"
<<
rscale
-
mLastScale
<<
"rot"
<<
rot
;
173
174
auto
e
=
QWaylandPointerGesturePinchEvent
(
mFocus
,
Qt
::
GestureUpdated
,
time
,
175
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
176
delta
,
rscale
-
mLastScale
,
rot
);
177
178
mFocus
->
waylandWindow
()->
handlePinchGesture
(
mParent
,
e
);
179
180
mLastScale
=
rscale
;
181
#
endif
182
}
183
184
void
QWaylandPointerGesturePinch
::
zwp_pointer_gesture_pinch_v1_end
(
uint32_t
serial
,
uint32_t
time
,
185
int32_t
cancelled
)
186
{
187
#
ifndef
QT_NO_GESTURES
188
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
189
return
;
190
}
191
mParent
->
mSerial
=
serial
;
192
const
auto
*
pointer
=
mParent
->
pointer
();
193
194
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_end @ "
195
<<
pointer
->
mSurfacePos
<< (
cancelled
?
"CANCELED"
:
""
);
196
197
auto
gestureType
=
cancelled
?
Qt
::
GestureFinished
:
Qt
::
GestureCanceled
;
198
199
auto
e
=
QWaylandPointerGesturePinchEvent
(
mFocus
,
gestureType
,
time
,
200
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
201
QPointF
(), 0, 0);
202
203
mFocus
->
waylandWindow
()->
handlePinchGesture
(
mParent
,
e
);
204
205
mFocus
.
clear
();
206
mFingers
= 0;
207
mLastScale
= 1;
208
#
endif
209
}
210
211
}
// namespace QtWaylandClient
212
213
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.16.1