Conversation
When switching from tty1 to another tty, the ActiveChanged(false) signal only stopped authentication without pre-activating the lock screen window. The lock screen was activated only on ActiveChanged(true) (switching back), after the compositor had already rendered the desktop frame, causing a brief desktop flash before the lock screen appeared. Remove the `active` condition from the showLockScreen() call in the ActiveChanged handler so the lock screen is pre-activated when switching away from the session. This ensures the lock screen window is already mapped to the compositor before the VT switch, so on switch-back the compositor renders the lock screen first instead of the desktop. This follows the same pre-activation pattern already used by the PrepareForSleep handler. PMS: BUG-345559
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy 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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates the ActiveChanged handling so the lock screen is mapped before switching away from the graphical VT, ensuring the lock screen is rendered immediately on return instead of briefly exposing the desktop; existing visibility protection and other lock flows remain unchanged. Sequence diagram for pre-activating the lock screen during VT switchingsequenceDiagram
participant Compositor
participant LockWorker
participant LockModel
Compositor->>LockWorker: ActiveChanged(false)
LockWorker->>LockModel: visible()
alt lock screen not visible
LockWorker->>LockModel: showLockScreen()
LockModel-->>Compositor: Lock screen window mapped
else lock screen already visible
LockWorker-->>Compositor: No duplicate activation
end
Compositor->>LockWorker: ActiveChanged(true)
Compositor-->>LockModel: Render lock screen immediately
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰。变更移除了 if 条件中的 active 参数,使 showLockScreen() 在 VT 切换离开时(active=false)也能被调用,实现锁屏预激活。m_model->visible() 守卫仍然防止重复激活,逻辑完备。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 建议在 if (!m_model->visible()) 行前添加简短注释,说明移除 active 条件的原因(VT 切换时预激活锁屏以防止桌面闪现),便于后续维护者理解意图。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。变更仅移除一个布尔条件判断,无性能影响。m_model->visible() 守卫防止了 showLockScreen() 的冗余调用。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞。本次变更不涉及用户输入处理、网络操作或文件操作,无安全风险。变更实际上提升了安全性——通过在 VT 切换时预激活锁屏,防止了桌面内容闪现可能导致的敏感信息短暂暴露。 💡 改进建议代码示例// 在 ActiveChanged 信号处理器中,移除 active 条件
// 使锁屏在 VT 切换离开时也被预激活,防止切回时桌面闪现
#ifdef ENABLE_DSS_SNIPE
// VT 切换时预激活锁屏,防止切回时桌面闪现(与 PrepareForSleep 预激活模式一致)
if (!m_model->visible()) {
m_model->showLockScreen();
}
#endif本报告由 AI 代码审查工具自动生成 |
|
修改是无效的,渲染阻塞: 当图形服务器失去显卡的主控权(Drop Master)后,如果应用程序试图向显卡发送新的绘图指令,内核会阻塞这个请求。这时,图形界面程序会停在某个系统调用上,直到你切回 GUI。由于桌面是一直在显示(渲染中),锁屏是后起应用,切回GUI后,先显示桌面,再显示锁屏,是正常现象。 |
Root Cause Analysis
When switching from tty1 to another tty, the
ActiveChanged(false)signal inlockworker.cpponly stopped authentication without pre-activating the lock screen window. The lock screen was activated only onActiveChanged(true)(switching back), after the compositor had already rendered the desktop frame, causing a brief desktop flash before the lock screen appeared. The root cause is insrc/dde-lock/lockworker.cpp:168— theshowLockScreen()call was guarded byactive &&, so it only fired when switching back, not when switching away.Key evidence:
lockworker.cpp:168:if (active && !m_model->visible())only triggers onactive=true(switch back)PrepareForSleephandler already uses pre-activation (setVisible(true)before sleep), establishing the correct patternFix
Remove the
activecondition from theshowLockScreen()call in theActiveChangedhandler so the lock screen is pre-activated when switching away from the session (active=false). This ensures the lock screen window is already mapped to the compositor before the VT switch, so on switch-back the compositor renders the lock screen first instead of the desktop. This follows the same pre-activation pattern already used by thePrepareForSleephandler.Change Safety Assessment
Code Safety
2fcc70ba(BUG-341543) to unify lock screen activation logic; this change does not revert that fix — still only oneshowLockScreen()call, just with a broader trigger conditionm_model->visible()guard prevents duplicate activation; when the lock screen is already visible, the call is skipped — no regressionBusiness Impact Scope
Affects the VT (virtual terminal) switching scenario: when a logged-in user switches from the desktop (tty1) to another tty and back, the lock screen should appear immediately without flashing the desktop. No other lock/unlock flows (normal lock, sleep/wake, manual lock) are affected.
Verification Suggestion
Test the VT switch scenario: log in on tty1, switch to tty2 via keyboard shortcut, switch back to tty1 — verify the lock screen appears immediately without a desktop flash. Also verify normal lock/unlock and sleep/wake still work correctly.
根因分析
从 tty1 切换到其他 tty 时,
lockworker.cpp中ActiveChanged(false)信号仅停止认证,未预激活锁屏窗口。锁屏仅在ActiveChanged(true)(切回)时才激活,此时合成器已渲染了桌面帧,导致切回时先闪现桌面再显示锁屏。根因位于src/dde-lock/lockworker.cpp:168——showLockScreen()调用被active &&守卫,仅在切回时触发,切走时不触发。关键证据:
lockworker.cpp:168:if (active && !m_model->visible())仅在active=true(切回)时触发PrepareForSleep处理器已使用预激活模式(休眠前setVisible(true)),是正确的参考模式修复方案
移除
ActiveChanged处理器中showLockScreen()调用的active条件,使锁屏在切走会话时(active=false)也被预激活。这样锁屏窗口在 VT 切换前已映射到合成器,切回时合成器优先渲染锁屏而非桌面。与PrepareForSleep处理器使用的预激活模式一致。改动安全评估
代码安全评估
2fcc70ba(BUG-341543)引入以统一锁屏激活逻辑;本次修改不回退该修复——仍只有一处showLockScreen()调用,仅扩大触发条件m_model->visible()守卫防止重复激活;锁屏已可见时跳过调用——无回归业务影响范围
影响 VT(虚拟终端)切换场景:已登录用户从桌面(tty1)切换到其他 tty 再切回时,锁屏应立即出现,不闪现桌面。其他锁屏/解锁流程(正常锁屏、休眠唤醒、手动锁屏)不受影响。
验证建议
测试 VT 切换场景:在 tty1 登录后,用快捷键切换到 tty2,再切回 tty1——验证锁屏立即出现,不闪现桌面。同时验证正常锁屏/解锁和休眠唤醒功能正常。
Summary by Sourcery
Bug Fixes: