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
23#include <QtCore/QScopedPointer>
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#if QT_CONFIG(cursor)
43struct wl_cursor_image;
44#endif
45
47
48namespace QtWayland {
49class zwp_primary_selection_device_v1;
50} //namespace QtWayland
51
52namespace QtWaylandClient {
53
55class QWaylandDisplay;
56#if QT_CONFIG(clipboard)
58#endif
59#if QT_CONFIG(wayland_client_primary_selection)
61#endif
62#if QT_CONFIG(tabletevent)
64#endif
65class QWaylandPointerGestures;
66class QWaylandPointerGestureSwipe;
67class QWaylandPointerGesturePinch;
70#if QT_CONFIG(cursor)
73template <typename T>
74class CursorSurface;
75#endif
76
78
88
89class Q_WAYLANDCLIENT_EXPORT QWaylandInputDevice
90 : public QObject
91 , public QtWayland::wl_seat
92{
94public:
95 class Keyboard;
96 class Pointer;
97 class Touch;
98
101
102 uint32_t id() const { return mId; }
103 uint32_t capabilities() const { return mCaps; }
104 QString seatname() const { return mSeatName; }
105
106 QWaylandDisplay *display() const { return mQDisplay; }
107 struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); }
108
109#if QT_CONFIG(cursor)
111#endif
112 void handleStartDrag();
113 void handleEndDrag();
114
115#if QT_CONFIG(wayland_datadevice)
118#endif
119
120#if QT_CONFIG(clipboard)
123#endif
124
125#if QT_CONFIG(wayland_client_primary_selection)
128#endif
129
130#if QT_CONFIG(tabletevent)
133#endif
134
137
140
142
145 QWaylandWindow *touchFocus() const;
146
147 QList<int> possibleKeys(const QKeyEvent *event) const;
148
150
152
153 uint32_t serial() const;
154
158
159 Keyboard *keyboard() const;
160 Pointer *pointer() const;
163 Touch *touch() const;
164
165protected:
167 struct wl_display *mDisplay = nullptr;
168
172
173#if QT_CONFIG(cursor)
174 struct CursorState {
175 QSharedPointer<QWaylandBuffer> bitmapBuffer; // not used with shape cursors
176 int bitmapScale = 1;
178 int fallbackOutputScale = 1;
181 } mCursor;
182#endif
183
184#if QT_CONFIG(wayland_datadevice)
186#endif
187
188#if QT_CONFIG(clipboard)
190#endif
191
192#if QT_CONFIG(wayland_client_primary_selection)
194#endif
195
201
204#if QT_CONFIG(tabletevent)
206#endif
207
210
212 void seat_name(const QString &name) override;
214
217
222 friend class QWaylandWindow;
224};
225
227{
228 return mSerial;
229}
230
231
233{
235
236public:
239
241
243 int32_t fd,
246 struct wl_surface *surface,
247 struct wl_array *keys) override;
249 struct wl_surface *surface) override;
258
261
263
271
273 int mRepeatRate = 25;
274 int mRepeatDelay = 400;
275
277
279
281
282#if QT_CONFIG(xkbcommon)
285 }
286#endif
287
288private Q_SLOTS:
290 void handleFocusLost();
291
292private:
293#if QT_CONFIG(xkbcommon)
294 bool createDefaultKeymap();
295#endif
298 const QString &text, bool autorepeat = false, ushort count = 1);
299
300#if QT_CONFIG(xkbcommon)
303#endif
305};
306
308{
310public:
312 ~Pointer() override;
314#if QT_CONFIG(cursor)
315 int idealCursorScale() const;
316 void updateCursorTheme();
317 void updateCursor();
318 void cursorTimerCallback();
319 void cursorFrameCallback();
321#endif
322 QWaylandInputDevice *seat() const { return mParent; }
323
324 struct ::wl_pointer *wl_pointer() { return QtWayland::wl_pointer::object(); }
325
326protected:
340 void pointer_frame() override;
343
344private Q_SLOTS:
346
347private:
348 void invalidateFocus();
349
350public:
351 void releaseButtons();
352 void leavePointers();
353
357#if QT_CONFIG(cursor)
358 struct {
360 QWaylandCursorTheme *theme = nullptr;
361 int themeBufferScale = 0;
364 bool gotFrameCallback = false;
365 bool gotTimerCallback = false;
366 } mCursor;
367#endif
372
389
390 bool mScrollBeginSent = false;
391 bool mScrollEnd = false;
394
396
397 void maybePointerFrame();
398
400 void flushScrollEvent();
401 void flushFrameEvent();
402private: //TODO: should other methods be private as well?
404};
405
437
439{
441public:
473
480 Qt::MouseButton button = Qt::NoButton; // Button that caused the event (QMouseEvent::button)
486 bool inverted = false;
487};
488
489#ifndef QT_NO_GESTURES
514
544#endif // #ifndef QT_NO_GESTURES
545
546}
547
548QT_END_NAMESPACE
549
550#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)