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 <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#include <memory>
42
43#if QT_CONFIG(cursor)
44struct wl_cursor_image;
45#endif
46
48
49namespace QtWayland {
50class zwp_primary_selection_device_v1;
51} //namespace QtWayland
52
53namespace QtWaylandClient {
54
56class QWaylandDisplay;
57#if QT_CONFIG(clipboard)
59#endif
60#if QT_CONFIG(wayland_client_primary_selection)
62#endif
63#if QT_CONFIG(tabletevent)
65#endif
66class QWaylandPointerGestures;
67class QWaylandPointerGestureSwipe;
68class QWaylandPointerGesturePinch;
71#if QT_CONFIG(cursor)
74template <typename T>
75class CursorSurface;
76#endif
77
79
89
90class Q_WAYLANDCLIENT_EXPORT QWaylandInputDevice
91 : public QObject
92 , public QtWayland::wl_seat
93{
95public:
96 class Keyboard;
97 class Pointer;
98 class Touch;
99
102
103 uint32_t id() const { return mId; }
104 uint32_t capabilities() const { return mCaps; }
105 QString seatname() const { return mSeatName; }
106
107 QWaylandDisplay *display() const { return mQDisplay; }
108 struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); }
109
110#if QT_CONFIG(cursor)
112#endif
113 void handleStartDrag();
114 void handleEndDrag();
115
116#if QT_CONFIG(wayland_datadevice)
119#endif
120
121#if QT_CONFIG(clipboard)
124#endif
125
126#if QT_CONFIG(wayland_client_primary_selection)
129#endif
130
131#if QT_CONFIG(tabletevent)
134#endif
135
138
141
143
146 QWaylandWindow *touchFocus() const;
147
148 QList<int> possibleKeys(const QKeyEvent *event) const;
149
151
153
154 uint32_t serial() const;
155
159
160 Keyboard *keyboard() const;
161 Pointer *pointer() const;
164 Touch *touch() const;
165
166protected:
168 struct wl_display *mDisplay = nullptr;
169
173
174#if QT_CONFIG(cursor)
175 struct CursorState {
176 QSharedPointer<QWaylandBuffer> bitmapBuffer; // not used with shape cursors
177 int bitmapScale = 1;
179 int fallbackOutputScale = 1;
182 } mCursor;
183#endif
184
185#if QT_CONFIG(wayland_datadevice)
187#endif
188
189#if QT_CONFIG(clipboard)
191#endif
192
193#if QT_CONFIG(wayland_client_primary_selection)
195#endif
196
202
205#if QT_CONFIG(tabletevent)
207#endif
208
211
213 void seat_name(const QString &name) override;
215
218
223 friend class QWaylandWindow;
225};
226
228{
229 return mSerial;
230}
231
232
234{
236
237public:
240
242
244 int32_t fd,
247 struct wl_surface *surface,
248 struct wl_array *keys) override;
250 struct wl_surface *surface) override;
259
262
264
272
274 int mRepeatRate = 25;
275 int mRepeatDelay = 400;
276
278
280
282
283#if QT_CONFIG(xkbcommon)
286 }
287#endif
288
289private Q_SLOTS:
291 void handleFocusLost();
292
293private:
294#if QT_CONFIG(xkbcommon)
295 bool createDefaultKeymap();
296#endif
299 const QString &text, bool autorepeat = false, ushort count = 1);
300
301#if QT_CONFIG(xkbcommon)
304#endif
306};
307
309{
311public:
313 ~Pointer() override;
315#if QT_CONFIG(cursor)
316 int idealCursorScale() const;
317 void updateCursorTheme();
318 void updateCursor();
319 void cursorTimerCallback();
320 void cursorFrameCallback();
322#endif
323 QWaylandInputDevice *seat() const { return mParent; }
324
325 struct ::wl_pointer *wl_pointer() { return QtWayland::wl_pointer::object(); }
326
327protected:
341 void pointer_frame() override;
344
345private Q_SLOTS:
347
348private:
349 void invalidateFocus();
350
351public:
352 void releaseButtons();
353 void leavePointers();
354
358#if QT_CONFIG(cursor)
359 struct {
361 QWaylandCursorTheme *theme = nullptr;
362 int themeBufferScale = 0;
365 bool gotFrameCallback = false;
366 bool gotTimerCallback = false;
367 } mCursor;
368#endif
373
390
391 bool mScrollBeginSent = false;
392 bool mScrollEnd = false;
395
397
398 void maybePointerFrame();
399
401 void flushScrollEvent();
402 void flushFrameEvent();
403private: //TODO: should other methods be private as well?
405};
406
438
440{
442public:
474
481 Qt::MouseButton button = Qt::NoButton; // Button that caused the event (QMouseEvent::button)
487 bool inverted = false;
488};
489
490#ifndef QT_NO_GESTURES
515
545#endif // #ifndef QT_NO_GESTURES
546
547}
548
549QT_END_NAMESPACE
550
551#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)