Skip to content

fix(dialog): remove KWin blur from DialogWindow to fix dark theme issue#628

Merged
18202781743 merged 1 commit into
linuxdeepin:masterfrom
robertkill:fix/dialog-dark-theme-blur
May 28, 2026
Merged

fix(dialog): remove KWin blur from DialogWindow to fix dark theme issue#628
18202781743 merged 1 commit into
linuxdeepin:masterfrom
robertkill:fix/dialog-dark-theme-blur

Conversation

@robertkill
Copy link
Copy Markdown
Contributor

@robertkill robertkill commented May 28, 2026

问题

DialogWindow 默认启用 KWin blur (enableBlurWindow: true)。当应用强制深色主题时(如 dde-launchpad 全屏模式),blur 会透过对话框显示背后的深色背景,导致对话框在浅色系统主题下也显示为深色。

修复

  • 移除 enableBlurWindow: true 默认值
  • color 直接设为 transparent,不再依赖 enableBlurWindow 条件判断

影响

所有使用 DialogWindow 的对话框将不再启用 KWin blur,使用标准 DTK 调色板。

测试

已在调试机上验证,dde-launchpad 卸载确认对话框恢复正常。

Bug: https://pms.uniontech.com/bug-view-359629.html

Summary by Sourcery

Bug Fixes:

  • Fix DialogWindow appearing dark under light system themes when applications enforce dark mode by disabling KWin blur and always using a transparent window color.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 28, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR removes the default KWin blur behavior from DialogWindow and simplifies its background color handling to always be transparent, ensuring dialogs respect the standard DTK palette and fixing dark-theme bleed-through issues in cases like dde-launchpad.

Flow diagram for DialogWindow color and blur configuration change

flowchart TD
    A[DialogWindow initialization] --> B[Previous: D.DWindow.enableBlurWindow = true]
    B --> C[Previous: color = transparent if enableBlurWindow]
    C --> D[Else: color = active/inactive DTK window]

    A --> E[Now: D.DWindow.enableBlurWindow removed]
    E --> F[Now: color = transparent]
    F --> G[KWin blur not applied; standard DTK palette respected behind dialog]
Loading

File-Level Changes

Change Details Files
Remove default KWin blur on DialogWindow to prevent dark background bleed-through when forcing dark theme.
  • Dropped the D.DWindow.enableBlurWindow: true property so dialogs no longer request KWin blur by default.
  • Ensured dialogs will now use standard DTK window colors rather than a blurred background when rendered by the window manager.
qt6/src/qml/DialogWindow.qml
Simplify DialogWindow background color logic to always be transparent instead of conditional on blur.
  • Replaced the conditional color expression referencing D.DWindow.enableBlurWindow and active palettes with a constant "transparent" color value.
  • Relied on DTK’s normal theming behavior without tying it to the blur flag, reducing theme-related side effects.
qt6/src/qml/DialogWindow.qml

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The description says dialogs will 'use standard DTK palette', but the change makes color always "transparent", which no longer uses DTK.palette.window; consider either restoring palette-based coloring when blur is off or updating the description to match the behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The description says dialogs will 'use standard DTK palette', but the change makes `color` always `"transparent"`, which no longer uses `DTK.palette.window`; consider either restoring palette-based coloring when blur is off or updating the description to match the behavior.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@robertkill robertkill force-pushed the fix/dialog-dark-theme-blur branch from 50834d3 to 3d37e45 Compare May 28, 2026 07:41
@deepin-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, mhduiy, robertkill

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

1. Remove enableBlurWindow: true default from DialogWindow.qml
2. Set color to transparent directly instead of conditional on enableBlurWindow

Influence:
1. All DialogWindow instances will no longer use KWin blur
2. Dialog windows will use standard DTK palette without blur side effects
3. Applications forcing dark theme will not affect dialog appearance

fix: 从 DialogWindow 移除 KWin blur 以修复深色主题问题

1. 从 DialogWindow.qml 中移除 enableBlurWindow: true 默认值
2. 将 color 直接设为 transparent,不再依赖 enableBlurWindow 条件判断

Influence:
1. 测试所有使用 DialogWindow 的对话框在浅色/深色主题下的显示
2. 验证 dde-launchpad 卸载确认对话框在浅色系统主题下不再显示深色
3. 检查其他 DTK 应用(如关于对话框)的 blur 效果是否正常
4. 在不同屏幕分辨率和缩放比例下进行测试

PMS: BUG-359629
@robertkill robertkill force-pushed the fix/dialog-dark-theme-blur branch from 3d37e45 to 21d979f Compare May 28, 2026 08:26
@deepin-ci-robot
Copy link
Copy Markdown
Contributor

deepin pr auto review

你好!我是CodeGeeX,你的智能编程助手。我已仔细审查了你提供的 Git Diff 输入。本次修改主要针对 QML 中的 DialogWindow.qml,移除了窗口模糊效果(enableBlurWindow)的动态配置,并将窗口背景色硬编码为透明。

以下是针对语法逻辑、代码质量、代码性能和代码安全四个维度的详细审查与改进意见:

1. 语法逻辑

  • 逻辑简化与一致性:原代码中 color 属性依赖于 enableBlurWindowactive 状态进行动态计算。现在移除了模糊效果,直接将 color 设为 "transparent",这在逻辑上是自洽的。因为如果窗口背景不透明,透明色就没有意义;而移除模糊后,如果仍保留原来的非透明色,会导致底层模糊效果残留或渲染异常。因此,当前的逻辑修改是合理的。
  • 潜在渲染异常风险:在 QML 中,将 Windowcolor 设置为 "transparent" 时,如果不配合特定的图形层(如 Qt Quick Scene Graph 的透明层支持),在某些平台或某些情况下可能会出现黑底闪烁穿透点击的问题。确保该窗口在其他平台的渲染表现符合预期。

2. 代码质量

  • 硬编码问题:将 color: "transparent" 硬编码会降低代码的灵活性。如果未来需要恢复模糊效果,或者需要根据主题切换背景色,就需要重新修改此处代码。
  • 残留代码清理:虽然删除了 D.DWindow.enableBlurWindow: true,但原代码中 D.DWindow.motifFunctionsD.DWindow.wmWindowTypes 等与窗口管理器(WM)强相关的属性仍然保留。请确认在移除模糊效果后,这些 WM 相关的设置是否仍然必要,避免留下无用代码。

3. 代码性能

  • 性能提升:移除 enableBlurWindow 通常是一个提升性能的操作。实时的高斯模糊是极其消耗 GPU 资源的,特别是在低端设备或集成显卡上,会导致窗口拖拽卡顿、掉帧。移除它并使用纯透明或纯色背景,可以大幅减轻渲染引擎的负担。
  • 过度绘制:将 color 设为透明后,如果 content 内部有复杂的图层叠加,可能会增加 GPU 的过度绘制。建议确保 content 的背景是不透明的,以避免渲染性能损耗。

4. 代码安全

  • UI 安全与点击穿透:在 QML 中,透明窗口区域默认可能会让鼠标事件穿透到下层应用(取决于平台和 Qt 版本)。如果 content 没有完全覆盖整个 Window,或者 content 内部存在透明区域,用户可能会误点到该对话框下层的其他应用窗口,这属于 UI 交互层面的“安全/防误触”隐患。
  • 信息泄露风险:如果窗口背景完全透明,且 content 尺寸小于 Window 尺寸,用户可能会透过透明部分看到桌面或其他应用中的敏感信息。

💡 改进建议与代码示例

为了提升代码的健壮性和可维护性,建议:

  1. color 提供一个回退机制,防止透明渲染失败时出现黑块。
  2. 确保窗口的鼠标事件不会被穿透。

改进后的代码示例:

Window {
    // ... 其他属性保持不变 ...
    D.DWindow.enableSystemResize: false
    D.DWindow.motifFunctions: D.WindowManagerHelper.FUNC_ALL & ~D.WindowManagerHelper.FUNC_RESIZE
    D.DWindow.wmWindowTypes: D.WindowManagerHelper.DialogType
    
    // 移除了 enableBlurWindow: true
    
    flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.MSWindowsFixedSizeDialogHint
    D.ColorSelector.family: D.Palette.CrystalColor
    
    // 改进点 1:使用条件表达式提供回退色,避免在某些不支持透明度的 Linux 窗口管理器上出现黑块
    // 如果确认当前运行环境完全支持透明,可直接使用 "transparent"
    color: D.DWindow.enableBlurWindow ? "transparent" : D.DTK.palette.window
    
    // 改进点 2:如果必须全透明,确保整个窗口区域可以拦截鼠标事件,防止点击穿透
    // 可以添加一个 MouseArea 作为底层拦截
    MouseArea {
        anchors.fill: parent
        onClicked: {} // 拦截点击,不做处理,防止穿透
    }
    
    height: content.height
    width: content.width
    
    // 改进点 3:确保 content 能够完全填充窗口并提供视觉边界
    // ...
}

总结:本次修改的核心逻辑是合理的,主要目的是优化性能和简化渲染逻辑。但需要特别注意跨平台透明窗口的渲染兼容性以及鼠标事件穿透的问题。如果该应用只在特定桌面环境(如 DDE,看代码前缀似乎是 Deepin 相关)下运行,透明度支持通常较好,但仍建议做好防御性编程。

@18202781743 18202781743 merged commit ad644ea into linuxdeepin:master May 28, 2026
18 of 20 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.

4 participants