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
qwaylandinputdevice_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2024 Jie Liu <liujie01@kylinos.cn>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6#ifndef QWAYLANDINPUTDEVICE_H
7#define QWAYLANDINPUTDEVICE_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
21#include <QtWaylandClient/private/qwaylandwindow_p.h>
22#include <QtWaylandClient/private/qwaylandsurface_p.h>
23
24#include <QSocketNotifier>
25#include <QObject>
26#include <QTimer>
27#include <qpa/qplatformintegration.h>
28#include <qpa/qplatformscreen.h>
29#include <qpa/qwindowsysteminterface.h>
30
31#include <QtWaylandClient/private/qwayland-wayland.h>
32#include <QtWaylandClient/private/qwayland-pointer-gestures-unstable-v1.h>
33
34#if QT_CONFIG(xkbcommon)
35#include <QtGui/private/qxkbcommon_p.h>
36#endif
37
38#include <QtCore/QDebug>
39#include <QtCore/QElapsedTimer>
40#include <QtCore/QPointer>
41
42#include <memory>
43
44#if QT_CONFIG(cursor)
45struct wl_cursor_image;
46#endif
47
49
50namespace QtWayland {
51class zwp_primary_selection_device_v1;
52} //namespace QtWayland
53
54namespace QtWaylandClient {
55
57class QWaylandDisplay;
58#if QT_CONFIG(clipboard)
60#endif
61#if QT_CONFIG(wayland_client_primary_selection)
63#endif
64#if QT_CONFIG(tabletevent)
66#endif
67class QWaylandPointerGestures;
68class QWaylandPointerGestureSwipe;
69class QWaylandPointerGesturePinch;
72#if QT_CONFIG(cursor)
75template <typename T>
76class CursorSurface;
77#endif
78
80
90
91class Q_WAYLANDCLIENT_EXPORT QWaylandInputDevice
92 : public QObject
93 , public QtWayland::wl_seat
94{
96public:
97 class Keyboard;
98 class Pointer;
99 class Touch;
100
103
104 uint32_t id() const { return mId; }
105 uint32_t capabilities() const { return mCaps; }
106 QString seatname() const { return mSeatName; }
107
108 QWaylandDisplay *display() const { return mQDisplay; }
109 struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); }
110
111#if QT_CONFIG(cursor)
113#endif
114 void handleStartDrag();
115 void handleEndDrag();
116
117#if QT_CONFIG(wayland_datadevice)
120#endif
121
122#if QT_CONFIG(clipboard)
125#endif
126
127#if QT_CONFIG(wayland_client_primary_selection)
130#endif
131
132#if QT_CONFIG(tabletevent)
135#endif
136
139
142
144
147 QWaylandWindow *touchFocus() const;
148
149 QList<int> possibleKeys(const QKeyEvent *event) const;
150
152
154
155 uint32_t serial() const;
156
160
161 Keyboard *keyboard() const;
162 Pointer *pointer() const;
165 Touch *touch() const;
166
167protected:
169 struct wl_display *mDisplay = nullptr;
170
174
175#if QT_CONFIG(cursor)
176 struct CursorState {
177 QSharedPointer<QWaylandBuffer> bitmapBuffer; // not used with shape cursors
178 int bitmapScale = 1;
180 int fallbackOutputScale = 1;
183 } mCursor;
184#endif
185
186#if QT_CONFIG(wayland_datadevice)
188#endif
189
190#if QT_CONFIG(clipboard)
192#endif
193
194#if QT_CONFIG(wayland_client_primary_selection)
196#endif
197
203
206#if QT_CONFIG(tabletevent)
208#endif
209
212
214 void seat_name(const QString &name) override;
216
219
224 friend class QWaylandWindow;
226};
227
229{
230 return mSerial;
231}
232
233
235{
237
238public:
241
243
245 int32_t fd,
248 struct wl_surface *surface,
249 struct wl_array *keys) override;
251 struct wl_surface *surface) override;
260
263
265
273
275 int mRepeatRate = 25;
276 int mRepeatDelay = 400;
277
279
281
283
284#if QT_CONFIG(xkbcommon)
287 }
288#endif
289
290private Q_SLOTS:
292 void handleFocusLost();
293
294private:
295#if QT_CONFIG(xkbcommon)
296 bool createDefaultKeymap();
297#endif
300 const QString &text, bool autorepeat = false, ushort count = 1);
301
302#if QT_CONFIG(xkbcommon)
305#endif
307};
308
310{
312public:
314 ~Pointer() override;
316#if QT_CONFIG(cursor)
317 int idealCursorScale() const;
318 void updateCursorTheme();
319 void updateCursor();
320 void cursorTimerCallback();
321 void cursorFrameCallback();
323#endif
324 QWaylandInputDevice *seat() const { return mParent; }
325
326 struct ::wl_pointer *wl_pointer() { return QtWayland::wl_pointer::object(); }
327
328protected:
342 void pointer_frame() override;
345
346private Q_SLOTS:
348
349private:
350 void invalidateFocus();
351
352public:
353 void releaseButtons();
354 void leavePointers();
355
359#if QT_CONFIG(cursor)
360 struct {
362 QWaylandCursorTheme *theme = nullptr;
363 int themeBufferScale = 0;
366 bool gotFrameCallback = false;
367 bool gotTimerCallback = false;
368 } mCursor;
369#endif
374
391
392 bool mScrollBeginSent = false;
393 bool mScrollEnd = false;
396
398
399 void maybePointerFrame();
400
402 void flushScrollEvent();
403 void flushFrameEvent();
404private: //TODO: should other methods be private as well?
406};
407
439
441{
443public:
475
482 Qt::MouseButton button = Qt::NoButton; // Button that caused the event (QMouseEvent::button)
488 bool inverted = false;
489};
490
491#ifndef QT_NO_GESTURES
516
546#endif // #ifndef QT_NO_GESTURES
547
548}
549
550QT_END_NAMESPACE
551
552#endif
friend class QPainter
Combined button and popup list for selecting options.
static QRegion marginsRegion(const QSize &size, const QMargins &margins)
Q_DECLARE_LOGGING_CATEGORY(lcQpaWaylandInput)