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
78class Q_WAYLANDCLIENT_EXPORT QWaylandInputDevice
79 : public QObject
80 , public QtWayland::wl_seat
81{
83public:
84 class Keyboard;
85 class Pointer;
86 class Touch;
87
90
91 uint32_t id() const { return mId; }
92 uint32_t capabilities() const { return mCaps; }
93 QString seatname() const { return mSeatName; }
94
95 QWaylandDisplay *display() const { return mQDisplay; }
96 struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); }
97
98#if QT_CONFIG(cursor)
100#endif
101 void handleStartDrag();
102 void handleEndDrag();
103
104#if QT_CONFIG(wayland_datadevice)
107#endif
108
109#if QT_CONFIG(clipboard)
112#endif
113
114#if QT_CONFIG(wayland_client_primary_selection)
117#endif
118
119#if QT_CONFIG(tabletevent)
122#endif
123
126
129
131
134 QWaylandWindow *touchFocus() const;
135
136 QList<int> possibleKeys(const QKeyEvent *event) const;
137
139
141
142 uint32_t serial() const;
143
147
148 Keyboard *keyboard() const;
149 Pointer *pointer() const;
152 Touch *touch() const;
153
154protected:
156 struct wl_display *mDisplay = nullptr;
157
161 bool mSeatNameKnown = false;
162
163#if QT_CONFIG(cursor)
164 struct CursorState {
165 QSharedPointer<QWaylandBuffer> bitmapBuffer; // not used with shape cursors
166 int bitmapScale = 1;
168 int fallbackOutputScale = 1;
171 } mCursor;
172#endif
173
174#if QT_CONFIG(wayland_datadevice)
176#endif
177
178#if QT_CONFIG(clipboard)
180#endif
181
182#if QT_CONFIG(wayland_client_primary_selection)
184#endif
185
191
194#if QT_CONFIG(tabletevent)
196#endif
197
200
202 void seat_name(const QString &name) override;
205
208
213 friend class QWaylandWindow;
215};
216
218{
219 return mSerial;
220}
221
222
224{
226
227public:
230
232
234 int32_t fd,
237 struct wl_surface *surface,
238 struct wl_array *keys) override;
240 struct wl_surface *surface) override;
249
252
254
262
264 int mRepeatRate = 25;
265 int mRepeatDelay = 400;
266
268
270
272
273#if QT_CONFIG(xkbcommon)
276 }
277#endif
278
279private Q_SLOTS:
281 void handleFocusLost();
282
283private:
284#if QT_CONFIG(xkbcommon)
285 bool createDefaultKeymap();
286#endif
289 const QString &text, bool autorepeat = false, ushort count = 1);
290
291#if QT_CONFIG(xkbcommon)
294#endif
296};
297
299{
301public:
303 ~Pointer() override;
305#if QT_CONFIG(cursor)
306 int idealCursorScale() const;
307 void updateCursorTheme();
308 void updateCursor();
309 void cursorTimerCallback();
310 void cursorFrameCallback();
312#endif
313 QWaylandInputDevice *seat() const { return mParent; }
314
315 struct ::wl_pointer *wl_pointer() { return QtWayland::wl_pointer::object(); }
316
317protected:
331 void pointer_frame() override;
334
335private Q_SLOTS:
337
338private:
339 void invalidateFocus();
340
341public:
342 void releaseButtons();
343 void leavePointers();
344
348#if QT_CONFIG(cursor)
349 struct {
351 QWaylandCursorTheme *theme = nullptr;
352 int themeBufferScale = 0;
355 bool gotFrameCallback = false;
356 bool gotTimerCallback = false;
357 } mCursor;
358#endif
363
380
381 bool mScrollBeginSent = false;
383
385 void flushScrollEvent();
386 void flushFrameEvent();
387private: //TODO: should other methods be private as well?
389};
390
422
424{
426public:
458
465 Qt::MouseButton button = Qt::NoButton; // Button that caused the event (QMouseEvent::button)
471 bool inverted = false;
472};
473
474#ifndef QT_NO_GESTURES
499
529#endif // #ifndef QT_NO_GESTURES
530
531}
532
533QT_END_NAMESPACE
534
535#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)