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
5#ifndef QWAYLANDINPUTDEVICE_H
6#define QWAYLANDINPUTDEVICE_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
20#include <QtWaylandClient/private/qwaylandwindow_p.h>
21
22#include <QtCore/QScopedPointer>
23#include <QSocketNotifier>
24#include <QObject>
25#include <QTimer>
26#include <qpa/qplatformintegration.h>
27#include <qpa/qplatformscreen.h>
28#include <qpa/qwindowsysteminterface.h>
29
30#include <QtWaylandClient/private/qwayland-wayland.h>
31#include <QtWaylandClient/private/qwayland-pointer-gestures-unstable-v1.h>
32
33#if QT_CONFIG(xkbcommon)
34#include <QtGui/private/qxkbcommon_p.h>
35#endif
36
37#include <QtCore/QDebug>
38#include <QtCore/QElapsedTimer>
39#include <QtCore/QPointer>
40
41#if QT_CONFIG(cursor)
42struct wl_cursor_image;
43#endif
44
46
47namespace QtWayland {
48class zwp_primary_selection_device_v1;
49} //namespace QtWayland
50
51namespace QtWaylandClient {
52
54class QWaylandDisplay;
55#if QT_CONFIG(clipboard)
57#endif
58#if QT_CONFIG(wayland_client_primary_selection)
60#endif
61#if QT_CONFIG(tabletevent)
63#endif
64class QWaylandPointerGestures;
65class QWaylandPointerGestureSwipe;
66class QWaylandPointerGesturePinch;
69#if QT_CONFIG(cursor)
72template <typename T>
73class CursorSurface;
74#endif
75
77
87
88class Q_WAYLANDCLIENT_EXPORT QWaylandInputDevice
89 : public QObject
90 , public QtWayland::wl_seat
91{
93public:
94 class Keyboard;
95 class Pointer;
96 class Touch;
97
100
101 uint32_t id() const { return mId; }
102 uint32_t capabilities() const { return mCaps; }
103 QString seatname() const { return mSeatName; }
104
105 QWaylandDisplay *display() const { return mQDisplay; }
106 struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); }
107
108#if QT_CONFIG(cursor)
110#endif
111 void handleStartDrag();
112 void handleEndDrag();
113
114#if QT_CONFIG(wayland_datadevice)
117#endif
118
119#if QT_CONFIG(clipboard)
122#endif
123
124#if QT_CONFIG(wayland_client_primary_selection)
127#endif
128
129#if QT_CONFIG(tabletevent)
132#endif
133
136
139
141
144 QWaylandWindow *touchFocus() const;
145
146 QList<int> possibleKeys(const QKeyEvent *event) const;
147
149
151
152 uint32_t serial() const;
153
157
158 Keyboard *keyboard() const;
159 Pointer *pointer() const;
162 Touch *touch() const;
163
164protected:
166 struct wl_display *mDisplay = nullptr;
167
171
172#if QT_CONFIG(cursor)
173 struct CursorState {
174 QSharedPointer<QWaylandBuffer> bitmapBuffer; // not used with shape cursors
175 int bitmapScale = 1;
177 int fallbackOutputScale = 1;
180 } mCursor;
181#endif
182
183#if QT_CONFIG(wayland_datadevice)
185#endif
186
187#if QT_CONFIG(clipboard)
189#endif
190
191#if QT_CONFIG(wayland_client_primary_selection)
193#endif
194
200
203#if QT_CONFIG(tabletevent)
205#endif
206
209
211 void seat_name(const QString &name) override;
213
216
221 friend class QWaylandWindow;
223};
224
226{
227 return mSerial;
228}
229
230
232{
234
235public:
238
240
242 int32_t fd,
245 struct wl_surface *surface,
246 struct wl_array *keys) override;
248 struct wl_surface *surface) override;
257
260
262
270
272 int mRepeatRate = 25;
273 int mRepeatDelay = 400;
274
276
278
280
281#if QT_CONFIG(xkbcommon)
284 }
285#endif
286
287private Q_SLOTS:
289 void handleFocusLost();
290
291private:
292#if QT_CONFIG(xkbcommon)
293 bool createDefaultKeymap();
294#endif
297 const QString &text, bool autorepeat = false, ushort count = 1);
298
299#if QT_CONFIG(xkbcommon)
302#endif
304};
305
307{
309public:
311 ~Pointer() override;
313#if QT_CONFIG(cursor)
314 int idealCursorScale() const;
315 void updateCursorTheme();
316 void updateCursor();
317 void cursorTimerCallback();
318 void cursorFrameCallback();
320#endif
321 QWaylandInputDevice *seat() const { return mParent; }
322
323 struct ::wl_pointer *wl_pointer() { return QtWayland::wl_pointer::object(); }
324
325protected:
339 void pointer_frame() override;
342
343private Q_SLOTS:
345
346private:
347 void invalidateFocus();
348
349public:
350 void releaseButtons();
351 void leavePointers();
352
356#if QT_CONFIG(cursor)
357 struct {
359 QWaylandCursorTheme *theme = nullptr;
360 int themeBufferScale = 0;
363 bool gotFrameCallback = false;
364 bool gotTimerCallback = false;
365 } mCursor;
366#endif
371
388
389 bool mScrollBeginSent = false;
390 bool mScrollEnd = false;
393
395
396 void maybePointerFrame();
397
399 void flushScrollEvent();
400 void flushFrameEvent();
401private: //TODO: should other methods be private as well?
403};
404
436
438{
440public:
472
479 Qt::MouseButton button = Qt::NoButton; // Button that caused the event (QMouseEvent::button)
485 bool inverted = false;
486};
487
488#ifndef QT_NO_GESTURES
513
543#endif // #ifndef QT_NO_GESTURES
544
545}
546
547QT_END_NAMESPACE
548
549#endif
friend class QPainter
static QRegion marginsRegion(const QSize &size, const QMargins &margins)
Q_DECLARE_LOGGING_CATEGORY(lcQpaWaylandInput)