Skip to content

feat(shortcut): migrate treeland-shortcut-manager v2 → v3 - #1387

Draft
deepin-wm wants to merge 2 commits into
linuxdeepin:masterfrom
deepin-wm:shortcut-v2-to-v3
Draft

feat(shortcut): migrate treeland-shortcut-manager v2 → v3#1387
deepin-wm wants to merge 2 commits into
linuxdeepin:masterfrom
deepin-wm:shortcut-v2-to-v3

Conversation

@deepin-wm

@deepin-wm deepin-wm commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

概述

适配 treeland 的 shortcut 模块到 treeland-protocols 0.6.0 的 breaking 变更,将 treeland-shortcut-manager 从 v2 迁移到 v3。

变更内容

  • 接口重命名treeland_shortcut_manager_v2_v3treeland_shortcut_capture_v2_v3
  • action 枚举重新编号:notify=0(原 1),所有条目下移 1
  • 移除 commit 机制commit 请求、commit_success/commit_failure 事件、error.invalid_commit 全部删除
  • 新增 bind_failure 事件:逐绑定反馈失败,不再回滚同批次其他绑定
  • bind 立即生效:活跃会话立即绑定,非活跃会话延迟到激活时逐条生效
  • error 枚举调整invalid_surface 从 4→3,移除 invalid_commit
  • 接口版本重置为 1,移除所有 since 属性
  • 修复既有 bugunbind 现从 m_shortcuts 映射中移除;移除 onSessionChanged 中的 early return

测试

  • 更新 tests/protocols/ 下 desktop-v3 和基础 v3 两个 fixture,覆盖 capture→captured、即时 bind_key→activated、acquire、bind_key 成功/upsert/name_conflict 等链路
  • 更新 examples/test_shortcut_managerexamples/test_shortcut_capture 示例代码,移除 commit 逻辑

关联

Summary by Sourcery

Migrate Treeland shortcut management from protocol v2 to v3 and adopt immediate, per-binding registration semantics.

New Features:

  • Migrate the shortcut manager and shortcut capture interfaces to protocol v3 with version 1 globals and renumbered action and error enums.
  • Apply bindings immediately for active sessions and report individual binding errors through the new bind_failure event.
  • Support deferred binding and unbinding across session activation while preserving accepted per-session shortcuts.

Bug Fixes:

  • Ensure unbind removes shortcuts from the per-session shortcut map and allow session changes to continue processing restored and pending shortcuts.

Enhancements:

  • Change key binding registration to support upserts for existing key/action triggers while retaining name-conflict validation.
  • Remove the commit-based batch registration workflow and its associated success, failure, and invalid-commit handling.

Build:

  • Update server and example builds to generate and consume the unstable shortcut manager v3 protocol.

Documentation:

  • Update shortcut protocol test documentation and coverage descriptions for v3 behavior.

Tests:

  • Rename and update shortcut manager protocol fixtures to validate immediate binding, upsert behavior, name conflicts, bind failures, capture, and activation.

Chores:

  • Update shortcut manager integration, unit tests, and examples to use the v3 interface.

- Rename interface classes: ShortcutManagerV2→V3, ShortcutCaptureV1→V3
- Update protocol XML reference to treeland-shortcut-manager-unstable-v3.xml
- Shift ShortcutAction enum values down by 1 (notify 1→0, etc.)
- Remove commit mechanism (commit request, commit_success/failure events,
  error.invalid_commit, m_pendingCommittedShortcuts)
- Add bind_failure event: per-binding failure reporting on immediate bind
- Binds take effect immediately for active sessions; deferred for inactive
- Update InterfaceVersion to 1 (v3 protocol resets version)
- Fix pre-existing bug: unbind now removes from m_shortcuts map
- Update all tests, examples, and helper references for v3

- 重命名接口类:ShortcutManagerV2→V3、ShortcutCaptureV1→V3
- 更新协议 XML 引用为 treeland-shortcut-manager-unstable-v3.xml
- ShortcutAction 枚举值整体下移 1(notify 1→0 等)
- 移除 commit 机制(commit 请求、commit_success/failure 事件、
  error.invalid_commit、m_pendingCommittedShortcuts)
- 新增 bind_failure 事件:即时绑定时逐条反馈失败
- 绑定对活跃会话立即生效,非活跃会话延迟到激活时生效
- InterfaceVersion 更新为 1(v3 协议重置版本号)
- 修复既有 bug:unbind 现从 m_shortcuts 映射中移除
- 更新所有测试、示例和 helper 引用为 v3

Log: 适配 shortcut 模块到 treeland-protocols 0.6.0 的 v3 协议
Influence: shortcut 模块从 v2 迁移到 v3,移除 commit 机制,绑定改为
即时生效并新增逐条 bind_failure 反馈,影响快捷键注册与绑定流程。
@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

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-wm

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

