1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#ifndef QWAYLANDSEAT_H
31#define QWAYLANDSEAT_H
32
33#include <QtCore/qnamespace.h>
34#include <QtCore/QPoint>
35#include <QtCore/QString>
36
37#include <QtWaylandCompositor/qtwaylandcompositorglobal.h>
38#include <QtWaylandCompositor/qwaylandcompositorextension.h>
39#include <QtWaylandCompositor/qwaylandkeyboard.h>
40
41QT_BEGIN_NAMESPACE
42
43class QWaylandCompositor;
44class QWaylandSurface;
45class QKeyEvent;
46class QTouchEvent;
47class QWaylandView;
48class QInputEvent;
49class QWaylandSeatPrivate;
50class QWaylandDrag;
51class QWaylandKeyboard;
52class QWaylandPointer;
53class QWaylandTouch;
54
55class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSeat : public QWaylandObject
56{
57 Q_OBJECT
58 Q_DECLARE_PRIVATE(QWaylandSeat)
59
60#if QT_CONFIG(draganddrop)
61 Q_PROPERTY(QWaylandDrag *drag READ drag CONSTANT)
62#endif
63 Q_PROPERTY(QWaylandKeymap *keymap READ keymap CONSTANT)
64public:
65 enum CapabilityFlag {
66 // The order should match the enum WL_SEAT_CAPABILITY_*
67 Pointer = 0x01,
68 Keyboard = 0x02,
69 Touch = 0x04,
70
71 DefaultCapabilities = Pointer | Keyboard | Touch
72 };
73 Q_DECLARE_FLAGS(CapabilityFlags, CapabilityFlag)
74 Q_ENUM(CapabilityFlags)
75
76 QWaylandSeat(QWaylandCompositor *compositor, CapabilityFlags capabilityFlags = DefaultCapabilities);
77 ~QWaylandSeat() override;
78 virtual void initialize();
79 bool isInitialized() const;
80
81 void sendMousePressEvent(Qt::MouseButton button);
82 void sendMouseReleaseEvent(Qt::MouseButton button);
83 void sendMouseMoveEvent(QWaylandView *surface , const QPointF &localPos, const QPointF &outputSpacePos = QPointF());
84 void sendMouseWheelEvent(Qt::Orientation orientation, int delta);
85
86 void sendKeyPressEvent(uint code);
87 void sendKeyReleaseEvent(uint code);
88
89 void sendFullKeyEvent(QKeyEvent *event);
90 Q_INVOKABLE void sendKeyEvent(int qtKey, bool pressed);
91
92 uint sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state);
93 Q_INVOKABLE uint sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position);
94 Q_INVOKABLE uint sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position);
95 Q_INVOKABLE uint sendTouchPointMoved(QWaylandSurface *surface, int id, const QPointF &position);
96 Q_INVOKABLE void sendTouchFrameEvent(QWaylandClient *client);
97 Q_INVOKABLE void sendTouchCancelEvent(QWaylandClient *client);
98
99 void sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *event);
100
101 QWaylandPointer *pointer() const;
102 //Normally set by the mouse device,
103 //But can be set manually for use with touch or can reset unset the current mouse focus;
104 QWaylandView *mouseFocus() const;
105 void setMouseFocus(QWaylandView *view);
106
107 QWaylandKeyboard *keyboard() const;
108 QWaylandSurface *keyboardFocus() const;
109 bool setKeyboardFocus(QWaylandSurface *surface);
110 QWaylandKeymap *keymap();
111
112 QWaylandTouch *touch() const;
113
114 QWaylandCompositor *compositor() const;
115
116#if QT_CONFIG(draganddrop)
117 QWaylandDrag *drag() const;
118#endif
119
120 QWaylandSeat::CapabilityFlags capabilities() const;
121
122 virtual bool isOwner(QInputEvent *inputEvent) const;
123
124 static QWaylandSeat *fromSeatResource(struct ::wl_resource *resource);
125
126Q_SIGNALS:
127 void mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus);
128 void keyboardFocusChanged(QWaylandSurface *newFocus, QWaylandSurface *oldFocus);
129 void cursorSurfaceRequest(QWaylandSurface *surface, int hotspotX, int hotspotY);
130
131private:
132 void handleMouseFocusDestroyed();
133};
134
135Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandSeat::CapabilityFlags)
136
137QT_END_NAMESPACE
138
139#endif // QWAYLANDSEAT_H
140

source code of qtwayland/src/compositor/compositor_api/qwaylandseat.h