fix: implement Wayland screen-off in systemTurnOffScreen#89
Conversation
|
Skipping CI for Draft Pull Request. |
Reviewer's GuideImplements Wayland/Treeland screen-off behavior by delegating systemTurnOffScreen() on Wayland to a Power1 DBus method and updating the session-side PowerManager to coordinate suspend preparation, optional locking, and a brief delay before actually powering off the screen. Sequence diagram for Wayland systemTurnOffScreen delegation via Power1 DBussequenceDiagram
actor User
participant PowerController
participant Power1_DBUS as Power1
participant PowerManager
User ->> PowerController: systemTurnOffScreen()
PowerController ->> PowerController: isWaylandSession()
alt isWaylandSession
PowerController ->> Power1_DBUS: power.call(TurnOffScreen)
Power1_DBUS ->> PowerManager: TurnOffScreen()
PowerManager ->> PowerManager: TurnOffScreen()
alt m_screenBlackLock
PowerManager ->> PowerManager: doLock(true)
end
PowerManager ->> PowerManager: QTimer::singleShot(500)
PowerManager ->> PowerManager: setDPMSModeOff()
else not Wayland
PowerController ->> PowerController: systemTurnOffScreen (non Wayland path)
end
Flow diagram for PowerManager::TurnOffScreen behaviorflowchart TD
A["PowerManager::TurnOffScreen"] --> B["log Turning off screen"]
B --> C["set m_prepareSuspendState = PS_Sleeping"]
C --> D{m_screenBlackLock?}
D -- yes --> E["doLock(true)"]
D -- no --> F["QTimer::singleShot 500ms"]
E --> F["QTimer::singleShot 500ms"]
F --> G["setDPMSModeOff()"]
G --> H["set m_prepareSuspendState = PS_Normal"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
3dfe9be to
3a66d6b
Compare
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
PowerManager::TurnOffScreen, consider avoiding hard-coded state transitions (PS_Sleeping→PS_Normal) inside the timer and instead reuse any existing prepare/undo helpers so the suspend state logic stays centralized and consistent with other callers. - The 500ms delay before
setDPMSModeOff()is currently an inline magic number; pulling this into a named constant (and/or sharing it with the Wayland/Treeland implementation) would make the intent clearer and easier to tune across platforms.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `PowerManager::TurnOffScreen`, consider avoiding hard-coded state transitions (`PS_Sleeping` → `PS_Normal`) inside the timer and instead reuse any existing prepare/undo helpers so the suspend state logic stays centralized and consistent with other callers.
- The 500ms delay before `setDPMSModeOff()` is currently an inline magic number; pulling this into a named constant (and/or sharing it with the Wayland/Treeland implementation) would make the intent clearer and easier to tune across platforms.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
1. Change TurnOffScreen() to call doTurnOffScreen() which handles lock + delay + DPMS off internally 2. Replace Wayland TODO placeholder in powercontroller with sessionBus DBus call to Power1 TurnOffScreen Log: Fixed power button screen-off not working on Wayland/Treeland Influence: 1. Test power button screen-off in Treeland session 2. Verify lock screen appears before display turns off 3. Test wake from screen-off resumes to lock screen 4. Verify X11 screen-off path is not affected fix: 实现 Wayland 熄屏功能 1. 修改 TurnOffScreen() 调用 doTurnOffScreen(),内部 已封装锁屏+延迟+熄屏完整流程 2. 替换 powercontroller Wayland TODO 占位为 sessionBus DBus 调用 Power1 TurnOffScreen Log: 修复 Wayland/Treeland 下按电源键熄屏无响应的问题 Influence: 1. 在 Treeland 会话下测试按电源键熄屏功能 2. 验证熄屏前锁屏界面正常显示 3. 测试从熄屏唤醒后回到锁屏界面 4. 验证 X11 熄屏路径不受影响 PMS: BUG-209669
3a66d6b to
7d768d6
Compare
deepin pr auto review★ 总体评分:85分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 diff --git a/src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp b/src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp
index 8d1aa0c..e1a2b3c 100644
--- a/src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp
+++ b/src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp
@@ -412,10 +412,11 @@ void PowerController::systemTurnOffScreen()
if (isWaylandSession()) {
QDBusInterface power("org.deepin.dde.Power1", "/org/deepin/dde/Power1",
"org.deepin.dde.Power1", QDBusConnection::sessionBus());
if (power.isValid()) {
- power.call("TurnOffScreen");
+ // 使用异步调用避免阻塞快捷键处理线程
+ power.asyncCall("TurnOffScreen");
} else {
qWarning() << "PowerController: Power1 unavailable for TurnOffScreen";
}
return; |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm, 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 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Summary
Replace the TODO placeholder in
systemTurnOffScreen()Wayland branch with a working implementation for Treeland/Wayland.Changes
systemTurnOffScreen()Wayland branchdoPrepareSuspend()/undoPrepareSuspend()to prevent idle watcher raceshouldLockOnScreenBlackis truePower1.TurnOffScreen()via DBus forwlr-output-power-management-v1Flow
Related
PMS: BUG-209669
Issue: WM-50
Summary by Sourcery
Implement functional screen-off behavior for Wayland sessions and align session power handling with lock and suspend preparation state.
New Features:
Bug Fixes:
Enhancements: