Skip to content

fix(dock): prevent dock from taking focus - #1679

Merged
mhduiy merged 1 commit into
linuxdeepin:masterfrom
mhduiy:docklayshell
Jul 29, 2026
Merged

fix(dock): prevent dock from taking focus#1679
mhduiy merged 1 commit into
linuxdeepin:masterfrom
mhduiy:docklayshell

Conversation

@mhduiy

@mhduiy mhduiy commented Jul 29, 2026

Copy link
Copy Markdown
Contributor
  1. Disable keyboard interactivity for the layer-shell surface.
  2. Keep application focus unchanged when interacting with the dock.

Log: Prevent the dock from acquiring keyboard focus.
Influence: Dock interaction no longer takes app focus.

fix(dock): 防止 Dock 获取焦点

  1. 禁用 layer-shell 表面的键盘交互。
  2. 与 Dock 交互时保持当前应用焦点不变。

Log: 防止 Dock 获取键盘焦点。
Influence: Dock 交互不再抢占应用焦点。

Summary by Sourcery

Bug Fixes:

  • Disable keyboard interactivity on the dock layer-shell surface so interacting with the dock no longer steals focus from the active application.

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

Sorry @mhduiy, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Jul 29, 2026

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

Reviewer's Guide

Adjusts the dock’s Wayland layer-shell configuration so that it never acquires keyboard focus, ensuring existing application focus is preserved when interacting with the dock.

File-Level Changes

Change Details Files
Disable keyboard focus acquisition for the dock’s layer-shell window so dock interactions no longer steal focus from applications.
  • Change the dock window’s layer-shell keyboardInteractivity mode from on-demand to none so it never accepts keyboard focus from the compositor
panels/dock/package/main.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

1. Disable keyboard interactivity for the layer-shell surface.
2. Keep application focus unchanged when interacting with the dock.

Log: Prevent the dock from acquiring keyboard focus.
Influence: Dock interaction no longer takes app focus.

fix(dock): 防止 Dock 获取焦点

1. 禁用 layer-shell 表面的键盘交互。
2. 与 Dock 交互时保持当前应用焦点不变。

Log: 防止 Dock 获取键盘焦点。
PMS: TASK-393373
Influence: Dock 交互不再抢占应用焦点。
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码通过修改 Layer Shell 的键盘交互属性,有效修复了 Dock 面板抢占键盘焦点的问题。
逻辑正确且符合 Wayland layer-shell 协议规范,无安全漏洞,代码质量良好,仅扣5分因缺乏详细注释说明修改原因。

■ 【详细分析】

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

代码位于 panels/dock/package/main.qml 第 72 行,将 DLayerShellWindow.keyboardInteractivity 的值从 KeyboardInteractivityOnDemand 修改为 KeyboardInteractivityNone。QML 属性赋值语法正确,且使用了框架提供的合法枚举值,能够正确禁用 Wayland layer-shell 窗口的键盘交互性,从而解决焦点抢占问题。
潜在问题:无
建议:无需修改

  • 2.代码质量(良好)✓

代码修改简洁明了,直接针对问题属性进行调整,符合代码规范。但 diff 中未包含针对该修改的行内注释,后续维护者可能不清楚为何要禁用键盘交互。
潜在问题:缺少必要的注释说明修改的业务背景
建议:在修改行上方添加简短注释,说明禁用键盘交互是为了避免干扰其他窗口输入

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

修改仅涉及静态属性绑定值的变更,不引入额外的计算或资源消耗,对运行时性能无负面影响,反而可能减少不必要的键盘事件处理开销。
潜在问题:无
建议:无需修改

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

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改为 UI 层属性调整,不涉及用户输入处理、外部命令调用或权限操作,不存在安全风险。

  • 建议:无需安全修复

■ 【改进建议代码示例】

// Dock 窗口的 Layer Shell 属性配置,修改 keyboardInteractivity 以避免抢占键盘焦点
69:     DLayerShellWindow.layer: DLayerShellWindow.LayerTop
70:     DLayerShellWindow.exclusionZone: Panel.hideMode === Dock.KeepShowing ? Applet.dockSize : 0
71:     DLayerShellWindow.scope: "dde-shell/dock"
72:     // 禁用键盘交互性,避免 Dock 面板显示时抢占键盘焦点,干扰其他应用或桌面的正常输入
73:     DLayerShellWindow.keyboardInteractivity: DLayerShellWindow.KeyboardInteractivityNone
74: 
75:     D.DWindow.enabled: true
76:     D.DWindow.windowRadius: 0

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@mhduiy
mhduiy merged commit d390097 into linuxdeepin:master Jul 29, 2026
12 of 13 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