Skip to content

feat: add treeland-input-manager-unstable-v1 protocol - #57

Merged
zccrs merged 1 commit into
linuxdeepin:masterfrom
zzxyb:input
May 27, 2026
Merged

feat: add treeland-input-manager-unstable-v1 protocol#57
zccrs merged 1 commit into
linuxdeepin:masterfrom
zzxyb:input

Conversation

@zzxyb

@zzxyb zzxyb commented May 14, 2026

Copy link
Copy Markdown
Contributor

Introduce a new Wayland protocol, treeland_input_manager_v1, to allow
privileged clients to configure compositor-managed input devices.

@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

@wineee
wineee requested a review from Copilot May 14, 2026 12:36
@18202781743

Copy link
Copy Markdown
Contributor

@copilot review下这个pr,

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

Pull request overview

This PR introduces a new Wayland protocol definition (treeland_input_manager_unstable_v1) for privileged clients to discover per-seat input capabilities and apply batched (atomic) settings for pointer, mouse, touchpad, and keyboard devices in the treeland compositor environment.

Changes:

  • Added a new unstable protocol XML defining treeland_input_manager_v1 plus settings interfaces for pointer/mouse/touchpad/keyboard.
  • Wired the new XML into the install list via CMakeLists.txt.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
xml/treeland-input-manager-unstable-v1.xml New protocol specification for compositor-managed input device configuration (capabilities + per-device settings objects + apply model).
CMakeLists.txt Installs the new protocol XML with the rest of the protocol set.
Comments suppressed due to low confidence (2)

xml/treeland-input-manager-unstable-v1.xml:139

  • wl_keyboard is not a global object (it is created from wl_seat.get_keyboard), so “wl_keyboard global is removed” is misleading/incorrect. Please reword this example to match Wayland object lifetimes (e.g., seat removed, client destroys wl_keyboard, or the server destroys the object).
            <arg name="keyboard" type="object" interface="wl_keyboard"
                 summary="keyboard object identifying the target keyboard"/>
        </request>

xml/treeland-input-manager-unstable-v1.xml:171

  • This sentence is unclear/grammatically incorrect: “treeland_pointer_settings_v1 creating just one is enough.” Please rephrase so it clearly states what the client should do (e.g., that one pointer settings object per seat is sufficient).
            </description>
            <arg name="type" type="uint" enum="treeland_input_manager_v1.device_type"
                 summary="type of the device capability"/>
            <arg name="seat" type="object" interface="wl_seat"
                 summary="seat associated with the capability"/>
        </event>

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread xml/treeland-input-manager-unstable-v1.xml Outdated
Comment thread xml/treeland-input-manager-unstable-v1.xml Outdated
Comment thread xml/treeland-input-manager-unstable-v1.xml
@zzxyb
zzxyb force-pushed the input branch 2 times, most recently from 8241da1 to 0a8adc7 Compare May 15, 2026 01:54
@zzxyb zzxyb changed the title feat: add treeland_input_manager_unstable_v1 protocol feat: add treeland-input-manager-unstable-v1 protocol May 15, 2026
@wineee
wineee requested a review from Copilot May 15, 2026 02:12

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (3)

xml/treeland-input-manager-unstable-v1.xml:743

  • Grammar issue in the interface description: "settings for all keyboard associated with the target seat" should be plural (e.g., "all keyboards" / "all keyboard devices").
        <description summary="keyboard settings object">
            The treeland_keyboard_settings_v1 interface represents pending
            settings for all keyboard associated with the target seat.

xml/treeland-input-manager-unstable-v1.xml:271

  • set_speed doesn’t define the valid range/interpretation of the fixed-point speed value (e.g., libinput typically uses a bounded range) or what happens for out-of-range inputs. Please document the range/behavior so clients can safely set speed without relying on compositor-specific behavior.
        <request name="set_speed">
            <description summary="set the pointer speed">
                Set the pointer motion speed. The change takes effect on the
                next apply request.

                This request updates only the pending state tracked by this
                object. Sending this request, or the following apply request,
                does not by itself cause a speed event to be emitted.
            </description>
            <arg name="speed" type="fixed" summary="desired pointer motion speed"/>
        </request>

xml/treeland-input-manager-unstable-v1.xml:782

  • set_repeat uses signed ints for rate/delay but the protocol doesn’t specify whether negative values are allowed, and what the compositor does for invalid inputs (protocol error vs clamp). Please document the accepted ranges and behavior to avoid clients guessing.
        <request name="set_repeat">
            <description summary="set keyboard repeat rate and delay">
                Set the keyboard repeat rate and delay to apply on the next
                apply request.

                This request updates only the pending state tracked by this
                object. Sending this request, or the following apply request,
                does not by itself cause a repeat event to be emitted.
            </description>
            <arg name="rate" type="int"
                 summary="repeat rate in characters per second"/>
            <arg name="delay" type="int"
                 summary="delay in milliseconds before repeating starts"/>
        </request>

