Skip to content

fix: 修复4K 225%缩放下切换深色模式时插件面板图标偶现黑色(DDE-225) - #505

Draft
MyLeeJiEun wants to merge 2 commits into
linuxdeepin:masterfrom
MyLeeJiEun:fix/dde-225-icon-theme-switch
Draft

MyLeeJiEun wants to merge 2 commits into
linuxdeepin:masterfrom
MyLeeJiEun:fix/dde-225-icon-theme-switch

Conversation

@MyLeeJiEun

@MyLeeJiEun MyLeeJiEun commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

修复说明

4K 屏幕、225% 缩放下切换深色模式时,插件面板中图标偶现未切换成功、显示为黑色。

根因

主题切换时三路 Wayland 事件非原子化发送,触发多次重绘竞态;高 DPI 分数缩放下图标渲染时序问题导致图标偶现黑色。

修改内容

  • 修复主题切换事件的发送时序,确保原子化通知
  • 优化图标刷新逻辑,避免竞态条件下的错误渲染

关联

Summary by Sourcery

确保主题切换通知与插件图标刷新协调执行,避免竞态导致图标渲染异常。

Bug Fixes:

  • 修复高 DPI 分数缩放下切换深色模式时插件面板图标偶现显示为黑色的问题。

Enhancements:

  • 提升主题切换后的图标刷新可靠性,并避免主题资源暂未加载完成时覆盖已有有效图标。

P0: Defer DGuiApplicationHelper::setPaletteType() call in
WidgetPlugin::onDockColorThemeChanged using QTimer::singleShot(0),
allowing theme_changed events (icon theme name update) to be
processed first in the same batch of Wayland events.

P1: In CommonIconButton::setIcon(), when QIcon::fromTheme() returns
null, try fallback -> default icon -> keep old icon (don't clear).
In refreshIcon(), if icon is still null after setState(), schedule a
50ms delayed retry to handle icon theme not yet loaded.

Fixes intermittent black icons when switching dark mode on 4K/225%.
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MyLeeJiEun

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 Sep 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

通过将主题切换调色板更新异步化,并在图标主题资源尚未加载完成时保留有效图标、执行有限次延迟刷新重试,降低高 DPI 分数缩放场景下主题切换引发的图标黑色或错误渲染问题。

Sequence diagram for asynchronous theme change and icon refresh

sequenceDiagram
    participant Dock as Dock
    participant WidgetPlugin as WidgetPlugin
    participant Palette as DGuiApplicationHelper
    participant IconButton as CommonIconButton
    participant Theme as IconTheme

    Dock->>WidgetPlugin: onDockColorThemeChanged(type)
    WidgetPlugin-->>Palette: setPaletteType(type) via QTimer::singleShot(0)
    Palette-->>IconButton: Theme change notification
    IconButton->>IconButton: refreshIcon()
    IconButton->>Theme: QIcon::fromTheme(icon)
    alt icon resource unavailable
        IconButton->>IconButton: QTimer::singleShot(50, refreshIcon)
        IconButton->>Theme: QIcon::fromTheme(icon)
    else icon resource available
        IconButton->>IconButton: setIcon(state)
        IconButton->>IconButton: update()
    end
Loading

File-Level Changes

Change Details Files
延迟主题类型更新,使 Wayland 主题通知在事件循环中统一处理,降低多路事件触发的重绘竞态。
  • 通过零延迟定时器异步调用调色板主题切换。
src/loader/widgetplugin.cpp
增强图标切换期间的加载容错,避免主题资源暂未就绪时以空图标覆盖已有图标。
  • 使用临时 QIcon 完成主题、回退和默认图标查找,仅在找到有效图标时更新成员图标。
  • 图标为空时按 50ms 间隔进行有限次刷新重试,成功后或达到上限后重置重试状态。
  • 新增图标刷新重试计数及最大重试次数配置。
plugins/dde-dock/common/commoniconbutton.cpp
plugins/dde-dock/common/commoniconbutton.h

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

@deepin-ci-robot

Copy link
Copy Markdown

Hi @MyLeeJiEun. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@deepin-bot

deepin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.40
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #506

@deepin-bot

deepin-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.41
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants