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