Comment thread xml/treeland-input-manager-unstable-v1.xml
Comment thread xml/treeland-input-manager-unstable-v1.xml
Comment thread xml/treeland-input-manager-unstable-v1.xml
Comment thread xml/treeland-input-manager-unstable-v1.xml Outdated
Comment thread xml/treeland-input-manager-unstable-v1.xml Outdated
Comment thread xml/treeland-input-manager-unstable-v1.xml Outdated
@zzxyb
zzxyb force-pushed the input branch 4 times, most recently from fd2953d to f903195 Compare May 20, 2026 09:20
@zzxyb
zzxyb marked this pull request as ready for review May 21, 2026 06:15
@zzxyb
zzxyb force-pushed the input branch 2 times, most recently from ca7e713 to 3be5963 Compare May 21, 2026 07:52
@zzxyb
zzxyb requested a review from wineee May 21, 2026 07:55
wineee
wineee previously requested changes May 21, 2026
Comment thread xml/treeland-input-manager-unstable-v1.xml
Comment thread xml/treeland-input-manager-unstable-v1.xml
Comment thread xml/treeland-input-manager-unstable-v1.xml Outdated
@deepin-bot

deepin-bot Bot commented May 22, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.5.7
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #60

@zzxyb
zzxyb force-pushed the input branch 2 times, most recently from 94f7b50 to cc9940e Compare May 23, 2026 06:03
Comment thread xml/treeland-input-manager-unstable-v1.xml Outdated
Comment thread xml/treeland-input-manager-unstable-v1.xml
Comment thread xml/treeland-input-manager-unstable-v1.xml Outdated
Comment thread xml/treeland-input-manager-unstable-v1.xml
@zzxyb
zzxyb requested a review from zccrs May 25, 2026 03:31
@zzxyb
zzxyb force-pushed the input branch 2 times, most recently from 6943cb1 to 8b1832c Compare May 25, 2026 08:01
@zzxyb
zzxyb requested a review from Groveer May 26, 2026 07:49
@zzxyb
zzxyb marked this pull request as draft May 26, 2026 09:43
Introduce a new Wayland protocol, treeland_input_manager_v1, to allow
privileged clients to configure compositor-managed input devices.

Key design features:
- Capability-based: Compositor advertises mouse/touchpad/keyboard availability
  via capability events.
- Atomic configuration: Uses a "request-apply" model where settings are
  batched and applied via an explicit apply request.
- Multi-seat support: Settings objects are bound to specific wl_seat.

This protocol enables fine-grained control over input peripheral behavior
within the treeland compositor environment.

Log: Added treeland-input-manager-unstable-v1.xml.
Tasks: https://pms.uniontech.com/task-view-389477.html

Influence:
1.Impacts how system settings applications interact with input hardware.
@zzxyb
zzxyb marked this pull request as ready for review May 26, 2026 11:39
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

你好!我是CodeGeeX。我已经仔细审查了你提供的 Wayland 协议 XML 文件及 CMakeLists.txt 的变更。

总体而言,这份协议设计得相当专业,采用了目前 Wayland 社区推荐的“双缓冲/状态累积+apply”模式来配置输入设备,避免了状态闪烁,并且通过 feature 事件实现了特性的动态发现。不过,从协议语义的严谨性、逻辑完整性以及安全性角度来看,还有以下几个关键地方需要改进:

1. 逻辑与协议语义

  • acceleration_profile 枚举不应为 bitfield
    treeland_pointer_device_configuration_v1 接口中,acceleration_profile 被声明为 bitfield="true"。从逻辑上看,一个设备的加速配置在同一时刻只能处于一种模式(要么 flat,要么 adaptive,要么 custom),不可能同时应用两种加速曲线。将其设为位域会导致客户端可以发送 3 (flat | adaptive) 这种毫无意义的组合。
    建议:移除 bitfield="true",将其改为普通的互斥枚举。如果 none 表示“不支持配置”,建议直接通过 feature 事件来控制,而不是作为一个 profile 值。
  • capability_unavailable 缺少强制销毁机制
    当设备被拔出时,合成器发送 capability_unavailable,描述中写道“客户端必须销毁对应的 settings 对象”。但在 Wayland 协议中,如果客户端没有遵守“必须”销毁的规定,合成器缺乏后手。
    建议:补充说明:“如果客户端在收到此事件后未销毁对应的对象,合成器应发送协议错误”。或者,合成器可以直接在服务端强制销毁这些对象并发放相应的 error 事件,以防资源泄漏和悬挂指针。
  • treeland_keyboard_settings_v1done 事件缺少 serial
    treeland_pointer_device_configuration_v1 中,done 事件携带了 serial,用于客户端在下次 get_pointer_configuration 时进行状态同步校验。但是,treeland_keyboard_settings_v1done 事件却没有 serial 参数,这破坏了协议设计的一致性,也导致键盘配置无法进行防回滚校验。
    建议:为 treeland_keyboard_settings_v1done 事件添加 serial 参数。

