KWin
Loading...
Searching...
No Matches
seat_p.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
3 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7#pragma once
8
9// KWayland
10#include "seat.h"
11// Qt
12#include <QHash>
13#include <QList>
14#include <QMap>
15#include <QPointer>
16
17#include <optional>
18
19#include "qwayland-server-wayland.h"
20
21namespace KWin
22{
23class AbstractDataSource;
24class DataDeviceInterface;
25class DataSourceInterface;
26class DataControlDeviceV1Interface;
27class TextInputV1Interface;
28class TextInputV2Interface;
29class TextInputV3Interface;
30class PrimarySelectionDeviceV1Interface;
31class DragAndDropIcon;
32
33class SeatInterfacePrivate : public QtWaylandServer::wl_seat
34{
35public:
36 // exported for unit tests
37 KWIN_EXPORT static SeatInterfacePrivate *get(SeatInterface *seat);
39
40 void sendCapabilities();
41 QList<DataDeviceInterface *> dataDevicesForSurface(SurfaceInterface *surface) const;
45 void endDrag();
46 void cancelDrag();
47 bool dragInhibitsPointer(SurfaceInterface *surface) const;
48
50 QPointer<Display> display;
51 QString name;
52 std::chrono::milliseconds timestamp = std::chrono::milliseconds::zero();
53 quint32 capabilities = 0;
54 std::unique_ptr<KeyboardInterface> keyboard;
55 std::unique_ptr<PointerInterface> pointer;
56 std::unique_ptr<TouchInterface> touch;
57 QList<DataDeviceInterface *> dataDevices;
58 QList<PrimarySelectionDeviceV1Interface *> primarySelectionDevices;
59 QList<DataControlDeviceV1Interface *> dataControlDevices;
60
61 QPointer<TextInputV1Interface> textInputV1;
62 // TextInput v2
63 QPointer<TextInputV2Interface> textInputV2;
64 QPointer<TextInputV3Interface> textInputV3;
65
67 QMetaObject::Connection focusedSurfaceDestroyConnection;
68
69 // the last thing copied into the clipboard content
72
73 // Pointer related members
74 struct Pointer
75 {
76 enum class State {
78 Pressed,
79 };
80 QHash<quint32, quint32> buttonSerials;
81 QHash<quint32, State> buttonStates;
82 QPointF pos;
83 struct Focus
84 {
86 QMetaObject::Connection destroyConnection;
87 QPointF offset = QPointF();
88 QMatrix4x4 transformation;
89 quint32 serial = 0;
90 };
92 };
94 void updatePointerButtonSerial(quint32 button, quint32 serial);
95 void updatePointerButtonState(quint32 button, Pointer::State state);
96
97 // Keyboard related members
98 struct Keyboard
99 {
100 struct Focus
101 {
103 QMetaObject::Connection destroyConnection;
104 quint32 serial = 0;
105 QList<DataDeviceInterface *> selections;
106 QList<PrimarySelectionDeviceV1Interface *> primarySelections;
107 };
109 };
111
112 // Touch related members
113 struct Touch
114 {
115 struct Focus
116 {
118 QMetaObject::Connection destroyConnection;
119 QPointF offset = QPointF();
121 QMatrix4x4 transformation;
122 };
124 QMap<qint32, quint32> ids;
125 };
127
128 struct Drag
129 {
130 enum class Mode {
131 None,
132 Pointer,
133 Touch,
134 };
137 QPointer<SurfaceInterface> surface;
138 QPointer<AbstractDropHandler> target;
139 QPointer<DragAndDropIcon> dragIcon;
140 QMatrix4x4 transformation;
141 std::optional<quint32> dragImplicitGrabSerial;
142 QMetaObject::Connection dragSourceDestroyConnection;
143 };
145
146protected:
147 void seat_bind_resource(Resource *resource) override;
148 void seat_get_pointer(Resource *resource, uint32_t id) override;
149 void seat_get_keyboard(Resource *resource, uint32_t id) override;
150 void seat_get_touch(Resource *resource, uint32_t id) override;
151 void seat_release(Resource *resource) override;
152
153private:
154 void updateSelection(DataDeviceInterface *dataDevice);
155 void updatePrimarySelection(PrimarySelectionDeviceV1Interface *primarySelectionDevice);
156};
157
158} // namespace KWin
The AbstractDataSource class abstracts the data that can be transferred to another client.
DataDeviceInterface allows clients to share data by copy-and-paste and drag-and-drop.
Definition datadevice.h:80
Class holding the Wayland server display loop.
Definition display.h:34
Represents the Resource for the wl_data_device interface.
Represents a Seat on the Wayland Display.
Definition seat.h:134
void seat_release(Resource *resource) override
Definition seat.cpp:89
void registerPrimarySelectionDevice(PrimarySelectionDeviceV1Interface *primarySelectionDevice)
Definition seat.cpp:231
QMetaObject::Connection focusedSurfaceDestroyConnection
Definition seat_p.h:67
void registerDataControlDevice(DataControlDeviceV1Interface *dataDevice)
Definition seat.cpp:191
bool dragInhibitsPointer(SurfaceInterface *surface) const
Definition seat.cpp:271
QPointer< Display > display
Definition seat_p.h:50
void seat_get_keyboard(Resource *resource, uint32_t id) override
Definition seat.cpp:77
void seat_get_touch(Resource *resource, uint32_t id) override
Definition seat.cpp:83
void updatePointerButtonSerial(quint32 button, quint32 serial)
Definition seat.cpp:110
SeatInterfacePrivate(SeatInterface *q, Display *display)
Definition seat.cpp:49
void seat_bind_resource(Resource *resource) override
Definition seat.cpp:62
static KWIN_EXPORT SeatInterfacePrivate * get(SeatInterface *seat)
Definition seat.cpp:44
SeatInterface * q
Definition seat_p.h:49
void registerDataDevice(DataDeviceInterface *dataDevice)
Definition seat.cpp:144
std::unique_ptr< PointerInterface > pointer
Definition seat_p.h:55
QList< DataDeviceInterface * > dataDevicesForSurface(SurfaceInterface *surface) const
Definition seat.cpp:130
void seat_get_pointer(Resource *resource, uint32_t id) override
Definition seat.cpp:71
void updatePointerButtonState(quint32 button, Pointer::State state)
Definition seat.cpp:120
std::unique_ptr< TouchInterface > touch
Definition seat_p.h:56
AbstractDataSource * currentSelection
Definition seat_p.h:70
QList< DataControlDeviceV1Interface * > dataControlDevices
Definition seat_p.h:59
QList< PrimarySelectionDeviceV1Interface * > primarySelectionDevices
Definition seat_p.h:58
QPointer< TextInputV3Interface > textInputV3
Definition seat_p.h:64
QList< DataDeviceInterface * > dataDevices
Definition seat_p.h:57
QPointer< TextInputV2Interface > textInputV2
Definition seat_p.h:63
AbstractDataSource * currentPrimarySelection
Definition seat_p.h:71
QPointer< TextInputV1Interface > textInputV1
Definition seat_p.h:61
std::chrono::milliseconds timestamp
Definition seat_p.h:52
std::unique_ptr< KeyboardInterface > keyboard
Definition seat_p.h:54
SurfaceInterface * focusedTextInputSurface
Definition seat_p.h:66
Resource representing a wl_surface.
Definition surface.h:80
QPointer< DragAndDropIcon > dragIcon
Definition seat_p.h:139
std::optional< quint32 > dragImplicitGrabSerial
Definition seat_p.h:141
QMetaObject::Connection dragSourceDestroyConnection
Definition seat_p.h:142
QPointer< AbstractDropHandler > target
Definition seat_p.h:138
AbstractDataSource * source
Definition seat_p.h:136
QPointer< SurfaceInterface > surface
Definition seat_p.h:137
QList< PrimarySelectionDeviceV1Interface * > primarySelections
Definition seat_p.h:106
QList< DataDeviceInterface * > selections
Definition seat_p.h:105
QMetaObject::Connection destroyConnection
Definition seat_p.h:103
QMetaObject::Connection destroyConnection
Definition seat_p.h:86
QHash< quint32, State > buttonStates
Definition seat_p.h:81
QHash< quint32, quint32 > buttonSerials
Definition seat_p.h:80
QMetaObject::Connection destroyConnection
Definition seat_p.h:118
QMap< qint32, quint32 > ids
Definition seat_p.h:124