Skip to content

fix: disable gesture module on Treeland#1133

Open
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:fix/disable-gesture-on-treeland
Open

fix: disable gesture module on Treeland#1133
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:fix/disable-gesture-on-treeland

Conversation

@yixinshark
Copy link
Copy Markdown
Contributor

@yixinshark yixinshark commented May 29, 2026

Add gesture to the Treeland module denylist so dde-session-daemon does not load the legacy gesture module under Treeland.

将 gesture 加入 Treeland 模块禁用列表,避免 dde-session-daemon 在 Treeland 环境加载旧的 gesture 模块。

Log: disable gesture module on Treeland
Pms: TASK-390447
Change-Id: I68f5a29ef9b3543523d1b15baa678b6ec432032f

Summary by Sourcery

Bug Fixes:

  • Add the gesture module to the Treeland module denylist so it is not loaded under Treeland.

Add gesture to the Treeland module denylist so dde-session-daemon does not load the legacy gesture module under Treeland.

将 gesture 加入 Treeland 模块禁用列表,避免 dde-session-daemon 在 Treeland 环境加载旧的 gesture 模块。

Log: disable gesture module on Treeland
Pms: TASK-390447
Change-Id: I68f5a29ef9b3543523d1b15baa678b6ec432032f
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yixinshark

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

sourcery-ai Bot commented May 29, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds the legacy gesture module to the Treeland module denylist so dde-session-daemon skips loading it under Treeland, and updates the SPDX copyright year range.

Flow diagram for Treeland module denylist including gesture

flowchart LR
    TreelandEnv["Treeland environment detected"] --> Loader["dde-session-daemon module loader"]
    Loader --> CheckDenylist["Check treeLandNotAllowModules"]
    CheckDenylist -->|gesture in denylist| SkipGesture["Skip loading gesture module"]
    CheckDenylist -->|module not in denylist| LoadModule["Load module"]
Loading

File-Level Changes

Change Details Files
Extend Treeland module denylist to include the gesture module so it is not loaded under Treeland.
  • Add "gesture" to the treeLandNotAllowModules slice that controls which modules are disabled under Treeland
bin/dde-session-daemon/main.go
Update SPDX copyright header to reflect coverage through 2026.
  • Change the SPDX-FileCopyrightText year range from 2018-2022 to 2018-2026
bin/dde-session-daemon/main.go

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

deepin pr auto review

你好!我是CodeGeeX,你的智能编程助手。我已仔细审查了你提供的 Git Diff 输入。本次代码变更非常精简,主要涉及版权年份的更新以及 Wayland (TreeLand) 环境下黑名单模块的调整。

以下是我对本次变更的详细审查意见:

1. 语法逻辑

  • 结论:无语法错误,逻辑符合预期。
  • 分析:
    • 版权年份从 2022 更新到 2026,符合代码仓库维护的常规操作(尽管2026年是一个未来的年份,但这通常是企业为了减少频繁修改版权头而采取的前瞻性策略,逻辑上没有问题)。
    • treeLandNotAllowModules 切片中增加了 "gesture" 字符串,语法正确。从逻辑上看,在 Wayland (TreeLand) 环境下,手势管理通常由 Wayland 合成器(如 mutter, kwin 或 deepin 的 treeland)直接接管,X11/Wayland 兼容层下的手势模块可能会失效或产生冲突,将其加入黑名单禁用是合理的逻辑。

2. 代码质量

  • 结论:当前变更质量可接受,但存在可优化空间。
  • 改进建议:
    • 魔法字符串: treeLandNotAllowModules 切片中的模块名(如 "x-event-monitor", "gesture" 等)属于硬编码的魔法字符串。如果在其他包或文件中也需要校验这些模块名,容易产生不一致。
      • 建议: 建议在全局或专门的常量包中定义这些模块名,例如 const ModuleGesture = "gesture",然后在切片中使用常量。
    • 数据结构选择: 当前使用 []string 切片来存储黑名单。如果在运行时需要频繁调用类似 isInTreeLandNotAllowModule(moduleName) 的函数,使用切片的时间复杂度为 $O(N)$
      • 建议: 如果黑名单列表较长或查询频繁,建议改用 map[string]struct{}map[string]bool,将查询时间复杂度降为 $O(1)$。例如:
        var treeLandNotAllowModules = map[string]struct{}{
            "x-event-monitor": {},
            "keybinding":      {},
            "gesture":         {},
            "screensaver":     {},
            "display":         {},
            "xsettings":       {},
        }

3. 代码性能

  • 结论:对性能影响微乎其微。
  • 分析: 新增一个 "gesture" 字符串仅增加了约 16 字节的内存占用,且切片长度从 5 变为 6,对遍历性能的影响可以忽略不计。但如果按照上述代码质量建议改用 Map,则在模块启动和路由分发时的查询性能会得到理论上的提升。

4. 代码安全

  • 结论:无直接安全隐患,但需注意业务逻辑带来的潜在风险。
  • 分析与建议:
    • 输入校验: 确保 "gesture" 模块在 TreeLand 环境下被禁用后,不会导致依赖该模块的 D-Bus 接口暴露出未初始化的空指针或引发 Panic。当客户端(如前端 UI)在 TreeLand 下调用 gesture 相关的 D-Bus 方法时,应当有明确的错误返回(如 org.freedesktop.DBus.Error.ServiceUnknown 或自定义错误),而不是发生底层崩溃。
    • 权限降级: 黑名单机制本质上是功能的“降级”或“屏蔽”。需确认在屏蔽手势模块后,系统的热键或快捷手势是否依然能通过其他底层途径(如合成器直接上报)正常工作,否则可能导致用户体验受损,这属于业务安全的范畴。

总结

本次 Diff 变更本身安全且合理,主要风险在于硬编码和查询效率。如果这只是项目初期的简单维护,当前代码完全可以合并;如果项目处于长期迭代中,建议考虑将黑名单重构为 Map 结构并提取魔法字符串为常量。

如果你有 isInShutdown 函数下方关于黑名单判断的具体实现代码,我也可以为你做进一步的性能和安全性审查!

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

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.

2 participants