Debian Codegraph @

src/xwayland/xwaylandlauncher.h

raw symbols SCIP
1 /*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2019 Roman Gilg <[email protected]>
6 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <[email protected]>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11 #pragma once
12
13 #include "utils/filedescriptor.h"
14
15 #include <QList>
16 #include <QMap>
17 #include <QObject>
18 #include <QProcess>
19 #include <QSocketNotifier>
20 #include <QTemporaryFile>
21 #include <memory>
22
23 #include <kwin_export.h>
24
25 class QTimer;
26
27 namespace KWin
28 {
29
30 class XwaylandSocket;
31
32 namespace Xwl
33 {
34
35 class KWIN_EXPORT XwaylandLauncher : public QObject
36 {
37 Q_OBJECT
38
39 public:
40 explicit XwaylandLauncher();
41 ~XwaylandLauncher();
42
43 /**
44 * Set file descriptors that xwayland should use for listening
45 * This is to be used in conjunction with kwin_wayland_wrapper which creates a socket externally
46 * That external process is responsible for setting up the DISPLAY env with a valid value.
47 * Ownership of the file descriptor is not transferrred.
48 */
49 void setListenFDs(const QList<int> &listenFds);
50
51 /**
52 * Sets the display name used by XWayland (i.e ':0')
53 * This is to be used in conjunction with kwin_wayland_wrapper to provide the name of the socket
54 * created externally
55 */
56 void setDisplayName(const QString &displayName);
57
58 /**
59 * Sets the xauthority file to be used by XWayland
60 * This is to be used in conjunction with kwin_wayland_wrapper
61 */
62 void setXauthority(const QString &xauthority);
63
64 void addEnvironmentVariables(const QMap<QString, QString> &extraEnvironment);
65
66 void passFileDescriptors(std::vector<FileDescriptor> &&fds);
67
68 void enable();
69 void disable();
70 bool start();
71 void stop();
72
73 QString displayName() const;
74 QString xauthority() const;
75 FileDescriptor takeXcbConnectionFd();
76
77 /**
78 * @internal
79 */
80 QProcess *process() const;
81 Q_SIGNALS:
82 /**
83 * This signal is emitted when the Xwayland server is ready to accept connections.
84 */
85 void ready();
86 /**
87 * This signal is emitted when the Xwayland server is started.
88 */
89 void started();
90 /**
91 * This signal is emitted when the Xwayland server quits or crashes
92 */
93 void finished();
94 /**
95 * This signal is emitted when an error occurs with the Xwayland server.
96 */
97 void errorOccurred();
98
99 private Q_SLOTS:
100 void resetCrashCount();
101 void handleXwaylandFinished(int exitCode, QProcess::ExitStatus exitStatus);
102 void handleXwaylandError(QProcess::ProcessError error);
103
104 private:
105 std::unique_ptr<QProcess> m_xwaylandProcess;
106 std::unique_ptr<QSocketNotifier> m_readyNotifier;
107 std::unique_ptr<QTimer> m_resetCrashCountTimer;
108 // this is only used when kwin is run without kwin_wayland_wrapper
109 std::unique_ptr<XwaylandSocket> m_socket;
110 QList<int> m_listenFds;
111 std::vector<std::unique_ptr<QSocketNotifier>> m_socketNotifiers;
112 QString m_displayName;
113 QString m_xAuthority;
114 QMap<QString, QString> m_extraEnvironment;
115 std::vector<FileDescriptor> m_fdsToPreserve;
116
117 bool m_enabled = false;
118 int m_crashCount = 0;
119 FileDescriptor m_readyFd;
120 FileDescriptor m_xcbConnectionFd;
121 };
122
123 }
124 }