Skip to content

feat: adapt keyboard layout for Treeland - #1253

Merged
mhduiy merged 1 commit into
masterfrom
agent/developer/3ffd1f829e9c
Sep 18, 2026
Merged

mhduiy merged 1 commit into
masterfrom
agent/developer/3ffd1f829e9c

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Treeland 键盘布局适配

适配 Treeland 环境下的键盘布局设置,通过 dconfig 写入 treeland user seat 的 xkbLayout/xkbVariant 配置,X11 路径保留不变。

改动内容

  • 新增 treeland user seat DConfig 常量(treelandAppID/treelandSeatName/treelandKeyXkbLayout/treelandKeyXkbVariant)
  • Keyboard 结构体新增 treelandSeatConfig 字段,newKeyboard 中 hasTreeLand 分支初始化
  • applyLayout() 方法新增 hasTreeLand 分流,调用 applyLayoutTreeLand
  • 新增 applyLayoutTreeLand 方法:通过 dconfig 写入 xkbLayout/xkbVariant,复用 layout/variant 拆分与 ,us 兜底逻辑
  • applyOptions() 添加 hasTreeLand guard,避免 treeland 下执行 setxkbmap 产生噪音日志

验证

  • 编译验证通过(dde-daemon 6.1.106 amd64)
  • 单测通过
  • X11 路径不受影响

参考上游 treeland PR: linuxdeepin/treeland#1406

Multica Issue: DDE-321

Summary by Sourcery

Adapt keyboard layout handling to configure Treeland user seats without affecting X11 behavior.

New Features:

  • Support applying keyboard layouts and variants through Treeland user-seat configuration.

Enhancements:

  • Preserve the existing X11 keyboard layout path while bypassing X11 option application in Treeland environments.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@sourcery-ai

sourcery-ai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR adapts keyboard layout updates for Treeland by initializing a user-seat DConfig client and writing xkbLayout/xkbVariant values, while preserving the existing X11 behavior and avoiding unsupported setxkbmap option calls in Treeland.

Sequence diagram for Treeland keyboard layout application

sequenceDiagram
    participant Keyboard
    participant TreelandSeatConfig as TreelandUserSeatDConfig

    Keyboard->>Keyboard: applyLayout()
    alt hasTreeLand
        Keyboard->>Keyboard: applyLayoutTreeLand(value)
        Keyboard->>TreelandSeatConfig: SetValue(xkbLayout, layout)
        Keyboard->>TreelandSeatConfig: SetValue(xkbVariant, variant)
    else X11
        Keyboard->>Keyboard: applyLayout(value)
    end
Loading

Flow diagram for Treeland keyboard initialization and options handling

flowchart TD
    Start[newKeyboard]
    Environment{hasTreeLand}
    X11[Initialize X connection]
    Treeland[NewDConfig treeland user seat]
    Layout[applyLayout]
    Options[applyOptions]
    Skip[Skip setxkbmap options]

    Start --> Environment
    Environment -->|false| X11
    Environment -->|true| Treeland
    X11 --> Layout
    Treeland --> Layout
    Layout --> Options
    Options -->|hasTreeLand| Skip
    Options -->|X11| SetOptions[Apply setxkbmap options]
Loading

File-Level Changes

Change Details Files
Add Treeland user-seat DConfig support for applying keyboard layouts and variants.
  • Define Treeland app, seat, and xkb configuration keys.
  • Initialize a Treeland seat DConfig client when running outside the X11 path.
  • Split layout and variant values, preserve the existing fallback to a US layout, and write them to DConfig with nil/error handling.
inputdevices1/keyboard.go
Route keyboard application behavior according to the active display environment.
  • Dispatch layout updates to the Treeland DConfig implementation when Treeland is detected.
  • Skip X11-only keyboard option application under Treeland.
  • Keep the existing setxkbmap layout and option paths unchanged for X11.
inputdevices1/keyboard.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

@mhduiy
mhduiy force-pushed the agent/developer/3ffd1f829e9c branch from 4b5113b to 8f1b4aa Compare September 17, 2026 08:42
适配 Treeland 键盘布局

1. 新增 treeland user seat DConfig 常量(treelandAppID/treelandSeatName/treelandKeyXkbLayout/treelandKeyXkbVariant)
2. Keyboard 结构体新增 treelandSeatConfig 字段,newKeyboard 中 hasTreeLand 分支初始化
3. applyLayout() 方法新增 hasTreeLand 分流,调用 applyLayoutTreeLand
4. 新增 applyLayoutTreeLand 方法:通过 dconfig 写入 xkbLayout/xkbVariant,复用 layout/variant 拆分与 ,us 兜底逻辑
5. applyOptions() 添加 hasTreeLand guard,避免 treeland 下执行 setxkbmap 产生噪音日志
6. applyLayoutTreeLand 中两次 SetValue 添加已知行为注释

PMS: BUG-377251
Log: 适配 Treeland 键盘布局,通过 dconfig 写入 treeland user seat 的 xkbLayout/xkbVariant 配置
Influence: inputdevices1 键盘布局设置在 Treeland 环境下走 dconfig 路径,X11 路径不受影响
@mhduiy
mhduiy force-pushed the agent/developer/3ffd1f829e9c branch from 8f1b4aa to 6c62c64 Compare September 17, 2026 08:49
@mhduiy
mhduiy marked this pull request as ready for review September 17, 2026 08:49

@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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="inputdevices1/keyboard.go" line_range="305-308" />
<code_context>
 	currentLayout := kbd.CurrentLayout.Get()
 	kbd.PropsMu.RUnlock()

+	if hasTreeLand {
+		kbd.applyLayoutTreeLand(currentLayout)
+		return
+	}
+
 	err := applyLayout(currentLayout)
</code_context>
<issue_to_address>
**issue (broader_impact):** Every Wayland session is treated as Treeland because `hasTreeLand` is set solely from `XDG_SESSION_TYPE=wayland`; on a non-Treeland Wayland compositor, `applyLayoutTreeLand` tries to write the Treeland DConfig instead of applying the layout, so layout changes are ignored when that manager is unavailable.

**Triggers:** When dde-daemon runs under a non-Treeland Wayland compositor.

**Suggested fix:** Detect the Treeland compositor specifically before selecting the Treeland DConfig path, or retain the existing layout path for other Wayland environments.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread inputdevices1/keyboard.go
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602, 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 bc2807c into master Sep 18, 2026
23 of 25 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