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
,
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
mFocus
->
waylandWindow
()->
handleSwipeGesture
(
mParent
,
e
);
72
#
endif
73
}
74
75
void
QWaylandPointerGestureSwipe
::
zwp_pointer_gesture_swipe_v1_update
(
uint32_t
time
,
76
wl_fixed_t
dx
,
wl_fixed_t
dy
)
77
{
78
#
ifndef
QT_NO_GESTURES
79
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
80
return
;
81
}
82
const
auto
*
pointer
=
mParent
->
pointer
();
83
84
const
QPointF
delta
=
QPointF
(
wl_fixed_to_double
(
dx
),
wl_fixed_to_double
(
dy
));
85
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_update @ "
86
<<
pointer
->
mSurfacePos
<<
"delta"
<<
delta
;
87
88
auto
e
=
QWaylandPointerGestureSwipeEvent
(
mFocus
,
Qt
::
GestureUpdated
,
time
,
89
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
delta
);
90
91
mFocus
->
waylandWindow
()->
handleSwipeGesture
(
mParent
,
e
);
92
#
endif
93
}
94
95
void
QWaylandPointerGestureSwipe
::
zwp_pointer_gesture_swipe_v1_end
(
uint32_t
serial
,
uint32_t
time
,
96
int32_t
cancelled
)
97
{
98
#
ifndef
QT_NO_GESTURES
99
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
100
return
;
101
}
102
mParent
->
mSerial
=
serial
;
103
const
auto
*
pointer
=
mParent
->
pointer
();
104
105
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_end @ "
106
<<
pointer
->
mSurfacePos
<< (
cancelled
?
"CANCELED"
:
""
);
107
108
auto
gestureType
=
cancelled
?
Qt
::
GestureFinished
:
Qt
::
GestureCanceled
;
109
110
auto
e
=
QWaylandPointerGestureSwipeEvent
(
mFocus
,
gestureType
,
time
,
111
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
112
QPointF
());
113
114
mFocus
->
waylandWindow
()->
handleSwipeGesture
(
mParent
,
e
);
115
116
mFocus
.
clear
();
117
mFingers
= 0;
118
#
endif
119
}
120
121
QWaylandPointerGesturePinch
::
QWaylandPointerGesturePinch
(
QWaylandInputDevice
*
p
, ::
zwp_pointer_gesture_pinch_v1
*
object
)
122
:
QtWayland
::
zwp_pointer_gesture_pinch_v1
(
object
)
123
,
mParent
(
p
)
124
{
125
}
126
127
QWaylandPointerGesturePinch
::~
QWaylandPointerGesturePinch
()
128
{
129
destroy
();
130
}
131
132
void
QWaylandPointerGesturePinch
::
zwp_pointer_gesture_pinch_v1_begin
(
uint32_t
serial
,
uint32_t
time
,
133
struct
::wl_surface *
surface
,
134
uint32_t
fingers
)
135
{
136
#
ifndef
QT_NO_GESTURES
137
mFocus
=
QWaylandSurface
::
fromWlSurface
(
surface
);
138
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
139
return
;
140
}
141
mParent
->
mSerial
=
serial
;
142
mFingers
=
fingers
;
143
mLastScale
= 1;
144
const
auto
*
pointer
=
mParent
->
pointer
();
145
146
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_pinch_v1_begin @ "
147
<<
pointer
->
mSurfacePos
<<
"fingers"
<<
fingers
;
148
149
auto
e
=
QWaylandPointerGesturePinchEvent
(
mFocus
,
Qt
::
GestureStarted
,
time
,
150
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
151
QPointF
(), 0, 0);
152
153
mFocus
->
waylandWindow
()->
handlePinchGesture
(
mParent
,
e
);
154
#
endif
155
}
156
157
void
QWaylandPointerGesturePinch
::
zwp_pointer_gesture_pinch_v1_update
(
uint32_t
time
,
158
wl_fixed_t
dx
,
wl_fixed_t
dy
,
159
wl_fixed_t
scale
,
160
wl_fixed_t
rotation
)
161
{
162
#
ifndef
QT_NO_GESTURES
163
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
164
return
;
165
}
166
const
auto
*
pointer
=
mParent
->
pointer
();
167
168
const
qreal
rscale
=
wl_fixed_to_double
(
scale
);
169
const
qreal
rot
=
wl_fixed_to_double
(
rotation
);
170
const
QPointF
delta
=
QPointF
(
wl_fixed_to_double
(
dx
),
wl_fixed_to_double
(
dy
));
171
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_pinch_v1_update @ "
172
<<
pointer
->
mSurfacePos
<<
"delta"
<<
delta
173
<<
"scale"
<<
mLastScale
<<
"->"
<<
rscale
174
<<
"delta"
<<
rscale
-
mLastScale
<<
"rot"
<<
rot
;
175
176
auto
e
=
QWaylandPointerGesturePinchEvent
(
mFocus
,
Qt
::
GestureUpdated
,
time
,
177
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
178
delta
,
rscale
-
mLastScale
,
rot
);
179
180
mFocus
->
waylandWindow
()->
handlePinchGesture
(
mParent
,
e
);
181
182
mLastScale
=
rscale
;
183
#
endif
184
}
185
186
void
QWaylandPointerGesturePinch
::
zwp_pointer_gesture_pinch_v1_end
(
uint32_t
serial
,
uint32_t
time
,
187
int32_t
cancelled
)
188
{
189
#
ifndef
QT_NO_GESTURES
190
if
(!
mFocus
|| !
mFocus
->
waylandWindow
()) {
191
return
;
192
}
193
mParent
->
mSerial
=
serial
;
194
const
auto
*
pointer
=
mParent
->
pointer
();
195
196
qCDebug
(
lcQpaWaylandInput
) <<
"zwp_pointer_gesture_swipe_v1_end @ "
197
<<
pointer
->
mSurfacePos
<< (
cancelled
?
"CANCELED"
:
""
);
198
199
auto
gestureType
=
cancelled
?
Qt
::
GestureFinished
:
Qt
::
GestureCanceled
;
200
201
auto
e
=
QWaylandPointerGesturePinchEvent
(
mFocus
,
gestureType
,
time
,
202
pointer
->
mSurfacePos
,
pointer
->
mGlobalPos
,
mFingers
,
203
QPointF
(), 0, 0);
204
205
mFocus
->
waylandWindow
()->
handlePinchGesture
(
mParent
,
e
);
206
207
mFocus
.
clear
();
208
mFingers
= 0;
209
mLastScale
= 1;
210
#
endif
211
}
212
213
}
// namespace QtWaylandClient
214
215
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