Skip to content

fix: implement Wayland screen-off in systemTurnOffScreen#89

Draft
deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:fix/wayland-turn-off-screen
Draft

fix: implement Wayland screen-off in systemTurnOffScreen#89
deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:fix/wayland-turn-off-screen

Conversation

@deepin-wm

@deepin-wm deepin-wm commented Jun 18, 2026

Copy link
Copy Markdown

Summary

Replace the TODO placeholder in systemTurnOffScreen() Wayland branch with a working implementation for Treeland/Wayland.

Changes

  1. Replace TODO placeholder in systemTurnOffScreen() Wayland branch
  2. Add doPrepareSuspend()/undoPrepareSuspend() to prevent idle watcher race
  3. Lock screen before turning off if shouldLockOnScreenBlack is true
  4. Call Power1.TurnOffScreen() via DBus for wlr-output-power-management-v1
  5. Add 500ms delay after lock for lock UI rendering

Flow

doPrepareSuspend → shouldLockOnScreenBlack → doLock → msleep(500) → TurnOffScreen(DBus) → undoPrepareSuspend

Related

PMS: BUG-209669
Issue: WM-50

Summary by Sourcery

Implement Wayland/Treeland screen-off behavior in systemTurnOffScreen using the Power1 DBus interface and suspend preparation hooks.

Bug Fixes:

  • Resolve missing Wayland implementation for turning off the screen by invoking Power1.TurnOffScreen over DBus and handling DPMS state.

Enhancements:

  • Ensure screen locking and suspend preparation are coordinated before and after turning off the screen on Wayland, including an optional delay to allow the lock UI to render.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-wm

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implements the previously missing Wayland/Treeland code path for systemTurnOffScreen by wiring it through Deepin’s Power1 DBus API, wrapping it with suspend-preparation calls, optional lock-before-off behavior, and a small delay to allow the lock UI to render, plus persisting a simple DPMS state marker file.

Sequence diagram for updated Wayland systemTurnOffScreen flow

sequenceDiagram
    participant PowerController
    participant DConfig
    participant Power1_DBUS as Power1_DBus
    participant QFile_dpms as QFile_dpms_state

    PowerController->>PowerController: doPrepareSuspend()
    PowerController->>DConfig: createPowerConfig(this)
    PowerController->>DConfig: shouldLockOnScreenBlack(config)
    alt [screenBlackLock]
        PowerController->>PowerController: doLock(true)
        PowerController->>PowerController: QThread::msleep(500)
    end
    PowerController->>Power1_DBUS: QDBusInterface(...)
    alt [Power1_DBUS isValid]
        PowerController->>Power1_DBUS: call(TurnOffScreen)
    else [Power1_DBUS invalid]
        PowerController->>PowerController: qWarning(...Power1 unavailable...)
    end
    PowerController->>PowerController: undoPrepareSuspend()
    PowerController->>QFile_dpms: open(WriteOnly | Truncate)
    alt [open successful]
        PowerController->>QFile_dpms: write(1)
    end
Loading

File-Level Changes

Change Details Files
Implement Wayland/Treeland screen-off behavior in systemTurnOffScreen using Power1 DBus and suspend-preparation helpers.
  • Replace the Wayland TODO in systemTurnOffScreen with a real implementation path.
  • Call doPrepareSuspend before any screen-off work and undoPrepareSuspend afterwards to avoid idle-watcher races during screen off.
  • Read power configuration via createPowerConfig and compute shouldLockOnScreenBlack to decide whether to lock before turning off the screen.
  • If lock-on-black is enabled, invoke doLock(true) and sleep 500ms to give the lock screen time to render before outputs are powered down.
  • Create a QDBusInterface to org.deepin.dde.Power1 and call the TurnOffScreen method when the interface is valid, logging a warning if it is not.
  • Write a simple DPMS marker ("1") to /tmp/dpms-state after completing the Wayland screen-off flow.
src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

1. Replace TODO placeholder in systemTurnOffScreen()
   Wayland branch with working implementation
2. Add doPrepareSuspend/undoPrepareSuspend to prevent
   idle watcher race during screen-off transition
3. Lock screen before turning off if screenBlackLock
   config is true
4. Call Power1 TurnOffScreen via systemBus DBus for
   wlr-output-power-management-v1 output control
5. Add 500ms delay after lock for lock UI rendering

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. 替换 systemTurnOffScreen() Wayland 分支的
   TODO 占位符为完整实现
2. 添加 doPrepareSuspend/undoPrepareSuspend 防止
   熄屏过渡期间 idle watcher 冲突
3. 熄屏前根据 screenBlackLock 配置判断是否先锁屏
4. 通过 systemBus DBus 调用 Power1 TurnOffScreen
   使用 wlr-output-power-management-v1 关闭显示器
5. 锁屏后延迟 500ms 等待锁屏 UI 渲染完成

Log: 修复 Wayland/Treeland 下按电源键熄屏无响应的问题

Influence:
1. 在 Treeland 会话下测试按电源键熄屏功能
2. 验证熄屏前锁屏界面正常显示
3. 测试从熄屏唤醒后回到锁屏界面
4. 验证 X11 熄屏路径不受影响

PMS: BUG-209669
@deepin-wm deepin-wm force-pushed the fix/wayland-turn-off-screen branch from b5f8586 to d76c15e Compare June 18, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants