1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
From 68cc9e31d1a4c4609f42114782fc485cb07353a4 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Fri, 9 Oct 2020 21:06:01 +0200
Subject: [PATCH] Merge normal and testing paths in XorgDisplayServer::start
They have much in common and this means that Xephyr can also make use use
of -displayfd now.
---
src/daemon/XorgDisplayServer.cpp | 132 ++++++++++++++-----------------
1 file changed, 60 insertions(+), 72 deletions(-)
diff --git a/src/daemon/XorgDisplayServer.cpp b/src/daemon/XorgDisplayServer.cpp
index d5f29a94a..e60c02210 100644
--- a/src/daemon/XorgDisplayServer.cpp
+++ b/src/daemon/XorgDisplayServer.cpp
@@ -136,95 +136,83 @@ namespace SDDM {
return false;
}
- if (daemonApp->testing()) {
- QStringList args;
- QDir x11socketDir(QStringLiteral("/tmp/.X11-unix"));
- int display = 100;
- while (x11socketDir.exists(QStringLiteral("X%1").arg(display))) {
- ++display;
- }
- m_display = QStringLiteral(":%1").arg(display);
- args << m_display << QStringLiteral("-auth") << m_authPath << QStringLiteral("-br") << QStringLiteral("-noreset") << QStringLiteral("-screen") << QStringLiteral("800x600");
- process->start(mainConfig.X11.XephyrPath.get(), args);
-
-
- // wait for display server to start
- if (!process->waitForStarted()) {
- // log message
- qCritical() << "Failed to start display server process.";
+ // set process environment
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ env.insert(QStringLiteral("XCURSOR_THEME"), mainConfig.Theme.CursorTheme.get());
+ process->setProcessEnvironment(env);
- // return fail
- return false;
- }
- emit started();
- } else {
- // set process environment
- QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
- env.insert(QStringLiteral("XCURSOR_THEME"), mainConfig.Theme.CursorTheme.get());
- process->setProcessEnvironment(env);
-
- //create pipe for communicating with X server
- //0 == read from X, 1== write to from X
- int pipeFds[2];
- if (pipe(pipeFds) != 0) {
- qCritical("Could not create pipe to start X server");
- }
+ //create pipe for communicating with X server
+ //0 == read from X, 1== write to from X
+ int pipeFds[2];
+ if (pipe(pipeFds) != 0) {
+ qCritical("Could not create pipe to start X server");
+ }
- // start display server
- QStringList args = mainConfig.X11.ServerArguments.get().split(QLatin1Char(' '), QString::SkipEmptyParts);
- args << QStringLiteral("-auth") << m_authPath
+ // start display server
+ QStringList args;
+ if (!daemonApp->testing()) {
+ process->setProgram(mainConfig.X11.ServerPath.get());
+ args << mainConfig.X11.ServerArguments.get().split(QLatin1Char(' '), QString::SkipEmptyParts)
<< QStringLiteral("-background") << QStringLiteral("none")
- << QStringLiteral("-noreset")
- << QStringLiteral("-displayfd") << QString::number(pipeFds[1])
<< QStringLiteral("-seat") << displayPtr()->seat()->name();
if (displayPtr()->seat()->name() == QLatin1String("seat0")) {
args << QStringLiteral("vt%1").arg(displayPtr()->terminalId());
}
- qDebug() << "Running:"
- << qPrintable(mainConfig.X11.ServerPath.get())
- << qPrintable(args.join(QLatin1Char(' ')));
- process->start(mainConfig.X11.ServerPath.get(), args);
-
- // wait for display server to start
- if (!process->waitForStarted()) {
- // log message
- qCritical() << "Failed to start display server process.";
-
- // return fail
- close(pipeFds[0]);
- return false;
- }
+ } else {
+ process->setProgram(mainConfig.X11.XephyrPath.get());
+ args << QStringLiteral("-br")
+ << QStringLiteral("-screen") << QStringLiteral("800x600");
+ }
- // close the other side of pipe in our process, otherwise reading
- // from it may stuck even X server exit.
- close(pipeFds[1]);
+ args << QStringLiteral("-auth") << m_authPath
+ << QStringLiteral("-noreset")
+ << QStringLiteral("-displayfd") << QString::number(pipeFds[1]);
- QFile readPipe;
+ process->setArguments(args);
+ qDebug() << "Running:"
+ << qPrintable(process->program())
+ << qPrintable(process->arguments().join(QLatin1Char(' ')));
+ process->start();
- if (!readPipe.open(pipeFds[0], QIODevice::ReadOnly)) {
- qCritical("Failed to open pipe to start X Server");
+ // wait for display server to start
+ if (!process->waitForStarted()) {
+ // log message
+ qCritical() << "Failed to start display server process.";
- close(pipeFds[0]);
- return false;
- }
- QByteArray displayNumber = readPipe.readLine();
- if (displayNumber.size() < 2) {
- // X server gave nothing (or a whitespace).
- qCritical("Failed to read display number from pipe");
+ // return fail
+ close(pipeFds[0]);
+ return false;
+ }
- close(pipeFds[0]);
- return false;
- }
- displayNumber.prepend(QByteArray(":"));
- displayNumber.remove(displayNumber.size() -1, 1); // trim trailing whitespace
- m_display = QString::fromLocal8Bit(displayNumber);
+ // close the other side of pipe in our process, otherwise reading
+ // from it may stuck even X server exit.
+ close(pipeFds[1]);
+
+ QFile readPipe;
+
+ if (!readPipe.open(pipeFds[0], QIODevice::ReadOnly)) {
+ qCritical("Failed to open pipe to start X Server");
- // close our pipe
close(pipeFds[0]);
+ return false;
+ }
+ QByteArray displayNumber = readPipe.readLine();
+ if (displayNumber.size() < 2) {
+ // X server gave nothing (or a whitespace).
+ qCritical("Failed to read display number from pipe");
- emit started();
+ close(pipeFds[0]);
+ return false;
}
+ displayNumber.prepend(QByteArray(":"));
+ displayNumber.remove(displayNumber.size() -1, 1); // trim trailing whitespace
+ m_display = QString::fromLocal8Bit(displayNumber);
+
+ // close our pipe
+ close(pipeFds[0]);
+
+ emit started();
// The file is also used by the greeter, which does care about the
// display number. Write the proper entry, if it's different.
|