KWin
Loading...
Searching...
No Matches
wayland_server.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
11#include "effect/globals.h"
12
13#include <QObject>
14#include <QPointer>
15#include <QSet>
16
17namespace KWin
18{
19
20class AppMenuManagerInterface;
21class ClientConnection;
22class CompositorInterface;
23class Display;
24class DataDeviceInterface;
25class IdleInterface;
26class InputMethodV1Interface;
27class SeatInterface;
28class DataDeviceManagerInterface;
29class ServerSideDecorationManagerInterface;
30class ServerSideDecorationPaletteManagerInterface;
31class SurfaceInterface;
32class OutputInterface;
33class PlasmaShellInterface;
34class PlasmaWindowActivationFeedbackInterface;
35class PlasmaVirtualDesktopManagementInterface;
36class PlasmaWindowManagementInterface;
37class OutputDeviceV2Interface;
38class OutputManagementV2Interface;
39class XdgExportedSurface;
40class XdgForeignV2Interface;
41class XdgOutputManagerV1Interface;
42class DrmClientBufferIntegration;
43class LinuxDmaBufV1ClientBufferIntegration;
44class TabletManagerV2Interface;
45class KeyboardShortcutsInhibitManagerV1Interface;
46class XdgDecorationManagerV1Interface;
47class XWaylandKeyboardGrabManagerV1Interface;
48class ContentTypeManagerV1Interface;
49class DrmLeaseManagerV1;
50class TearingControlManagerV1Interface;
51class XwaylandShellV1Interface;
52class OutputOrderV1Interface;
53class Window;
54class Output;
55class XdgActivationV1Integration;
56class XdgPopupWindow;
57class XdgSurfaceWindow;
58class XdgToplevelWindow;
59class PresentationTime;
60class XXColorManagerV2;
61
62class KWIN_EXPORT WaylandServer : public QObject
63{
64 Q_OBJECT
65
66public:
67 enum class InitializationFlag {
68 NoOptions = 0x0,
69 LockScreen = 0x1,
70 NoLockScreenIntegration = 0x2,
71 NoGlobalShortcuts = 0x4
72 };
73
74 Q_DECLARE_FLAGS(InitializationFlags, InitializationFlag)
75
76 ~WaylandServer() override;
77 bool init(const QString &socketName, InitializationFlags flags = InitializationFlag::NoOptions);
78 bool init(InitializationFlags flags = InitializationFlag::NoOptions);
79
80 bool start();
81
83 {
84 return m_display;
85 }
87 {
88 return m_compositor;
89 }
91 {
92 return m_seat;
93 }
95 {
96 return m_tabletManagerV2;
97 }
99 {
100 return m_dataDeviceManager;
101 }
103 {
104 return m_plasmaActivationFeedback;
105 }
107 {
108 return m_virtualDesktopManagement;
109 }
111 {
112 return m_windowManagement;
113 }
115 {
116 return m_decorationManager;
117 }
119 {
120 return m_xdgOutputManagerV1;
121 }
123 {
124 return m_keyboardShortcutsInhibitManager;
125 }
127 {
128 return m_xwaylandShell;
129 }
130
131 bool isKeyboardShortcutsInhibited() const;
132
135
137 {
138 return m_inputMethod;
139 }
141 {
142 return m_idle;
143 }
144 QList<Window *> windows() const
145 {
146 return m_windows;
147 }
148 void removeWindow(Window *c);
149 Window *findWindow(const SurfaceInterface *surface) const;
150 XdgToplevelWindow *findXdgToplevelWindow(SurfaceInterface *surface) const;
151 XdgSurfaceWindow *findXdgSurfaceWindow(SurfaceInterface *surface) const;
152
156 SurfaceInterface *findForeignTransientForSurface(SurfaceInterface *surface);
157
161 XdgExportedSurface *exportAsForeign(SurfaceInterface *surface);
162
166 int createXWaylandConnection();
167 void destroyXWaylandConnection();
168
172 int createInputMethodConnection();
173 void destroyInputMethodConnection();
174
178 bool isScreenLocked() const;
182 bool hasScreenLockerIntegration() const;
183
187 bool hasGlobalShortcutSupport() const;
188
189 void initWorkspace();
190
191 ClientConnection *xWaylandConnection() const;
192 ClientConnection *inputMethodConnection() const;
194 {
195 return m_screenLockerClientConnection;
196 }
197
203 {
207 ClientConnection *connection = nullptr;
211 int fd = -1;
212 };
216 SocketPairConnection createConnection();
217
222 QString socketName() const;
223
225 {
226 return m_xdgActivationIntegration;
227 }
228
229Q_SIGNALS:
235
236private:
237 int createScreenLockerConnection();
238 void initScreenLocker();
239 void registerXdgGenericWindow(Window *window);
240 void registerXdgToplevelWindow(XdgToplevelWindow *window);
241 void registerXdgPopupWindow(XdgPopupWindow *window);
242 void registerWindow(Window *window);
243 void handleOutputAdded(Output *output);
244 void handleOutputRemoved(Output *output);
245 void handleOutputEnabled(Output *output);
246 void handleOutputDisabled(Output *output);
247
248 class LockScreenPresentationWatcher : public QObject
249 {
250 public:
251 LockScreenPresentationWatcher(WaylandServer *server);
252
253 private:
254 QSet<Output *> m_signaledOutputs;
255 };
256
257 Display *m_display = nullptr;
258 CompositorInterface *m_compositor = nullptr;
259 SeatInterface *m_seat = nullptr;
260 TabletManagerV2Interface *m_tabletManagerV2 = nullptr;
261 DataDeviceManagerInterface *m_dataDeviceManager = nullptr;
262 PlasmaShellInterface *m_plasmaShell = nullptr;
263 PlasmaWindowActivationFeedbackInterface *m_plasmaActivationFeedback = nullptr;
264 PlasmaWindowManagementInterface *m_windowManagement = nullptr;
265 PlasmaVirtualDesktopManagementInterface *m_virtualDesktopManagement = nullptr;
266 ServerSideDecorationManagerInterface *m_decorationManager = nullptr;
267 OutputManagementV2Interface *m_outputManagement = nullptr;
268 AppMenuManagerInterface *m_appMenuManager = nullptr;
269 ServerSideDecorationPaletteManagerInterface *m_paletteManager = nullptr;
270 IdleInterface *m_idle = nullptr;
271 XdgOutputManagerV1Interface *m_xdgOutputManagerV1 = nullptr;
272 XdgDecorationManagerV1Interface *m_xdgDecorationManagerV1 = nullptr;
273 DrmClientBufferIntegration *m_drm = nullptr;
274 LinuxDmaBufV1ClientBufferIntegration *m_linuxDmabuf = nullptr;
275 KeyboardShortcutsInhibitManagerV1Interface *m_keyboardShortcutsInhibitManager = nullptr;
276 QPointer<ClientConnection> m_xwaylandConnection;
277 InputMethodV1Interface *m_inputMethod = nullptr;
278 QPointer<ClientConnection> m_inputMethodServerConnection;
279 ClientConnection *m_screenLockerClientConnection = nullptr;
280 XdgForeignV2Interface *m_XdgForeign = nullptr;
281 XdgActivationV1Integration *m_xdgActivationIntegration = nullptr;
282 XWaylandKeyboardGrabManagerV1Interface *m_xWaylandKeyboardGrabManager = nullptr;
283 ContentTypeManagerV1Interface *m_contentTypeManager = nullptr;
284 TearingControlManagerV1Interface *m_tearingControlInterface = nullptr;
285 XwaylandShellV1Interface *m_xwaylandShell = nullptr;
286 PresentationTime *m_presentationTime = nullptr;
287 QList<Window *> m_windows;
288 InitializationFlags m_initFlags;
289 QHash<Output *, OutputInterface *> m_waylandOutputs;
290 QHash<Output *, OutputDeviceV2Interface *> m_waylandOutputDevices;
291 DrmLeaseManagerV1 *m_leaseManager = nullptr;
292 OutputOrderV1Interface *m_outputOrder = nullptr;
293 XXColorManagerV2 *m_xxColorManager = nullptr;
295};
296
298{
299 return WaylandServer::self();
300}
301
302} // namespace KWin
Convenient Class which represents a wl_client.
Represents the Global for wl_data_device_manager interface.
Class holding the Wayland server display loop.
Definition display.h:34
Global representing the org_kde_kwin_idle interface.
Definition idle.h:38
Global for the org_kde_plasma_shell interface.
Definition plasmashell.h:37
Wrapper for the org_kde_plasma_virtual_desktop_management interface.
Represents a Seat on the Wayland Display.
Definition seat.h:134
Manager to create ServerSideDecorationInterface.
Resource representing a wl_surface.
Definition surface.h:80
void windowRemoved(KWin::Window *)
ServerSideDecorationManagerInterface * decorationManager() const
PlasmaWindowManagementInterface * windowManagement() const
PlasmaVirtualDesktopManagementInterface * virtualDesktopManagement() const
XdgOutputManagerV1Interface * xdgOutputManagerV1() const
SeatInterface * seat() const
TabletManagerV2Interface * tabletManagerV2() const
DataDeviceManagerInterface * dataDeviceManager() const
IdleInterface * idle() const
PlasmaWindowActivationFeedbackInterface * plasmaActivationFeedback() const
XwaylandShellV1Interface * xwaylandShell() const
Display * display() const
CompositorInterface * compositor() const
KeyboardShortcutsInhibitManagerV1Interface * keyboardShortcutsInhibitManager() const
QList< Window * > windows() const
XdgActivationV1Integration * xdgActivationIntegration() const
InputMethodV1Interface * inputMethod() const
void foreignTransientChanged(KWin::SurfaceInterface *child)
ClientConnection * screenLockerClientConnection() const
void windowAdded(KWin::Window *)
#define KWIN_SINGLETON(ClassName)
Definition globals.h:323
WaylandServer * waylandServer()
struct _XDisplay Display