Conversation
1. Root cause: Window constructor inherited DMainWindow but did not call setAttribute(Qt::WA_TranslucentBackground), causing X11 to use 24-bit visual without alpha channel 2. Fix: add setAttribute(Qt::WA_TranslucentBackground) in Window constructor to enable 32-bit visual with alpha channel 3. Impact: kwin XRender compositor now correctly handles window alpha blending in Alt+Tab switcher, no effect on OpenGL compositing Log: fix window preview residual in Alt+Tab switcher under best performance mode Influence: 1. Test Alt+Tab window switching under best performance (XRender) mode 2. Verify window rendering under OpenGL compositing mode 3. Verify normal window operations (drag, maximize, minimize) fix: 设置窗口透明背景属性 1. 根因:Window 构造函数继承 DMainWindow 但未调用 setAttribute(Qt::WA_TranslucentBackground),导致 X11 使用 24-bit visual 无 alpha 通道 2. 方案:在 Window 构造函数中添加 setAttribute(Qt::WA_TranslucentBackground) 启用 32-bit visual 带 alpha 通道 3. 影响:kwin XRender 合成器在 Alt+Tab 切换器中正确处理窗口透明度 混合,不影响 OpenGL 合成模式 Log: 修复最佳性能模式下 Alt+Tab 切换器窗口预览残留问题 Influence: 1. 测试最佳性能(XRender)模式下 Alt+Tab 窗口切换 2. 验证 OpenGL 合成模式下窗口渲染 3. 验证窗口正常操作(拖拽、最大化、最小化) PMS: BUG-339947
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR fixes residual deepin-editor previews during Alt+Tab under XRender compositing by setting the window's translucent-background attribute during construction, matching the established deepin-terminal approach. The change is localized and low risk; review should focus on constructor timing and validating XRender, OpenGL, and normal window operations. Sequence diagram for translucent window initializationsequenceDiagram
participant Application
participant Window
participant Qt
participant KWin
Application->>Window: Window::Window(parent)
Window->>Qt: setAttribute(Qt::WA_TranslucentBackground)
Qt-->>Window: Window uses alpha-capable visual
Window-->>Application: Constructed
KWin->>Window: Read window alpha during Alt+Tab
KWin-->>Window: Blend preview correctly
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码语法正确,逻辑清晰。setAttribute(Qt::WA_TranslucentBackground) 是 Qt QWidget 的标准 API 调用,DMainWindow 通过继承链 DMainWindow → QMainWindow → QWidget 可正常访问该方法。Qt::WA_TranslucentBackground 是有效的 Qt::WidgetAttribute 枚举值。属性设置放置在构造函数体开头,在窗口显示之前生效,符合 Qt 文档建议的使用方式。与 deepin-terminal 的 MainWindow::initWindow() 中相同的调用方式保持一致。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码改动极小且聚焦(仅新增1行),无重复代码,无残留调试代码。PR 描述提供了详尽的根因分析、修复方案和影响评估,文档质量优秀。改动遵循与 deepin-terminal 一致的实现模式,可维护性良好。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: setAttribute() 是轻量级操作,仅设置窗口属性标志位,仅在构造时调用一次。启用半透明背景后,合成器需处理 alpha 通道混合,但这是预期行为且与 deepin-terminal 一致,不会引入性能瓶颈。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 本次改动不涉及用户输入处理、网络操作、文件系统访问、密码学操作或命令执行,不存在安全风险。 💡 改进建议代码示例// 当前代码已是最优实现,无需修改
// src/widgets/window.cpp - Window::Window(DMainWindow *parent)
{
setAttribute(Qt::WA_TranslucentBackground); // 启用32-bit visual,支持alpha通道
// ... 其余构造函数代码
}本报告由 AI 代码审查工具自动生成 |
|
TAG Bot New tag: 6.6.3 |
|
TAG Bot New tag: 6.6.4 |
Root Cause Analysis
deepin-editor's
Windowclass inheritsDMainWindowbut does not callsetAttribute(Qt::WA_TranslucentBackground)in its constructor, causing X11 to use a 24-bit visual without an alpha channel. Under the XRender compositing mode (best performance, kwin compositing type=4), kwin detectshasAlpha: falsefor the window and skips alpha blending in the Alt+Tab switcher, resulting in a residual preview of deepin-editor when switching to other applications.Key evidence: kwin logs show
"deepin-editor" hasAlpha: falsevs"deepin-terminal" hasAlpha: true; deepin-terminal explicitly callssetAttribute(Qt::WA_TranslucentBackground)in itsMainWindow::initWindow(), while deepin-editor'sWindowconstructor does not.DMainWindow(dtkwidget) does not set this attribute by default.Fix
Added
setAttribute(Qt::WA_TranslucentBackground)at the beginning of theWindowconstructor body insrc/widgets/window.cpp, consistent with deepin-terminal's approach. This enables a 32-bit visual with alpha channel, allowing kwin to correctly handle window alpha blending in the Alt+Tab switcher.Change Safety Assessment
Code Safety
setAttribute(Qt::WA_TranslucentBackground)) to theWindowconstructor body, with no function signature changes, no logic modifications, and no external callers affectedef4cf7a), unrelated to window transparency; this change does not revert any historical fixBusiness Impact Scope
Affects deepin-editor's window rendering under X11 compositing. In XRender (best performance) mode, the Alt+Tab window switcher will now correctly clear deepin-editor's preview when switching to other applications. OpenGL compositing mode and normal window operations (drag, maximize, minimize) are unaffected.
Verification Suggestion
根因分析
deepin-editor 的
Window类继承DMainWindow但在构造函数中未调用setAttribute(Qt::WA_TranslucentBackground),导致 X11 使用 24-bit visual(无 alpha 通道)。在 XRender 合成模式(最佳性能,kwin compositing type=4)下,kwin 检测到该窗口hasAlpha: false,在 Alt+Tab 切换器的透明度混合特效中跳过该窗口,导致切换到其他应用时文本编辑器的预览窗口残留。关键证据:kwin 日志显示
"deepin-editor" hasAlpha: false而"deepin-terminal" hasAlpha: true;deepin-terminal 在MainWindow::initWindow()中显式调用了setAttribute(Qt::WA_TranslucentBackground),而 deepin-editor 的Window构造函数未设置。DMainWindow(dtkwidget)默认不设置该属性。修复方案
在
src/widgets/window.cpp的Window构造函数体开头添加setAttribute(Qt::WA_TranslucentBackground),与 deepin-terminal 的做法一致。该属性启用 32-bit visual(带 alpha 通道),使 kwin 在 Alt+Tab 切换器中正确处理窗口透明度混合。改动安全评估
代码安全评估
Window构造函数中新增一行setAttribute(Qt::WA_TranslucentBackground)调用,不修改函数签名、不改变已有逻辑流程、无外部调用者受影响ef4cf7a),与窗口透明属性无关,本次改动不会撤销任何历史修复业务影响范围
影响 deepin-editor 在 X11 合成模式下的窗口渲染。在 XRender(最佳性能)模式下,Alt+Tab 窗口切换器将正确清除文本编辑器的预览窗口。OpenGL 合成模式和窗口正常操作(拖拽、最大化、最小化)不受影响。
验证建议
Summary by Sourcery
Bug Fixes: