Skip to content

feat(dde-blackwidget): 迁移 V20 增强版黑屏组件并支持 nodbus 模式显示 logo - #451

Merged
mhduiy merged 1 commit into
linuxdeepin:masterfrom
mhduiy:feat-blackwidget-nodbus-dconfig
Sep 8, 2026
Merged

mhduiy merged 1 commit into
linuxdeepin:masterfrom
mhduiy:feat-blackwidget-nodbus-dconfig

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

变更内容

  1. 迁移 V20 增强版 dde-blackwidget:共享单实例锁、nodbus 模式、Plymouth logo、多屏遮罩及 X11 兼容
  2. 移除 startdde GSettings 依赖,黑屏配置改用 DConfig,blackWidgetLogoVisible 默认开启
  3. 新增 Type=execdde-blackwidget-nodbus.service,不绑定 graphical-session.target 的停止生命周期
  4. 使用调色板替代 QSS 设置背景与文字颜色
  5. 仅在存在 DISPLAY 时选择 XCB,并移除无效的 gravity-rotate 路径
  6. REUSE.toml 中以 CC0-1.0 标注 DConfig JSON 元数据

PMS: TASK-395319
Influence: 关机/重启时显示 Plymouth logo 黑屏,取代纯黑空档

@sourcery-ai

sourcery-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Reviewer's Guide

本 PR 将 dde-blackwidget 迁移为基于 DConfig 的增强实现:支持 nodbus 模式直接显示 Plymouth logo、单实例锁、多屏遮罩和 X11 安全护栏,同时通过 Qt6/Dtk6DConfig 更新构建及服务安装配置,并移除原有 startdde GSettings 依赖。

Sequence diagram for dde-blackwidget startup modes

sequenceDiagram
    participant Service as SystemdService
    participant Main as dde_blackwidget
    participant Lock as QLockFile
    participant Window as Window
    participant DConfig as DConfigHelper
    participant X11 as X11

    Service->>Main: start
    Main->>Lock: tryLock(0)
    alt lock unavailable
        Lock-->>Main: false
        Main-->>Service: exit
    else lock acquired
        Main->>Main: parse nodbus argument
        Main->>Window: construct
        alt nodbus mode
            Main->>Window: setLogoVisible(true)
            Window->>DConfig: getConfig(blackWidgetLogoVisible)
            DConfig-->>Window: logo visibility
            Main->>Window: raiseWindow()
        else DBus mode
            Main->>Window: register DBus service
        end
        Window->>X11: ensurePlatformReady()
        Window->>Window: paintBackground()
        Window->>Window: updateScreenWindows()
    end
Loading

File-Level Changes

Change Details Files
将黑屏组件迁移为支持单实例、无 DBus 启动和多屏遮罩的 X11 兼容实现。
  • 通过运行时 QLockFile 统一约束 DBus 与 nodbus 启动实例
  • 新增 nodbus systemd 用户服务,并强制使用 XCB、增加 X11 键盘抓取与退出清理
  • 按屏幕创建独立黑色遮罩窗口,改进窗口提升、激活和平台就绪重试逻辑
  • 移除 Wayland 专用处理,保留 X11 平台安全检查
dde-blackwidget/src/main.cpp
dde-blackwidget/src/window.cpp
dde-blackwidget/src/window.h
dde-blackwidget/misc/systemd/user/dde-blackwidget-nodbus.service
通过 DConfig 管理黑屏行为、logo 和关机文案,使用 Plymouth 主题资源显示 logo。
  • 新增可复用 DConfig 初始化、读取、写入和对象绑定变化回调封装
  • 使用 blackWidgetLogoVisible、blackWidgetShutdownText 和 blackWidgetQuitInterval 配置项
  • 从 plymouthd.conf 解析主题并安全校验主题路径,缺失时回退默认 logo
  • 使用 QPalette 替代 QSS 设置背景和文字颜色
common/dconfig_helper.cpp
common/dconfig_helper.h
configs/org.deepin.dde.session.ui.json
dde-blackwidget/src/window.cpp
更新构建与安装配置以适配 Qt6/Dtk6DConfig 并移除 gsettings 依赖。
  • 将公共构建源切换为包含 DConfig helper
  • 添加 X11、Dtk DConfig、GLib/GIO 链接和公共头文件路径
  • 安装两种 systemd 服务并注册 DConfig 元数据
  • 移除黑屏组件对 GSettings 的构建依赖
common/CMakeLists.txt
dde-blackwidget/CMakeLists.txt

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="dde-blackwidget/src/main.cpp" line_range="43-45" />
<code_context>
-    a.setOrganizationName("deepin");
-    a.setApplicationName("dde-blackwidget");
-    a.setDesktopFileName(QStringLiteral("org.deepin.dde.blackwidget"));
+    if (qgetenv("QT_QPA_PLATFORM") != "xcb") {
+        qputenv("QT_QPA_PLATFORM", "xcb");
+    }

