Skip to content

refactor(launcher): remove redundant window flags configuration#725

Open
add-uos wants to merge 1 commit intolinuxdeepin:masterfrom
add-uos:fix/BUG-289261-BUG-343503-window-flags
Open

refactor(launcher): remove redundant window flags configuration#725
add-uos wants to merge 1 commit intolinuxdeepin:masterfrom
add-uos:fix/BUG-289261-BUG-343503-window-flags

Conversation

@add-uos
Copy link

@add-uos add-uos commented Mar 7, 2026

Remove commented visibility setting and conditional window flags that are no longer needed.

删除不再需要的窗口可见性注释和条件窗口标志配置。

Log: 移除冗余的窗口标志配置
PMS: BUG-289261, BUG-343503
Influence: 清理冗余代码,窗口标志现在由 DLayerShellWindow 统一管理。

Summary by Sourcery

Enhancements:

  • Simplify launcher window configuration by removing obsolete visibility and flag settings that are now managed by DLayerShellWindow.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

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
Copy link

sourcery-ai bot commented Mar 7, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the launcher item's window configuration by removing now-redundant window flags logic so that window behavior is fully managed by DLayerShellWindow/DWindow.

Class diagram for launcher window configuration refactor

classDiagram
    class AppletItem {
    }

    class LauncherItemWindow {
        <<QML_Window>>
        string note_removed_flags "Removed flags"
    }

    class DLayerShellWindow {
        <<QML_Attached_Properties>>
        int exclusionZone
        string scope
        string note_window_flags_visibility "Manages window flags and visibility"
    }

    class DWindow {
        <<QML_Attached_Properties>>
        bool enabled
        int windowRadius
        bool enableSystemResize
    }

    class DebugHelper {
        <<Singleton>>
        bool useRegularWindow
    }

    AppletItem *-- LauncherItemWindow : contains
    LauncherItemWindow .. DLayerShellWindow : attached
    LauncherItemWindow .. DWindow : attached
    DebugHelper ..> DWindow : controls enabled
Loading

Flow diagram for launcher window configuration after refactor

flowchart LR
    A[LauncherItemWindow creation] --> B[DLayerShellWindow attached properties]
    A --> C[DWindow attached properties]

    B --> B1[exclusionZone = -1]
    B --> B2[scope = dde-shell/launchpad]

    C --> D{DebugHelper.useRegularWindow}
    D -- true --> E[DWindow.enabled = false]
    D -- false --> F[DWindow.enabled = true]

    B1 --> G[Window behavior managed by DLayerShellWindow]
    B2 --> G
    E --> G
    F --> G
Loading

File-Level Changes

Change Details Files
Remove custom window flags configuration from the launcher item so window behavior is fully controlled by the underlying shell/window abstractions.
  • Deleted the commented-out visibility property that forced fullscreen mode.
  • Removed the flags function block that conditionally chose between a regular Qt.Window and a frameless Qt.Tool window based on DebugHelper.useRegularWindow.
  • Left DWindow- and DLayerShellWindow-related properties intact so window configuration is now centralized there.
shell-launcher-applet/package/launcheritem.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

@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 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.

@add-uos add-uos force-pushed the fix/BUG-289261-BUG-343503-window-flags branch from ab034c1 to f954f5e Compare March 7, 2026 02:50
BLumia
BLumia previously approved these changes Mar 7, 2026
Copy link
Member

@BLumia BLumia left a comment

Choose a reason for hiding this comment

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

能接受,DebugHelper 的独立窗口模式目前已经没人用了大概,不过如果能保留这个选项的功能的话更好,这个选项是用来给特定调试需求 attach gammaray 用的。

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 -2026 UnionTech Software Technology Co., Ltd.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// SPDX-FileCopyrightText: 2023 -2026 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.

Remove commented visibility setting and conditional window flags
that are no longer needed.

删除不再需要的窗口可见性注释和条件窗口标志配置。

Log: 移除冗余的窗口标志配置
PMS: BUG-289261, BUG-343503
Influence: 清理冗余代码,窗口标志现在由 DLayerShellWindow 统一管理。
@add-uos add-uos force-pushed the fix/BUG-289261-BUG-343503-window-flags branch from f954f5e to eff1b05 Compare March 7, 2026 06:13
@deepin-ci-robot
Copy link

