Changeset View
Changeset View
Standalone View
Standalone View
wayland_server.h
Show All 35 Lines | |||||
36 | class ConnectionThread; | 36 | class ConnectionThread; | ||
37 | class Registry; | 37 | class Registry; | ||
38 | class Compositor; | 38 | class Compositor; | ||
39 | class Seat; | 39 | class Seat; | ||
40 | class DataDeviceManager; | 40 | class DataDeviceManager; | ||
41 | class ShmPool; | 41 | class ShmPool; | ||
42 | class Surface; | 42 | class Surface; | ||
43 | } | 43 | } | ||
44 | namespace Server | 44 | } | ||
45 | namespace KWaylandServer | ||||
45 | { | 46 | { | ||
46 | class AppMenuManagerInterface; | 47 | class AppMenuManagerInterface; | ||
47 | class ClientConnection; | 48 | class ClientConnection; | ||
48 | class CompositorInterface; | 49 | class CompositorInterface; | ||
49 | class Display; | 50 | class Display; | ||
50 | class DataDeviceInterface; | 51 | class DataDeviceInterface; | ||
51 | class IdleInterface; | 52 | class IdleInterface; | ||
52 | class SeatInterface; | 53 | class SeatInterface; | ||
Show All 13 Lines | |||||
66 | class XdgShellInterface; | 67 | class XdgShellInterface; | ||
67 | class XdgForeignInterface; | 68 | class XdgForeignInterface; | ||
68 | class XdgOutputManagerInterface; | 69 | class XdgOutputManagerInterface; | ||
69 | class KeyStateInterface; | 70 | class KeyStateInterface; | ||
70 | class LinuxDmabufUnstableV1Interface; | 71 | class LinuxDmabufUnstableV1Interface; | ||
71 | class LinuxDmabufUnstableV1Buffer; | 72 | class LinuxDmabufUnstableV1Buffer; | ||
72 | class TabletManagerInterface; | 73 | class TabletManagerInterface; | ||
73 | } | 74 | } | ||
74 | } | 75 | | ||
75 | 76 | | |||
76 | namespace KWin | 77 | namespace KWin | ||
77 | { | 78 | { | ||
78 | class XdgShellClient; | 79 | class XdgShellClient; | ||
79 | 80 | | |||
80 | class AbstractClient; | 81 | class AbstractClient; | ||
81 | class Toplevel; | 82 | class Toplevel; | ||
82 | 83 | | |||
Show All 9 Lines | 87 | public: | |||
92 | }; | 93 | }; | ||
93 | 94 | | |||
94 | Q_DECLARE_FLAGS(InitializationFlags, InitializationFlag) | 95 | Q_DECLARE_FLAGS(InitializationFlags, InitializationFlag) | ||
95 | 96 | | |||
96 | ~WaylandServer() override; | 97 | ~WaylandServer() override; | ||
97 | bool init(const QByteArray &socketName = QByteArray(), InitializationFlags flags = InitializationFlag::NoOptions); | 98 | bool init(const QByteArray &socketName = QByteArray(), InitializationFlags flags = InitializationFlag::NoOptions); | ||
98 | void terminateClientConnections(); | 99 | void terminateClientConnections(); | ||
99 | 100 | | |||
100 | KWayland::Server::Display *display() { | 101 | KWaylandServer::Display *display() { | ||
101 | return m_display; | 102 | return m_display; | ||
102 | } | 103 | } | ||
103 | KWayland::Server::CompositorInterface *compositor() { | 104 | KWaylandServer::CompositorInterface *compositor() { | ||
104 | return m_compositor; | 105 | return m_compositor; | ||
105 | } | 106 | } | ||
106 | KWayland::Server::SeatInterface *seat() { | 107 | KWaylandServer::SeatInterface *seat() { | ||
107 | return m_seat; | 108 | return m_seat; | ||
108 | } | 109 | } | ||
109 | KWayland::Server::TabletManagerInterface *tabletManager() | 110 | KWaylandServer::TabletManagerInterface *tabletManager() | ||
110 | { | 111 | { | ||
111 | return m_tabletManager; | 112 | return m_tabletManager; | ||
112 | } | 113 | } | ||
113 | KWayland::Server::DataDeviceManagerInterface *dataDeviceManager() { | 114 | KWaylandServer::DataDeviceManagerInterface *dataDeviceManager() { | ||
114 | return m_dataDeviceManager; | 115 | return m_dataDeviceManager; | ||
115 | } | 116 | } | ||
116 | KWayland::Server::PlasmaVirtualDesktopManagementInterface *virtualDesktopManagement() { | 117 | KWaylandServer::PlasmaVirtualDesktopManagementInterface *virtualDesktopManagement() { | ||
117 | return m_virtualDesktopManagement; | 118 | return m_virtualDesktopManagement; | ||
118 | } | 119 | } | ||
119 | KWayland::Server::PlasmaWindowManagementInterface *windowManagement() { | 120 | KWaylandServer::PlasmaWindowManagementInterface *windowManagement() { | ||
120 | return m_windowManagement; | 121 | return m_windowManagement; | ||
121 | } | 122 | } | ||
122 | KWayland::Server::ServerSideDecorationManagerInterface *decorationManager() const { | 123 | KWaylandServer::ServerSideDecorationManagerInterface *decorationManager() const { | ||
123 | return m_decorationManager; | 124 | return m_decorationManager; | ||
124 | } | 125 | } | ||
125 | KWayland::Server::XdgOutputManagerInterface *xdgOutputManager() const { | 126 | KWaylandServer::XdgOutputManagerInterface *xdgOutputManager() const { | ||
126 | return m_xdgOutputManager; | 127 | return m_xdgOutputManager; | ||
127 | } | 128 | } | ||
128 | KWayland::Server::LinuxDmabufUnstableV1Interface *linuxDmabuf(); | 129 | KWaylandServer::LinuxDmabufUnstableV1Interface *linuxDmabuf(); | ||
129 | 130 | | |||
130 | QList<AbstractClient *> clients() const { | 131 | QList<AbstractClient *> clients() const { | ||
131 | return m_clients; | 132 | return m_clients; | ||
132 | } | 133 | } | ||
133 | void removeClient(AbstractClient *c); | 134 | void removeClient(AbstractClient *c); | ||
134 | AbstractClient *findClient(quint32 id) const; | 135 | AbstractClient *findClient(quint32 id) const; | ||
135 | AbstractClient *findClient(KWayland::Server::SurfaceInterface *surface) const; | 136 | AbstractClient *findClient(KWaylandServer::SurfaceInterface *surface) const; | ||
136 | XdgShellClient *findXdgShellClient(KWayland::Server::SurfaceInterface *surface) const; | 137 | XdgShellClient *findXdgShellClient(KWaylandServer::SurfaceInterface *surface) const; | ||
137 | 138 | | |||
138 | /** | 139 | /** | ||
139 | * @returns a transient parent of a surface imported with the foreign protocol, if any | 140 | * @returns a transient parent of a surface imported with the foreign protocol, if any | ||
140 | */ | 141 | */ | ||
141 | KWayland::Server::SurfaceInterface *findForeignTransientForSurface(KWayland::Server::SurfaceInterface *surface); | 142 | KWaylandServer::SurfaceInterface *findForeignTransientForSurface(KWaylandServer::SurfaceInterface *surface); | ||
142 | 143 | | |||
143 | /** | 144 | /** | ||
144 | * @returns file descriptor for Xwayland to connect to. | 145 | * @returns file descriptor for Xwayland to connect to. | ||
145 | */ | 146 | */ | ||
146 | int createXWaylandConnection(); | 147 | int createXWaylandConnection(); | ||
147 | void destroyXWaylandConnection(); | 148 | void destroyXWaylandConnection(); | ||
148 | 149 | | |||
149 | /** | 150 | /** | ||
Show All 14 Lines | |||||
164 | /** | 165 | /** | ||
165 | * @returns whether any kind of global shortcuts are supported. | 166 | * @returns whether any kind of global shortcuts are supported. | ||
166 | */ | 167 | */ | ||
167 | bool hasGlobalShortcutSupport() const; | 168 | bool hasGlobalShortcutSupport() const; | ||
168 | 169 | | |||
169 | void createInternalConnection(); | 170 | void createInternalConnection(); | ||
170 | void initWorkspace(); | 171 | void initWorkspace(); | ||
171 | 172 | | |||
172 | KWayland::Server::ClientConnection *xWaylandConnection() const { | 173 | KWaylandServer::ClientConnection *xWaylandConnection() const { | ||
173 | return m_xwayland.client; | 174 | return m_xwayland.client; | ||
174 | } | 175 | } | ||
175 | KWayland::Server::ClientConnection *inputMethodConnection() const { | 176 | KWaylandServer::ClientConnection *inputMethodConnection() const { | ||
176 | return m_inputMethodServerConnection; | 177 | return m_inputMethodServerConnection; | ||
177 | } | 178 | } | ||
178 | KWayland::Server::ClientConnection *internalConnection() const { | 179 | KWaylandServer::ClientConnection *internalConnection() const { | ||
179 | return m_internalConnection.server; | 180 | return m_internalConnection.server; | ||
180 | } | 181 | } | ||
181 | KWayland::Server::ClientConnection *screenLockerClientConnection() const { | 182 | KWaylandServer::ClientConnection *screenLockerClientConnection() const { | ||
182 | return m_screenLockerClientConnection; | 183 | return m_screenLockerClientConnection; | ||
183 | } | 184 | } | ||
184 | KWayland::Client::Compositor *internalCompositor() { | 185 | KWayland::Client::Compositor *internalCompositor() { | ||
185 | return m_internalConnection.compositor; | 186 | return m_internalConnection.compositor; | ||
186 | } | 187 | } | ||
187 | KWayland::Client::Seat *internalSeat() { | 188 | KWayland::Client::Seat *internalSeat() { | ||
188 | return m_internalConnection.seat; | 189 | return m_internalConnection.seat; | ||
189 | } | 190 | } | ||
190 | KWayland::Client::DataDeviceManager *internalDataDeviceManager() { | 191 | KWayland::Client::DataDeviceManager *internalDataDeviceManager() { | ||
191 | return m_internalConnection.ddm; | 192 | return m_internalConnection.ddm; | ||
192 | } | 193 | } | ||
193 | KWayland::Client::ShmPool *internalShmPool() { | 194 | KWayland::Client::ShmPool *internalShmPool() { | ||
194 | return m_internalConnection.shm; | 195 | return m_internalConnection.shm; | ||
195 | } | 196 | } | ||
196 | KWayland::Client::ConnectionThread *internalClientConection() { | 197 | KWayland::Client::ConnectionThread *internalClientConection() { | ||
197 | return m_internalConnection.client; | 198 | return m_internalConnection.client; | ||
198 | } | 199 | } | ||
199 | KWayland::Client::Registry *internalClientRegistry() { | 200 | KWayland::Client::Registry *internalClientRegistry() { | ||
200 | return m_internalConnection.registry; | 201 | return m_internalConnection.registry; | ||
201 | } | 202 | } | ||
202 | void dispatch(); | 203 | void dispatch(); | ||
203 | quint32 createWindowId(KWayland::Server::SurfaceInterface *surface); | 204 | quint32 createWindowId(KWaylandServer::SurfaceInterface *surface); | ||
204 | 205 | | |||
205 | /** | 206 | /** | ||
206 | * Struct containing information for a created Wayland connection through a | 207 | * Struct containing information for a created Wayland connection through a | ||
207 | * socketpair. | 208 | * socketpair. | ||
208 | */ | 209 | */ | ||
209 | struct SocketPairConnection { | 210 | struct SocketPairConnection { | ||
210 | /** | 211 | /** | ||
211 | * ServerSide Connection | 212 | * ServerSide Connection | ||
212 | */ | 213 | */ | ||
213 | KWayland::Server::ClientConnection *connection = nullptr; | 214 | KWaylandServer::ClientConnection *connection = nullptr; | ||
214 | /** | 215 | /** | ||
215 | * client-side file descriptor for the socket | 216 | * client-side file descriptor for the socket | ||
216 | */ | 217 | */ | ||
217 | int fd = -1; | 218 | int fd = -1; | ||
218 | }; | 219 | }; | ||
219 | /** | 220 | /** | ||
220 | * Creates a Wayland connection using a socket pair. | 221 | * Creates a Wayland connection using a socket pair. | ||
221 | */ | 222 | */ | ||
222 | SocketPairConnection createConnection(); | 223 | SocketPairConnection createConnection(); | ||
223 | 224 | | |||
224 | void simulateUserActivity(); | 225 | void simulateUserActivity(); | ||
225 | void updateKeyState(KWin::Xkb::LEDs leds); | 226 | void updateKeyState(KWin::Xkb::LEDs leds); | ||
226 | 227 | | |||
227 | QSet<KWayland::Server::LinuxDmabufUnstableV1Buffer*> linuxDmabufBuffers() const { | 228 | QSet<KWaylandServer::LinuxDmabufUnstableV1Buffer*> linuxDmabufBuffers() const { | ||
228 | return m_linuxDmabufBuffers; | 229 | return m_linuxDmabufBuffers; | ||
229 | } | 230 | } | ||
230 | void addLinuxDmabufBuffer(KWayland::Server::LinuxDmabufUnstableV1Buffer *buffer) { | 231 | void addLinuxDmabufBuffer(KWaylandServer::LinuxDmabufUnstableV1Buffer *buffer) { | ||
231 | m_linuxDmabufBuffers << buffer; | 232 | m_linuxDmabufBuffers << buffer; | ||
232 | } | 233 | } | ||
233 | void removeLinuxDmabufBuffer(KWayland::Server::LinuxDmabufUnstableV1Buffer *buffer) { | 234 | void removeLinuxDmabufBuffer(KWaylandServer::LinuxDmabufUnstableV1Buffer *buffer) { | ||
234 | m_linuxDmabufBuffers.remove(buffer); | 235 | m_linuxDmabufBuffers.remove(buffer); | ||
235 | } | 236 | } | ||
236 | 237 | | |||
237 | Q_SIGNALS: | 238 | Q_SIGNALS: | ||
238 | void shellClientAdded(KWin::AbstractClient *); | 239 | void shellClientAdded(KWin::AbstractClient *); | ||
239 | void shellClientRemoved(KWin::AbstractClient *); | 240 | void shellClientRemoved(KWin::AbstractClient *); | ||
240 | void terminatingInternalClientConnection(); | 241 | void terminatingInternalClientConnection(); | ||
241 | void initialized(); | 242 | void initialized(); | ||
242 | void foreignTransientChanged(KWayland::Server::SurfaceInterface *child); | 243 | void foreignTransientChanged(KWaylandServer::SurfaceInterface *child); | ||
243 | 244 | | |||
244 | private: | 245 | private: | ||
245 | int createScreenLockerConnection(); | 246 | int createScreenLockerConnection(); | ||
246 | void shellClientShown(Toplevel *t); | 247 | void shellClientShown(Toplevel *t); | ||
247 | quint16 createClientId(KWayland::Server::ClientConnection *c); | 248 | quint16 createClientId(KWaylandServer::ClientConnection *c); | ||
248 | void destroyInternalConnection(); | 249 | void destroyInternalConnection(); | ||
249 | template <class T> | 250 | template <class T> | ||
250 | void createSurface(T *surface); | 251 | void createSurface(T *surface); | ||
251 | void initScreenLocker(); | 252 | void initScreenLocker(); | ||
252 | KWayland::Server::Display *m_display = nullptr; | 253 | KWaylandServer::Display *m_display = nullptr; | ||
253 | KWayland::Server::CompositorInterface *m_compositor = nullptr; | 254 | KWaylandServer::CompositorInterface *m_compositor = nullptr; | ||
254 | KWayland::Server::SeatInterface *m_seat = nullptr; | 255 | KWaylandServer::SeatInterface *m_seat = nullptr; | ||
255 | KWayland::Server::TabletManagerInterface *m_tabletManager = nullptr; | 256 | KWaylandServer::TabletManagerInterface *m_tabletManager = nullptr; | ||
256 | KWayland::Server::DataDeviceManagerInterface *m_dataDeviceManager = nullptr; | 257 | KWaylandServer::DataDeviceManagerInterface *m_dataDeviceManager = nullptr; | ||
257 | KWayland::Server::XdgShellInterface *m_xdgShell = nullptr; | 258 | KWaylandServer::XdgShellInterface *m_xdgShell = nullptr; | ||
258 | KWayland::Server::PlasmaShellInterface *m_plasmaShell = nullptr; | 259 | KWaylandServer::PlasmaShellInterface *m_plasmaShell = nullptr; | ||
259 | KWayland::Server::PlasmaWindowManagementInterface *m_windowManagement = nullptr; | 260 | KWaylandServer::PlasmaWindowManagementInterface *m_windowManagement = nullptr; | ||
260 | KWayland::Server::PlasmaVirtualDesktopManagementInterface *m_virtualDesktopManagement = nullptr; | 261 | KWaylandServer::PlasmaVirtualDesktopManagementInterface *m_virtualDesktopManagement = nullptr; | ||
261 | KWayland::Server::ServerSideDecorationManagerInterface *m_decorationManager = nullptr; | 262 | KWaylandServer::ServerSideDecorationManagerInterface *m_decorationManager = nullptr; | ||
262 | KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr; | 263 | KWaylandServer::OutputManagementInterface *m_outputManagement = nullptr; | ||
263 | KWayland::Server::AppMenuManagerInterface *m_appMenuManager = nullptr; | 264 | KWaylandServer::AppMenuManagerInterface *m_appMenuManager = nullptr; | ||
264 | KWayland::Server::ServerSideDecorationPaletteManagerInterface *m_paletteManager = nullptr; | 265 | KWaylandServer::ServerSideDecorationPaletteManagerInterface *m_paletteManager = nullptr; | ||
265 | KWayland::Server::IdleInterface *m_idle = nullptr; | 266 | KWaylandServer::IdleInterface *m_idle = nullptr; | ||
266 | KWayland::Server::XdgOutputManagerInterface *m_xdgOutputManager = nullptr; | 267 | KWaylandServer::XdgOutputManagerInterface *m_xdgOutputManager = nullptr; | ||
267 | KWayland::Server::XdgDecorationManagerInterface *m_xdgDecorationManager = nullptr; | 268 | KWaylandServer::XdgDecorationManagerInterface *m_xdgDecorationManager = nullptr; | ||
268 | KWayland::Server::LinuxDmabufUnstableV1Interface *m_linuxDmabuf = nullptr; | 269 | KWaylandServer::LinuxDmabufUnstableV1Interface *m_linuxDmabuf = nullptr; | ||
269 | QSet<KWayland::Server::LinuxDmabufUnstableV1Buffer*> m_linuxDmabufBuffers; | 270 | QSet<KWaylandServer::LinuxDmabufUnstableV1Buffer*> m_linuxDmabufBuffers; | ||
270 | struct { | 271 | struct { | ||
271 | KWayland::Server::ClientConnection *client = nullptr; | 272 | KWaylandServer::ClientConnection *client = nullptr; | ||
272 | QMetaObject::Connection destroyConnection; | 273 | QMetaObject::Connection destroyConnection; | ||
273 | } m_xwayland; | 274 | } m_xwayland; | ||
274 | KWayland::Server::ClientConnection *m_inputMethodServerConnection = nullptr; | 275 | KWaylandServer::ClientConnection *m_inputMethodServerConnection = nullptr; | ||
275 | KWayland::Server::ClientConnection *m_screenLockerClientConnection = nullptr; | 276 | KWaylandServer::ClientConnection *m_screenLockerClientConnection = nullptr; | ||
276 | struct { | 277 | struct { | ||
277 | KWayland::Server::ClientConnection *server = nullptr; | 278 | KWaylandServer::ClientConnection *server = nullptr; | ||
278 | KWayland::Client::ConnectionThread *client = nullptr; | 279 | KWayland::Client::ConnectionThread *client = nullptr; | ||
279 | QThread *clientThread = nullptr; | 280 | QThread *clientThread = nullptr; | ||
280 | KWayland::Client::Registry *registry = nullptr; | 281 | KWayland::Client::Registry *registry = nullptr; | ||
281 | KWayland::Client::Compositor *compositor = nullptr; | 282 | KWayland::Client::Compositor *compositor = nullptr; | ||
282 | KWayland::Client::Seat *seat = nullptr; | 283 | KWayland::Client::Seat *seat = nullptr; | ||
283 | KWayland::Client::DataDeviceManager *ddm = nullptr; | 284 | KWayland::Client::DataDeviceManager *ddm = nullptr; | ||
284 | KWayland::Client::ShmPool *shm = nullptr; | 285 | KWayland::Client::ShmPool *shm = nullptr; | ||
285 | bool interfacesAnnounced = false; | 286 | bool interfacesAnnounced = false; | ||
286 | 287 | | |||
287 | } m_internalConnection; | 288 | } m_internalConnection; | ||
288 | KWayland::Server::XdgForeignInterface *m_XdgForeign = nullptr; | 289 | KWaylandServer::XdgForeignInterface *m_XdgForeign = nullptr; | ||
289 | KWayland::Server::KeyStateInterface *m_keyState = nullptr; | 290 | KWaylandServer::KeyStateInterface *m_keyState = nullptr; | ||
290 | QList<AbstractClient *> m_clients; | 291 | QList<AbstractClient *> m_clients; | ||
291 | QHash<KWayland::Server::ClientConnection*, quint16> m_clientIds; | 292 | QHash<KWaylandServer::ClientConnection*, quint16> m_clientIds; | ||
292 | InitializationFlags m_initFlags; | 293 | InitializationFlags m_initFlags; | ||
293 | QVector<KWayland::Server::PlasmaShellSurfaceInterface*> m_plasmaShellSurfaces; | 294 | QVector<KWaylandServer::PlasmaShellSurfaceInterface*> m_plasmaShellSurfaces; | ||
294 | KWIN_SINGLETON(WaylandServer) | 295 | KWIN_SINGLETON(WaylandServer) | ||
295 | }; | 296 | }; | ||
296 | 297 | | |||
297 | inline | 298 | inline | ||
298 | WaylandServer *waylandServer() { | 299 | WaylandServer *waylandServer() { | ||
299 | return WaylandServer::self(); | 300 | return WaylandServer::self(); | ||
300 | } | 301 | } | ||
301 | 302 | | |||
302 | } // namespace KWin | 303 | } // namespace KWin | ||
303 | 304 | | |||
304 | #endif | 305 | #endif | ||
305 | 306 | |