Skip to content

Commit 87cc597

Browse files
committed
fix: Fix Xwayland not started after crash recover & switch user
ddm should ack with switchToUser when treeland send an identify-only request. Lacking this acknowledgement will cause Xwayland not work after crash recover and user switch, which is a bug caused by previous commit.
1 parent 66c23ee commit 87cc597

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/daemon/Display.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -225,25 +225,14 @@ namespace DDM {
225225
m_greeter->setUserActivated(false);
226226
}
227227

228-
Auth *auth = nullptr;
229-
230-
for (auto *a : m_auths) {
231-
if (a->user() == user) {
232-
auth = a;
233-
break;
234-
}
235-
}
236-
237-
if (!auth) {
238-
return;
239-
}
228+
Q_ASSERT(xdgSessionId > 0);
240229

241230
auto* server = reinterpret_cast<SingleWaylandDisplayServer*>(m_displayServer);
242231
server->activateUser(user, xdgSessionId);
243232

244233
if (Logind::isAvailable()) {
245234
OrgFreedesktopLogin1ManagerInterface manager(Logind::serviceName(), Logind::managerPath(), QDBusConnection::systemBus());
246-
manager.ActivateSession(QString::number(auth->xdgSessionId()));
235+
manager.ActivateSession(QString::number(xdgSessionId));
247236
}
248237
}
249238

@@ -637,16 +626,25 @@ namespace DDM {
637626
stateConfig.Last.Session.setDefault();
638627
stateConfig.save();
639628

640-
if (auth->isSingleMode()) {
629+
if (auth->identifyOnly()) {
630+
auto* server = reinterpret_cast<SingleWaylandDisplayServer*>(m_displayServer);
631+
server->onLoginSucceeded(user);
632+
// TODO: Use exact ID when there're multiple sessions for a user
633+
int xdgSessionId = 0;
634+
for (auto *auth : m_auths)
635+
if (auth->user() == user && auth->xdgSessionId() > 0) {
636+
xdgSessionId = auth->xdgSessionId();
637+
break;
638+
}
639+
switchToUser(user, xdgSessionId);
640+
} else if (auth->isSingleMode()) {
641641
auto* server = reinterpret_cast<SingleWaylandDisplayServer*>(m_displayServer);
642642
server->onLoginSucceeded(user);
643643
} else {
644644
if (m_socket) {
645645
emit loginSucceeded(m_socket, user);
646646
daemonApp->displayManager()->setLastSession(auth->sessionId());
647647
}
648-
if (auth->identifyOnly())
649-
return;
650648

651649
// Stop the original suit of displayServer since it has finished its job.
652650
disconnect(m_displayServer, &DisplayServer::stopped, this, &Display::stop);

0 commit comments

Comments
 (0)