Skip to content

feat: add shortcut capture protocol support#897

Merged
zccrs merged 3 commits into
linuxdeepin:masterfrom
wineee:key
May 27, 2026
Merged

feat: add shortcut capture protocol support#897
zccrs merged 3 commits into
linuxdeepin:masterfrom
wineee:key

Conversation

@wineee
Copy link
Copy Markdown
Member

@wineee wineee commented May 26, 2026

  1. Implement treeland_shortcut_capture_v1 protocol for one-shot shortcut
    capture
  2. Add isPureModifierKey() to identify pure modifier keys (excluding
    Super/Meta)
  3. Add isValidShortcutCombo() mirroring dde-daemon's IsGood() validation
    logic
  4. Add ShortcutCaptureV1 class to manage capture session lifecycle
  5. Integrate capture event handling in Helper::beforeDisposeEvent()
  6. Bump protocol version from 1 to 2 to include new capture
    functionality
  7. Validate surface ownership and focus state before allowing capture

Log: Added shortcut capture feature allowing clients to request key
combination input

Influence:

  1. Test capturing valid shortcuts like Ctrl+A, Alt+F4, F1-F12
  2. Verify Win/Super key alone is captured as "Meta"
  3. Test that pure modifier releases (Ctrl alone) fail the capture
  4. Verify pointer clicks or wheel events cancel pending capture
  5. Test capture rejection when surface is not focused/active
  6. Test capture rejection when surface belongs to different client
  7. Verify only one capture session can be active at a time
  8. Test Shift+special keys like Shift+Tab, Shift+Escape
  9. Test media keys capture without modifiers
  10. Verify auto-repeat key events are consumed silently

@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

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.

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

Please try again later or upgrade to continue using Sourcery

@wineee wineee changed the title fix: apply xwayland relative position reliably feat: add shortcut capture protocol support May 26, 2026
@wineee wineee requested a review from Copilot May 26, 2026 09:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

EN: This PR adds one-shot shortcut capture support to Treeland’s shortcut manager flow, allowing Wayland clients to request the next valid key combination and receive either a captured shortcut string or a failure reason. The implementation hooks capture handling into the seat event-dispose path and introduces validation logic to determine which key combinations are considered capturable.

**中文:**该 PR 为 Treeland 增加“一次性快捷键捕获”能力,使 Wayland 客户端可以请求捕获下一次有效的按键组合,并收到捕获结果(字符串)或失败原因。实现上将捕获逻辑接入 seat 的事件分发/释放前阶段,并新增按键组合的有效性判定规则。

Changes:

  • Add a shortcut capture session object and lifecycle/state management in ShortcutManagerV2.
  • Implement shortcut validity checks (pure-modifier detection + “good shortcut” rules) for capture.
  • Integrate capture-event interception into Helper::beforeDisposeEvent() so capture can consume/cancel relevant input events.

Reviewed changes

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

File Description
src/seat/helper.cpp Routes pending-capture input events to the shortcut manager before normal shortcut dispatch.
src/modules/shortcut/shortcutmanager.h Exposes capture state + event handling entry points on ShortcutManagerV2.
src/modules/shortcut/shortcutmanager.cpp Implements capture protocol handling, capture session state machine, and shortcut validation rules.

Comment thread src/modules/shortcut/shortcutmanager.h
Comment thread src/modules/shortcut/shortcutmanager.h
Comment thread src/modules/shortcut/shortcutmanager.cpp
Comment thread src/modules/shortcut/shortcutmanager.cpp Outdated
Comment thread src/modules/shortcut/shortcutmanager.cpp
Comment thread src/modules/shortcut/shortcutmanager.cpp Outdated
@wineee wineee force-pushed the key branch 3 times, most recently from c83f2bf to 0868ba2 Compare May 26, 2026 13:24
Comment thread examples/test_shortcut_capture/main.cpp Outdated
@wineee wineee force-pushed the key branch 4 times, most recently from 7b38cff to 06cc59c Compare May 27, 2026 03:47
@wineee wineee marked this pull request as ready for review May 27, 2026 04:21
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.

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

Please try again later or upgrade to continue using Sourcery

@wineee wineee force-pushed the key branch 2 times, most recently from 278da82 to be781f3 Compare May 27, 2026 05:04
Comment thread src/modules/shortcut/shortcutmanager.cpp Outdated
@wineee wineee force-pushed the key branch 2 times, most recently from 1f6f6a9 to d915bdd Compare May 27, 2026 05:46
wineee added 3 commits May 27, 2026 14:22
1. Add test_shortcut_capture example directory and CMakeLists.txt
configuration
2. Implement ShortcutCapture wrapper class for
treeland_shortcut_capture_v1 Wayland protocol
3. Implement ShortcutManagerV2 class to handle protocol initialization
and capture requests
4. Create simple UI with button to trigger one-shot shortcut capture and
status label
5. Handle capture success event and various failure reasons including
busy, aborted, not_active, and interrupted

Influence:
1. Verify the example application builds successfully with Qt6 and
required Wayland components
2. Test application launch under a Wayland compositor supporting
treeland-shortcut-manager-v2
1. Implement treeland_shortcut_capture_v1 protocol for one-shot shortcut
capture
2. Add isPureModifierKey() to identify pure modifier keys (excluding
Super/Meta)
3. Add isValidShortcutCombo() mirroring dde-daemon's IsGood() validation
logic
4. Add ShortcutCaptureV1 class to manage capture session lifecycle
5. Integrate capture event handling in Helper::beforeDisposeEvent()
6. Validate surface ownership and focus state before allowing capture

Log: Added shortcut capture feature allowing clients to request key
combination input

Influence:
1. Test capturing valid shortcuts like Ctrl+A, Alt+F4, F1-F12
2. Verify Win/Super key alone is captured as "Meta"
3. Test that pure modifier releases (Ctrl alone) fail the capture
4. Verify pointer clicks or wheel events cancel pending capture
5. Test capture rejection when surface is not focused/active
6. Test capture rejection when surface belongs to different client
7. Verify only one capture session can be active at a time
8. Test Shift+special keys like Shift+Tab, Shift+Escape
9. Test media keys capture without modifiers
10. Verify auto-repeat key events are consumed silently
1. Replace preprocessor macros with static constexpr int for Wayland
protocol version constants
2. Move InterfaceVersion definitions to public class headers for better
encapsulation
@deepin-ci-robot
Copy link
Copy Markdown

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

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 e22660a into linuxdeepin:master May 27, 2026
9 checks passed
@wineee wineee deleted the key branch May 27, 2026 08:28
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.

4 participants