2. 安全性

  • 输入参数边界校验缺失(DoS 风险)
    协议中大量使用了 fixedint 类型,但未在描述中规定合法的取值范围。
    • set_scroll_factor:如果客户端传入负数或极大的值(如 -100 或 1e9),会导致 UI 滚动行为异常甚至崩溃。
    • set_accel_speed:libinput 的加速速度通常限制在 [-1, 1] 之间,如果允许任意 fixed 值,可能导致越界。
    • set_repeatratedelay 如果为负数,或者极大,会导致内核或合成器在处理按键重复时出现死循环或崩溃。
      建议:在对应的 request 描述中明确取值范围。例如:“The factor must be greater than 0, otherwise a invalid_factor protocol error is raised”;“Rate must be non-negative”。

3. 代码质量与一致性

  • 状态枚举复用导致语义模糊
    treeland_input_manager_v1::state (disabled: 0, enabled: 1) 被复用在了 natural_scroll, disable_while_typing, tap_to_click 上。虽然逻辑上说得通,但“disable_while_typing”的“enabled”表示“开启打字时禁用触控板”,这种双重否定容易让实现者绕晕。
    建议:这目前是可以接受的,但建议在实现代码中使用具有强类型提示的枚举类(如 C++ 的 enum class)来映射,并加上详尽的注释,避免逻辑反转错误。
  • failed 事件过于模糊
    treeland_pointer_device_configuration_v1treeland_keyboard_settings_v1 都有 failed 事件,但没有告知客户端为什么失败(是权限不足?值越界?还是设备已被移除?)。
    建议:为 failed 事件增加一个 enum 类型的参数来指示失败原因,这有助于客户端进行 UI 提示或降级处理。
  • 版权年份拼写错误
    SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
    这里的年份是 2026,通常应为作品创作的年份(如 2023, 2024)。
    建议:修正为当前实际年份。

4. 性能

  • Wayland 协议解析性能(CMake 侧)
    CMake 中将 xml 文件加入 XML 变量并安装是常规操作,性能没有问题。但需注意,如果这些 XML 参与了 wayland_add_protocol_server 或类似的代码生成过程,每次修改 XML 都会触发大量源文件重编译。
    建议:确保协议 XML 的生成目标只被实际依赖它的库/可执行文件链接,避免不必要的全局重编译。

修改建议示例(针对 XML 关键部分)

<!-- 1. 修正 acceleration_profile 枚举 -->
<enum name="acceleration_profile"> <!-- 移除 bitfield="true" -->
    <entry name="flat" value="1" summary="use a flat acceleration profile"/>
    <entry name="adaptive" value="2" summary="use an adaptive acceleration profile"/>
    <entry name="custom" value="3" summary="use a custom acceleration profile"/>
</enum>

<!-- 2. 为 set_scroll_factor 增加安全约束描述 -->
<request name="set_scroll_factor">
    <description summary="set the scroll delta scaling factor">
        ...
        The factor must be strictly greater than zero. If a non-positive factor
        is provided, the compositor will raise the invalid_scroll_factor protocol error.
    </description>
    <arg name="factor" type="fixed" summary="scaling factor applied to scroll axis deltas"/>
</request>

<!-- 3. 为 keyboard 的 done 事件补充 serial -->
<event name="done">
    <description summary="end of a keyboard state batch">
        ...
    </description>
    <arg name="serial" type="uint" summary="current configuration serial"/>
</event>

<!-- 4. 修正版权年份 -->
<copyright><![CDATA[
    SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
    SPDX-License-Identifier: MIT
]]></copyright>

综上所述,协议整体架构优秀,但在边界条件限制、枚举类型定义的严谨性上需要进一步打磨,以防止恶意或编写不佳的客户端利用协议漏洞攻击合成器。

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zccrs, zzxyb

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

@zccrs
zccrs merged commit 6456001 into linuxdeepin:master May 27, 2026
3 of 4 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.

6 participants