deepin pr auto review

这段希望对提供的 git diff 进行代码审查,重点关注语法逻辑、代码质量、代码性能和代码安全。

1. Diff 分析:

  • 版权年份更新: SPDX-FileCopyrightText: 2023 -> 2023 - 2026。这是标准的维护操作,用于延长版权声明。
  • Layer 属性变更: DLayerShellWindow.layerLayerTop 变更为 LayerOverlay
    • LayerTop: 通常用于面板等需要位于普通窗口之上,但在锁屏或全屏窗口之下的元素。
    • LayerOverlay: 通常用于需要位于所有内容之上(包括锁屏层,尽管具体行为取决于 Wayland 合成器的实现和特定的 layer-shell 协议扩展)的元素,比如屏幕键盘或特定的全局菜单/启动器。将启动器(Launchpad)改为 LayerOverlay 意味着它应该始终可见且位于最顶层,不受全屏窗口遮挡。
  • 删除代码:
    • 注释掉的 visibility: Window.FullScreen
    • flags 属性的绑定逻辑:根据 DebugHelper.useRegularWindow 的值决定是使用普通窗口 (Qt.Window) 还是无边框工具窗口 (Qt.FramelessWindowHint | Qt.Tool)。
  • 新增/保留代码: DWindow.enabled: !DebugHelper.useRegularWindow。这行代码控制是否启用 Wayland Layer Shell 特性。如果使用常规窗口(调试模式),则禁用 DWindow。

2. 审查意见:

  • 语法逻辑:

    • QML 语法本身没有错误。
    • 逻辑上,删除 flags 属性是合理的,因为当使用 DLayerShellWindow 时,窗口的层级和锚点由 Wayland 协议的 layer-shell 扩展控制,传统的 X11 风格的 flags(如 Qt.ToolQt.FramelessWindowHint)可能会产生冲突或被忽略。如果 DWindow.enabled 为 true(即非调试模式),flags 的设置可能是不必要的副作用。
    • DWindow.enabled: !DebugHelper.useRegularWindow 这一行确保了在调试模式下(使用普通窗口)不启用 Wayland 特有的 DWindow 封装,逻辑自洽。
  • 代码质量:

    • 清理死代码: 删除注释掉的 visibility 和不再使用的 flags 绑定是良好的实践,减少了代码混淆。
    • 意图明确: 将 layer 改为 LayerOverlay 明确了该窗口在全屏应用或锁屏时的层级行为(即置顶)。
  • 代码性能:

    • QML 属性绑定的移除(flags)理论上会略微减少属性评估的开销,但影响微乎其微。
    • LayerOverlayLayerTop 在性能上通常没有显著差异,主要影响合成器的渲染顺序。
  • 代码安全:

    • 没有直接的安全漏洞。
    • LayerOverlay 的使用需要谨慎,因为它允许窗口覆盖锁屏或其他关键系统 UI。如果 Launchpad 存在漏洞,可能会被利用来覆盖安全提示(如密码输入框)。但作为系统启动器,这种行为可能是预期的(例如在全屏游戏时呼出启动器)。

3. 改进建议:

  • 关于 LayerOverlay 的确认: 需要确认 Launchpad 是否真的需要覆盖锁屏。通常启动器(Launchpad/Menu)在锁屏时是不应该显示的,或者应该被锁屏遮挡。如果是这样,LayerTop 可能更合适,或者需要在锁屏状态变化时动态调整 layer。如果需求是“在任何情况下都能呼出”,则 LayerOverlay 是正确的。
  • 关于 flags 删除的兼容性: 删除 flags 意味着完全依赖 DLayerShellWindow 的默认行为或 Wayland 协议。需要确保在非 Wayland 环境(如果该组件支持回退)或特定合成器上,删除 flags 不会导致意外的窗口装饰(边框、标题栏)出现。不过,既然有 DWindow.enabled 控制开关,且 DWindow.windowRadius: 0,看起来是有意为之。

4. 格式化输出:

按照用户要求的格式(语法逻辑、代码质量、代码性能、代码安全)组织语言。

详细草稿:

  • 语法逻辑

    • 修改后的代码移除了 flags 属性,这对于使用 Wayland Layer Shell 协议的窗口是正确的。Layer Shell 窗口通常不应依赖传统的 X11 窗口标志(如 Qt.Tool)来控制外观,而是由协议本身管理。
    • DWindow.enabled 的逻辑保持不变,确保了调试模式下回退到普通窗口行为,逻辑清晰。
  • 代码质量

    • 删除了注释掉的代码和不再使用的 flags 绑定,提高了代码的可读性和整洁度。
    • 更新了版权年份,符合合规性要求。
  • 代码性能

    • 移除不必要的属性绑定减少了微小的运行时开销,但对整体性能影响极小。
    • Layer 的变更主要影响渲染层级,对性能无明显负面影响。
  • 代码安全

    • 将层级改为 LayerOverlay 意味着该窗口可以覆盖锁屏层。请确保这是符合产品设计意图的。通常,启动器在全屏应用或锁屏时应被遮挡,除非有特殊需求(如全局快捷键呼出且必须可见)。如果不需要覆盖锁屏,建议保持 LayerTop 或根据锁屏状态动态切换,以防止潜在的 UI 欺骗风险。

总结:代码修改在逻辑上是自洽的,清理了冗余代码。主要关注点在于 LayerOverlay 的使用是否符合安全策略(是否允许覆盖锁屏)。

最终输出生成
将上述思考转化为结构化的中文回答。以下是对提供的 git diff 的代码审查意见:

1. 语法逻辑

  • 移除 flags 属性是合理的:在 Wayland 合成器环境下,使用 DLayerShellWindow 时,窗口的层级、锚点和交互性由 Wayland Layer Shell 协议直接控制。保留传统的 X11 风格窗口标志(如 Qt.FramelessWindowHintQt.Tool)可能会导致冲突或被忽略。移除 flags 并完全依赖 DLayerShellWindow 的属性(如 layer, anchors)符合 Wayland 的编程逻辑。
  • 调试逻辑保留完整:代码保留了 DWindow.enabled: !DebugHelper.useRegularWindow,这意味着在调试模式下(useRegularWindow 为 true),会禁用 DWindow 封装,回退到普通窗口行为。由于 flags 被移除,调试模式下的窗口行为将依赖于 QML Window 的默认属性或 DTK 的默认处理,逻辑上是自洽的。

2. 代码质量

  • 清理冗余代码:删除了注释掉的 visibility: Window.FullScreen 和不再使用的 flags 绑定块,这提高了代码的整洁度和可维护性,避免了后续维护者对废弃代码的困惑。
  • 版权更新:将版权年份从 2023 更新为 2023 - 2026,符合开源项目维护的规范,表明代码将持续维护。

3. 代码性能

  • 属性绑定优化:移除 flags 的属性绑定逻辑(flags: { if ... })消除了运行时的条件判断开销,尽管影响极小,但在高频属性访问场景下是有益的优化。
  • Layer 层级变更:将 layerLayerTop 改为 LayerOverlay 主要影响合成器的渲染顺序,对 GPU 渲染性能没有显著影响。

4. 代码安全

  • LayerOverlay 的潜在风险
    • 修改将窗口层级提升到了 LayerOverlay。在 Wayland Layer Shell 协议中,LayerOverlay 通常用于锁屏界面、屏幕键盘等需要位于所有内容(包括全屏窗口和锁屏)之上的组件。
    • 建议:请确认 Launchpad(启动器)的业务逻辑是否需要覆盖锁屏界面。通常情况下,启动器在全屏游戏或视频播放时可能不应遮挡,或者在锁屏状态下不应显示。如果不需要覆盖锁屏,建议保持 LayerTop 或者在检测到锁屏时动态降低层级,以防止潜在的 UI 欺骗或遮挡关键安全提示。

总结

该 diff 主要是为了适配 Wayland 协议的特性,清理了不再适用的 X11 风格代码,逻辑上是正确的。唯一的关注点在于 LayerOverlay 的使用,请务必确认该组件确实需要拥有比锁屏更高的层级权限。

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