fix: route screen lock through logind on Wayland#214
Conversation
On Wayland the lock screen is provided by treeland (driven by the logind Lock signal), but RequestLock() unconditionally called the X11-only org.deepin.dde.LockFront1 (dde-lock). Under Wayland dde-lock.service is ExecCondition-disabled, so that D-Bus name has no provider and the call hangs on the 120s activation timeout, logging "failed to lock". A Wayland guard used to exist on this path and was dropped during an earlier refactor. Gate the lock path on Utils::IS_WAYLAND_DISPLAY: - RequestLock() asks logind to Lock() so treeland shows the lock screen. - handleLoginSessionLocked() only syncs local lock state (treeland reacts to the same logind signal; re-entering RequestLock would loop). - handleLoginSessionUnlocked() only syncs state, skipping the X11 LockFront1-kill dance that early-returns and leaves m_locked stale. 在 Wayland 下锁屏由 treeland 提供(响应 logind 的 Lock 信号),但 RequestLock() 无条件调用了仅 X11 有效的 org.deepin.dde.LockFront1(dde-lock)。Wayland 下 dde-lock.service 被 ExecCondition 禁用,该 D-Bus 名无人提供,调用会卡在 120s 的 激活超时并打印 "failed to lock"。此路径原有的 Wayland 判断在之前的重构中被丢失。 按 Utils::IS_WAYLAND_DISPLAY 分流: - RequestLock() 改为请求 logind Lock(),由 treeland 显示锁屏; - handleLoginSessionLocked() 仅同步本地锁状态(treeland 已响应同一 logind 信号, 再次进入 RequestLock 会形成回环); - handleLoginSessionUnlocked() 仅同步状态,跳过会提前 return 并使 m_locked 不一致 的 X11 LockFront1 kill 流程。 Log: route screen lock through logind on Wayland Change-Id: Iab1b9648ec8f53eca3023891ac33cc76d7f8f59b
There was a problem hiding this comment.
Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
deepin pr auto review这段代码主要是对SessionManager类中锁屏相关功能的改进,主要针对Wayland显示协议的支持。我来分析一下代码的改进点和潜在问题: 改进点分析:
潜在问题和建议:
具体改进建议示例:void SessionManager::syncLockState(bool locked)
{
if (m_locked == locked)
return;
m_locked = locked;
emitLockChanged(locked);
if (!locked)
Q_EMIT Unlock();
}
void SessionManager::RequestLock()
{
if (Utils::IS_WAYLAND_DISPLAY) {
qDebug() << "[SessionManager] RequestLock on wayland: ask logind to lock";
m_login1SessionInter->Lock();
m_inCallRequestLock = false;
return;
}
// X11处理逻辑
...
}
void SessionManager::handleLoginSessionLocked()
{
if (Utils::IS_WAYLAND_DISPLAY) {
qDebug() << "[SessionManager] handleLoginSessionLocked on wayland: sync local state";
syncLockState(true);
return;
}
// X11处理逻辑
...
}
void SessionManager::handleLoginSessionUnlocked()
{
qDebug() << "[SessionManager] login session unlocked";
if (Utils::IS_WAYLAND_DISPLAY) {
qDebug() << "[SessionManager] handleLoginSessionUnlocked on wayland: sync local state";
syncLockState(false);
return;
}
// X11处理逻辑
...
}这些改进建议旨在提高代码的可维护性、可读性和健壮性,同时保持原有功能的完整性。 |
Summary
Locksignal), butSessionManager::RequestLock()unconditionally called the X11-onlyorg.deepin.dde.LockFront1(dde-lock).dde-lock.serviceisExecCondition-disabled, soorg.deepin.dde.LockFront1has no provider — the call hangs on the 120 s D-Bus activation timeout and logsfailed to lock. A Wayland guard previously existed on this path and was dropped in an earlier refactor.Utils::IS_WAYLAND_DISPLAY:RequestLock()→m_login1SessionInter->Lock()so treeland shows the lock screen.handleLoginSessionLocked()only syncs local lock state (treeland reacts to the same logind signal; re-enteringRequestLockwould loop).handleLoginSessionUnlocked()only syncs state, skipping the X11LockFront1-kill path that early-returns and leavesm_lockedstale.Evidence (before fix)
Test plan
LockFront1120 s activation timeout /failed to lock.dde-lock(LockFront1) as before.