Repository navigation
fix: restore hardware sleep shortcuts - #188
deepin-bot[bot] merged 1 commit into
Conversation
Reviewer's GuideRestores independent hardware Sleep and Suspend shortcuts, routes both through the suspend power action with availability-aware locking, and hardens key validation and backend registration behavior for X11 and Treeland-compatible Wayland environments. Sequence diagram for hardware suspend shortcut executionsequenceDiagram
participant Shortcut as ShortcutHandler
participant Tool as dde_shortcut_tool
participant Power as PowerController
participant Session as SessionLock
participant System as SystemSuspend
Shortcut->>Tool: execute suspend
Tool->>Power: execute suspend
Power->>Power: canSuspend()
alt suspend unavailable
Power-->>Tool: return true
else suspend available
Power->>Power: shouldLockOnSleep(config)
opt lock on sleep
Power->>Session: doLock(true)
end
Power->>System: systemSuspend()
Power-->>Tool: return true
end
Flow diagram for Sleep and Suspend shortcut registrationflowchart TD
Config[Sleep and Suspend shortcut configs] --> Validate[QKeySequenceConverter validates Qt Key_Sleep]
Validate --> Backend{Backend}
Backend -->|X11| X11[X11 registers available bindings independently]
Backend -->|Wayland| Guard{Contains bare Sleep?}
Guard -->|Yes| Reject[WaylandKeyHandler rejects Sleep]
Guard -->|No| Register[Suspend binding registers]
X11 --> Action[dde-shortcut-tool power suspend]
Register --> Action
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰。所有C++代码语法无误,快捷键注册→键值验证→Wayland兼容性守卫→动作执行的逻辑链条完整。handleSystemSuspend()中先检查canSuspend()再锁屏的逻辑正确,避免了在不支持挂起的机器上不必要的锁屏UI延迟。测试代码使用Qt测试框架规范,智能指针和qScopeGuard确保资源正确释放。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 代码结构清晰,注释完整。注释充分解释了Treeland兼容性问题、Qt键值位置异常等设计决策。测试覆盖全面,包括单元测试和X11集成测试。建议修正Suspend快捷键配置文件中displayName的中文翻译,将"睡眠"改为"挂起"以与Sleep区分。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。handleSystemSuspend()中canSuspend()前置检查是良好的性能优化,避免了在不支持挂起的机器上触发500ms锁屏UI延迟。无频繁系统调用,无不必要的计算。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞,安全合规。triggerValue中的命令执行来自配置文件而非用户输入,无注入风险。无硬编码密钥或敏感信息泄露。 💡 改进建议代码示例// 修正 suspend 快捷键配置中的中文翻译
// 文件: org.deepin.dde.keybinding.shortcut.suspend/org.deepin.shortcut.json
// 修改前:
// "name[zh_CN]": "睡眠"
// 修改后:
// "name[zh_CN]": "挂起"
// 同步修正 description 字段以保持一致性
// 修改前:
// "description": "睡眠快捷键"
// 修改后:
// "description": "挂起快捷键"本报告由 AI 代码审查工具自动生成 |
|
TAG Bot New tag: 1.0.45 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, 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 |
Register Sleep and Suspend as independent fixed hardware shortcuts that invoke dde-shortcut-tool power suspend, so an unavailable X11 keysym does not disable the other binding. Accept Qt::Key_Sleep in shared validation and check suspend availability before locking the session. Reject bare Sleep before queuing Wayland bindings while the current Treeland validator does not support it, preserving the startup shortcut and gesture batch. Add converter checks and Xvfb regression coverage for keymaps containing either sleep variant, both, or neither. 将 Sleep 和 Suspend 注册为独立的固定硬件快捷键,统一调用 dde-shortcut-tool power suspend,避免 X11 缺少一种按键符号时 连带禁用另一种绑定。公共校验接受 Qt::Key_Sleep,并在锁屏前 检查待机能力。 当前 Treeland 校验尚不支持无修饰的 Sleep,因此在 Wayland 请求 入队前拒绝该绑定,保护启动时的快捷键和手势批次。补充按键转换 测试及 Xvfb 回归测试,覆盖仅有一种睡眠键、两者都有和都没有的映射。 Log: restore hardware sleep shortcuts Pms: BUG-378959 Change-Id: I662ac9d99245210ddf0b5b5ee9b7de7ccb0b9a60
47b185e to
c1550eb
Compare
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Summary
Restore hardware sleep shortcuts with independent
SleepandSuspendbindings invokingdde-shortcut-tool power suspend. On X11, a missing keysym no longer rolls back the other available binding.Qt::Key_Sleepin shared shortcut validation.Sleepinactive on Wayland until Treeland accepts it, preventing rejection of the startup shortcut and gesture batch.Suspendremains a separate binding.Validation
git diff --checkpassed.Pms: BUG-378959
Summary by Sourcery
Restore reliable hardware Sleep and Suspend shortcuts across supported backends while preserving unrelated shortcut registrations.
New Features:
Bug Fixes:
Tests: