Skip to content

Commit e4f122b

Browse files
calsys456zccrs
authored andcommitted
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 e4f122b

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/daemon/Display.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,8 @@ 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) {
228+
if (xdgSessionId <= 0) {
229+
qFatal() << "Invalid xdg session id" << xdgSessionId << "for user" << user;
238230
return;
239231
}
240232

@@ -243,7 +235,7 @@ namespace DDM {
243235

244236
if (Logind::isAvailable()) {
245237
OrgFreedesktopLogin1ManagerInterface manager(Logind::serviceName(), Logind::managerPath(), QDBusConnection::systemBus());
246-
manager.ActivateSession(QString::number(auth->xdgSessionId()));
238+
manager.ActivateSession(QString::number(xdgSessionId));
247239
}
248240
}
249241

@@ -637,16 +629,25 @@ namespace DDM {
637629
stateConfig.Last.Session.setDefault();
638630
stateConfig.save();
639631

640-
if (auth->isSingleMode()) {
632+
if (auth->identifyOnly()) {
633+
auto* server = reinterpret_cast<SingleWaylandDisplayServer*>(m_displayServer);
634+
server->onLoginSucceeded(user);
635+
// TODO: Use exact ID when there're multiple sessions for a user
636+
int xdgSessionId = 0;
637+
for (auto *auth : m_auths)
638+
if (auth->user() == user && auth->xdgSessionId() > 0) {
639+
xdgSessionId = auth->xdgSessionId();
640+
break;
641+
}
642+
switchToUser(user, xdgSessionId);
643+
} else if (auth->isSingleMode()) {
641644
auto* server = reinterpret_cast<SingleWaylandDisplayServer*>(m_displayServer);
642645
server->onLoginSucceeded(user);
643646
} else {
644647
if (m_socket) {
645648
emit loginSucceeded(m_socket, user);
646649
daemonApp->displayManager()->setLastSession(auth->sessionId());
647650
}
648-
if (auth->identifyOnly())
649-
return;
650651

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

0 commit comments

Comments
 (0)