feat: add one-shot shortcut capture interface#63
Conversation
|
Skipping CI for Draft Pull Request. |
There was a problem hiding this comment.
Pull request overview
This PR extends the treeland_shortcut_manager_v2 Wayland protocol by adding a one-shot shortcut capture flow, enabling clients to request capture of the next shortcut input once (scoped to a specific wl_surface) with explicit cancellation reasons.
Changes:
- Bumped
treeland_shortcut_manager_v2interface version from 1 to 2 and added a new protocol errorinvalid_surface(since v2). - Added
capture_next_keyrequest (since v2) to create a one-shot capture object bound to a provided surface. - Introduced new
treeland_shortcut_capture_v1interface withcaptured/cancelledterminal events and cancellation reasons.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ed785b2 to
e67313a
Compare
15508dd to
94ab58d
Compare
Added the treeland_shortcut_capture_v1 interface and a new capture_next_key request to treeland_shortcut_manager_v2. The protocol version is bumped to 2. The new request allows clients to capture the next shortcut input once, bound to a specific wl_surface. The compositor validates surface activity/focus and only captures valid shortcut key releases; otherwise, it cancels with a detailed reason. This change enables more interactive and user-friendly shortcut configuration workflows, while ensuring protocol safety and clear error signaling. 增加了 treeland_shortcut_capture_v1 接口,并为 treeland_shortcut_manager_v2 添加了新的 capture_next_key 请求,协议版本 提升到 2。新请求允许客户端绑定特定 wl_surface 后一次性捕获下一个快捷键输 入。合成器会验证 surface 的活动或焦点状态,仅当捕获到有效的快捷键释放时 才发送 captured 事件,否则会以详细原因取消。这一改动提升了快捷键配置的交 互性和用户友好性,同时确保协议安全和清晰的错误信号。
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提供的 Wayland 协议 XML 文件的 整体来看,协议的设计逻辑比较清晰,状态机定义也较为明确。但在语法规范、逻辑严谨性、代码质量和安全性方面,我有一些改进建议,请参考: 1. 语法与规范
2. 逻辑严谨性
3. 代码质量与可维护性
4. 安全性
改进后的 XML 片段建议参考:针对上述部分问题,我为你修改了 <request name="capture_next_shortcut" since="2">
<description summary="capture the next shortcut once">
Request the compositor to capture the next shortcut input once,
bound to the provided surface.
The capture object is created by this request via new_id.
The compositor performs validation after receiving the request,
and may immediately emit a terminal event on the newly created object.
Clients must be prepared to handle a capture object that is
failed immediately after creation.
The surface argument must be a wl_surface owned by the requesting client.
Otherwise, the compositor will raise the `invalid_surface` protocol error.
If the surface ID is invalid or already destroyed, the compositor
should handle it as a Wayland core object violation.
The compositor must verify that the provided surface currently has
keyboard focus or is active at the moment the compositor processes
this request. If this check fails, the compositor must emit `failed`
with reason `not_active` on the created object.
The compositor monitors both key_press and key_release events during
capture. The shortcut candidate is established on key_press of a valid
non-modifier key; the terminal event (captured or failed) is sent on
key_release of that non-modifier key. Pure modifier-only key presses
(e.g. Ctrl, Alt, Shift) are silently consumed while waiting for a
non-modifier key. Auto-repeat events are consumed and ignored.
If the capture is cancelled, interrupted, or the object is destroyed
while modifier keys are physically held down, the compositor must
ensure the client's keyboard state remains consistent, for example
by synthesizing key release events or resuming normal event delivery
for those modifiers.
If the next intercepted input is not a valid shortcut input
(for example: unmodified alphanumeric keys such as a, b, c, d,
1, 2, 3, unmodified Escape, or pointer button and wheel events),
the compositor must fail capture with reason `interrupted`.
For either `interrupted` failure or successful `captured`,
the triggering input event must be consumed by the compositor
and must not be forwarded to the client.
The compositor creates a treeland_shortcut_capture_v1 object and starts
a one-shot capture flow for this request.
To prevent resource exhaustion, the compositor may emit `failed`
with reason `busy` if the client requests a capture while a
pending capture from the same client already exists.
This request does not modify existing shortcut bindings.
This request does not require acquire.
</description>
<arg name="surface" type="object" interface="wl_surface"
summary="surface used for focus or active validation"/>
<arg name="seat" type="object" interface="wl_seat" allow-null="true"
summary="seat to capture from, or null to capture from any seat. Must be a valid seat owned by the client if non-null"/>
<arg name="capture" type="new_id" interface="treeland_shortcut_capture_v1"
summary="one-shot capture object"/>
</request>希望这些建议能帮助你完善 Wayland 协议的设计!如果有任何疑问,欢迎继续探讨。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wineee, zccrs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Added the treeland_shortcut_capture_v1 interface and a new
capture_next_key request to treeland_shortcut_manager_v2. The protocol
version is bumped to 2. The new request allows clients to capture the
next shortcut input once, bound to a specific wl_surface. The compositor
validates surface activity/focus and only captures valid shortcut key
releases; otherwise, it cancels with a detailed reason. This change
enables more interactive and user-friendly shortcut configuration
workflows, while ensuring protocol safety and clear error signaling.
增加了 treeland_shortcut_capture_v1 接口,并为
treeland_shortcut_manager_v2 添加了新的 capture_next_key 请求,协议版本
提升到 2。新请求允许客户端绑定特定 wl_surface 后一次性捕获下一个快捷键输
入。合成器会验证 surface 的活动或焦点状态,仅当捕获到有效的快捷键释放时
才发送 captured 事件,否则会以详细原因取消。这一改动提升了快捷键配置的交
互性和用户友好性,同时确保协议安全和清晰的错误信号。