</code_context>
<issue_to_address>
**issue (bug_risk):** The process forcibly selects the XCB Qt platform for every session, so starting it under a Wayland session without a usable Xwayland display causes QApplication initialization to fail and the black-screen overlay never appears.

**Triggers:** When the system is running Wayland and Xwayland is unavailable or its display cannot be opened.

**Suggested fix:** Only force XCB when the environment provides a usable X11 display, or retain a supported Wayland platform path.

```suggestion
    if (qgetenv("QT_QPA_PLATFORM").isEmpty() && !qgetenv("DISPLAY").isEmpty()) {
        qputenv("QT_QPA_PLATFORM", "xcb");
    }
```
</issue_to_address>

### Comment 2
<location path="dde-blackwidget/src/window.cpp" line_range="229-235" />
<code_context>
+        return;
+    }
+
+    QScreen *currentScreen = qApp->primaryScreen();
+    if (!currentScreen) {
+        currentScreen = screens.first();
+        qWarning() << "primary screen is null, use first screen:" << currentScreen;
+    }
+
+    const QRect currentGeometry = currentScreen->geometry();
+    if (geometry().topLeft() != currentGeometry.topLeft()) {
+        move(currentGeometry.topLeft());
+    }
+    if (size() != currentGeometry.size()) {
+        setFixedSize(currentGeometry.size());
+    }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** The Show event calls setupSize(), which unconditionally invokes updateScreenWindows() and resizes the main window to the primary screen geometry after paintBackground() set it to 10000x10000 for gravity-rotate mode; the rotation blackout therefore no longer covers the intended oversized area.

**Triggers:** When gravity-rotate-black-enabled is true.

**Suggested fix:** Preserve the 10000x10000 size in updateScreenWindows or skip the per-screen sizing path while gravity-rotate mode is active.

```suggestion
    const QRect currentGeometry = currentScreen->geometry();
    if (geometry().topLeft() != currentGeometry.topLeft()) {
        move(currentGeometry.topLeft());
    }
    if (!m_gravityRotateBlackEnabled && size() != currentGeometry.size()) {
        setFixedSize(currentGeometry.size());
    }
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread dde-blackwidget/src/main.cpp Outdated
Comment thread dde-blackwidget/src/window.cpp
@mhduiy
mhduiy force-pushed the feat-blackwidget-nodbus-dconfig branch 7 times, most recently from 2487af6 to 428f916 Compare September 8, 2026 05:47
1. Port the V20 black widget with DTK-managed single-instance startup, nodbus mode, and multi-screen X11 coverage.
2. Load the Plymouth logo and shutdown text from one smart-pointer-owned DConfig instance, with logo display enabled by default.
3. Install a Type=exec nodbus user service that remains active after graphical-session.target stops.
4. Use DTK platform detection for X11-specific window flags and input grabs while retaining explicit Treeland extension points.
5. Remove the obsolete gravity-rotate path and redundant platform-readiness wrappers.
6. Add REUSE metadata for DConfig JSON files and normalize new-file copyright years.

Log: Add a nodbus shutdown overlay that displays Plymouth branding until handoff.
Influence: Reduce the blank interval during shutdown.

feat(dde-blackwidget): 支持 nodbus 关机遮罩

1. 迁移 V20 黑屏组件,使用 DTK 管理单实例启动,并支持 nodbus 模式和 X11 多屏覆盖。
2. 通过智能指针管理的单一 DConfig 实例加载 Plymouth logo 和关机文字,并默认显示 logo。
3. 安装 Type=exec nodbus 用户服务,并在 graphical-session.target 停止后继续运行。
4. 使用 DTK 平台检测处理 X11 窗口标志和输入抓取,同时保留明确的 Treeland 扩展入口。
5. 移除废弃的 gravity-rotate 路径和重复的平台就绪包装逻辑。
6. 为 DConfig JSON 文件补充 REUSE 元数据并规范新增文件版权年份。

Log: 新增 nodbus 关机遮罩,在 Plymouth 接管前显示品牌 logo。
PMS: TASK-395319
Influence: 减少关机过程中的纯黑空档。
Change-Id: I85a52a82648f9588a424e8e63f641712117dfaa0
@mhduiy
mhduiy force-pushed the feat-blackwidget-nodbus-dconfig branch from 428f916 to 213a382 Compare September 8, 2026 08:45
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy, yixinshark

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

@mhduiy
mhduiy merged commit a3acfc1 into linuxdeepin:master Sep 8, 2026
13 of 14 checks passed
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.

3 participants