@sourcery-ai

sourcery-ai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Migrates Treeland shortcut management from protocol v2 to v3, replacing commit-based transactional binding with immediate per-bind registration and failure events, updating session lifecycle handling, examples, generated protocol integration, and protocol fixtures.

Sequence diagram for v3 immediate and deferred shortcut binding

sequenceDiagram
    participant Client
    participant ShortcutManagerV3
    participant ShortcutController
    participant Session

    Client->>ShortcutManagerV3: bind_key(name, key_sequence, flags, action)
    alt active session
        ShortcutManagerV3->>ShortcutController: registerKey(name, key, flags, action)
        alt registration fails
            ShortcutManagerV3-->>Client: bind_failure(name, error)
        end
    else inactive session
        ShortcutManagerV3->>ShortcutManagerV3: queue bind_key
        Session-->>ShortcutManagerV3: onSessionChanged()
        ShortcutManagerV3->>ShortcutController: registerKey(name, key, flags, action)
        alt registration fails
            ShortcutManagerV3-->>Client: bind_failure(name, error)
        end
    end
Loading

File-Level Changes

Change Details Files
Migrated the server and client integration from the v2 shortcut protocol to the unstable v3 protocol with interface version 1.
  • Renamed manager and capture interfaces, generated protocol sources, implementation classes, and test bindings.
  • Updated action and error enum mappings and related compile-time consistency checks.
  • Rewired server initialization and Qt/C client examples to use v3 APIs.
src/modules/shortcut/CMakeLists.txt
src/modules/shortcut/shortcutcontroller.cpp
src/modules/shortcut/shortcutcontroller.h
src/modules/shortcut/shortcutmanager.cpp
src/modules/shortcut/shortcutmanager.h
src/seat/helper.cpp
src/seat/helper.h
examples/test_shortcut_manager/CMakeLists.txt
examples/test_shortcut_manager/main.cpp
examples/test_shortcut_capture/CMakeLists.txt
examples/test_shortcut_capture/main.cpp
Reworked binding lifecycle for v3 immediate application and per-binding failure reporting.
  • Apply binds immediately for the active session and queue them for inactive sessions until activation.
  • Replace transactional commit and rollback handling with independent registration and bind_failure events.
  • Restore accepted bindings on session changes and process deferred binds/unbinds without aborting unrelated entries.
  • Remove unbound entries from the tracked shortcut maps and eliminate obsolete commit state.
src/modules/shortcut/shortcutmanager.cpp
Updated protocol fixtures and integration tests to validate v3 behavior.
  • Renamed fixtures and protocol artifacts to v3 and reset client interface binding to version 1.
  • Replaced commit assertions with immediate bind, upsert, name-conflict, bind_failure, capture, and activation coverage.
  • Updated test documentation and coverage notes, including the remaining inactive-session limitation.
tests/protocols/CMakeLists.txt
tests/protocols/INDEX.md
tests/protocols/treeland-shortcut-manager-v3/CMakeLists.txt
tests/protocols/treeland-shortcut-manager-v3/README.md
tests/protocols/treeland-shortcut-manager-v3/setup.cpp
tests/protocols/treeland-shortcut-manager-v3/treeland-shortcut-manager-v3.c
tests/protocols/treeland-shortcut-manager-v3/treeland-shortcut-manager-v3.h
tests/protocols/treeland-shortcut-manager-desktop-v3/CMakeLists.txt
tests/protocols/treeland-shortcut-manager-desktop-v3/setup.cpp
tests/protocols/treeland-shortcut-manager-desktop-v3/treeland-shortcut-manager-desktop-v3.c
tests/test_protocol_shortcut/main.cpp

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

Fix two CI failures on the v2→v3 migration PR:

1. test event.no_bind_failure_upsert: registerKey() checked
   m_deleters.contains(name) and returned name_conflict before reaching
   the upsert logic (same key+action → update flags). Re-binding the
   same name to the same key+action is an in-place flag update, not a
   conflict. Reorder so the upsert check runs first; name_conflict now
   only fires when the name is already used by a different key+action
   binding.

   Also update ShortcutManagerV3Private::registerKey() to replace the
   existing same-name entry on upsert instead of appending a duplicate.

2. SPDX license-header year: tests/test_protocol_shortcut/main.cpp had
   2024-2025 but the file was modified in 2026. Update to 2024-2026.

Verified: all 10 steps of test_treeland_shortcut_manager_v3 pass,
including event.no_bind_failure_upsert and event.bind_failure_name_conflict.
@deepin-bot

deepin-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 0.10.0
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1392

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