Skip to content

fix: use platform check API for menu decoration in treeland#318

Merged
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master
Jun 22, 2026
Merged

fix: use platform check API for menu decoration in treeland#318
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743

@18202781743 18202781743 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor
  1. Replace manual platform name checking with DTK API to detect Wayland
    platform
  2. Fix menu decoration issue under treeland by using proper platform
    detection method
  3. Include DGuiApplicationHelper header for the new API usage

Log: Fixed menu decoration issue in treeland environment by using
correct platform detection API

Influence:

  1. Test menu display in treeland environment
  2. Verify menu decorations appear correctly
  3. Test menu functionality in other window managers (dxcb, dwayland)
  4. Verify no regression in normal X11 environment
  5. Test context menus in various applications

fix: 适配treeland下菜单无装饰器问题

  1. 使用DTK API替换手动平台名称检查来检测Wayland平台
  2. 通过正确的平台检测方法修复treeland下的菜单装饰问题
  3. 添加DGuiApplicationHelper头文件以使用新的API

Log: 修复treeland环境下菜单没有装饰器的问题

Influence:

  1. 在treeland环境测试菜单显示
  2. 验证菜单装饰器是否正确显示
  3. 在其他窗口管理器(dxcb、dwayland)测试菜单功能
  4. 验证在普通X11环境下没有回归问题
  5. 测试各种应用程序中的上下文菜单

Summary by Sourcery

Use DTK's platform helper to detect Wayland and fix menu decoration behavior on treeland.

Bug Fixes:

  • Resolve missing menu decorations on treeland by using proper Wayland platform detection.

Enhancements:

  • Replace manual platform name and property checks with DGuiApplicationHelper-based Wayland detection for menu styling logic.

1. Replace manual platform name checking with DTK API to detect Wayland
platform
2. Fix menu decoration issue under treeland by using proper platform
detection method
3. Include DGuiApplicationHelper header for the new API usage

Log: Fixed menu decoration issue in treeland environment by using
correct platform detection API

Influence:
1. Test menu display in treeland environment
2. Verify menu decorations appear correctly
3. Test menu functionality in other window managers (dxcb, dwayland)
4. Verify no regression in normal X11 environment
5. Test context menus in various applications

fix: 适配treeland下菜单无装饰器问题

1. 使用DTK API替换手动平台名称检查来检测Wayland平台
2. 通过正确的平台检测方法修复treeland下的菜单装饰问题
3. 添加DGuiApplicationHelper头文件以使用新的API

Log: 修复treeland环境下菜单没有装饰器的问题

Influence:
1. 在treeland环境测试菜单显示
2. 验证菜单装饰器是否正确显示
3. 在其他窗口管理器(dxcb、dwayland)测试菜单功能
4. 验证在普通X11环境下没有回归问题
5. 测试各种应用程序中的上下文菜单
@18202781743 18202781743 requested review from BLumia and mhduiy June 22, 2026 05:20
@sourcery-ai

sourcery-ai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR fixes menu decoration handling under Treeland/Wayland by replacing manual platform name checks with the DTK DGuiApplicationHelper platform attribute API and updating includes accordingly.

Sequence diagram for updated platform detection in ChameleonStyle::polish

sequenceDiagram
    participant ChameleonStyle
    participant QWidget
    participant DApplication
    participant DGuiApplicationHelper

    ChameleonStyle->>QWidget: polish(QWidget w)
    ChameleonStyle->>DApplication: isDXcbPlatform()
    alt DXcb platform
        ChameleonStyle->>QWidget: qobject_cast<QMenu>(w) / inherits("QTipLabel")
        ChameleonStyle->>QWidget: apply menu decoration
    else not DXcb
        ChameleonStyle->>DGuiApplicationHelper: testAttribute(IsWaylandPlatform)
        alt Wayland platform (treeland, dwayland, etc.)
            ChameleonStyle->>QWidget: qobject_cast<QMenu>(w) / inherits("QTipLabel")
            ChameleonStyle->>QWidget: apply menu decoration
        else not Wayland
            ChameleonStyle->>QWidget: no special menu decoration
        end
    end
Loading

File-Level Changes

Change Details Files
Use DTK platform attribute API instead of manual platform name checks to detect Wayland for menu decoration logic.
  • Replace inclusion of dtkgui_config header with DGuiApplicationHelper header to access the platform attribute API.
  • Update the conditional that previously checked qApp->platformName() and a _d_isDwayland property to instead call DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform) alongside the existing DApplication::isDXcbPlatform() check.
  • Keep existing menu and tooltip detection logic (is_menu and is_tip) but ensure it now relies on the unified platform detection condition.
styleplugins/chameleon/chameleonstyle.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

@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 reviewed your changes and they look great!


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.

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

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

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码正确使用DTK标准接口替换了冗余的Wayland平台检测逻辑,消除了对非标准属性的依赖
逻辑清晰、符合规范且无任何安全风险,无需扣分

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓

在ChameleonStyle::polish函数中,将原先复杂的字符串比较与属性读取逻辑替换为DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform),逻辑等价且更加严谨,完全符合DTK框架的设计意图
潜在问题:无
建议:保持当前实现

  • 2.代码质量(优秀)✓

移除了对dtkgui_config.h内部配置头文件的依赖,转而使用公开的DGuiApplicationHelper接口,大幅提升了代码的可维护性和规范性,彻底消除了硬编码的字符串"dwayland"和内部属性"_d_isDwayland"
潜在问题:无
建议:保持当前实现

  • 3.代码性能(无性能问题)✓

接口替换前后均属于轻量级的条件判断,DGuiApplicationHelper::testAttribute内部通常通过位运算或简单的布尔变量读取实现,不会引入额外的性能开销
潜在问题:无
建议:保持当前实现

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
代码移除了对qApp->property的调用,降低了通过动态属性注入进行平台欺骗的理论风险,整体安全可靠

  • 建议:无需额外安全修复措施

■ 【改进建议代码示例】

// 当前代码已为最佳实践,无需修改,此处展示当前正确实现供参考
#include <DGuiApplicationHelper>
// ...
void ChameleonStyle::polish(QWidget *w)
{
    // ...
    if (DApplication::isDXcbPlatform() || DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
        bool is_menu = qobject_cast<QMenu *>(w);
        bool is_tip = w->inherits("QTipLabel");
        // ...
    }
}

@18202781743 18202781743 merged commit 42c6189 into linuxdeepin:master Jun 22, 2026
22 of 23 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