Skip to content

Conversation

@misaka18931
Copy link
Contributor

This commit introduces improvements to the shortcut management protocol, and refactors Helper::beforeDisposeEvent to purge hardcoded shortcuts in favor of the new shortcut management system.

Changes:

  • moved shortcut matching and action logic from Helper::beforeDisposeEvent to ShortcutV1::handleKeySequence and Helper::handleCompositorAction, respectively, and categorized previously defined shortcut actions into treeland_shortcut_v1_action enum.
  • removed m_windowGesture and 'm_multiTaskViewGesturefromHelper, gesture handling is now moved within the protocol implementation of treeland-shortcut-manager-v1`.

TODO:
Refactor TogglableGesture, as workspace swipe gestures is still hardcoded within TogglableGesture, thus remains non-customizable.

Copy link

@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 @misaka18931, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: misaka18931

The full list of commands accepted by this bot can be found here.

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

@deepin-ci-robot
Copy link

Hi @misaka18931. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@misaka18931 misaka18931 force-pushed the shortcut-management branch 2 times, most recently from c0259f6 to 78ffffa Compare December 2, 2025 02:09
@misaka18931 misaka18931 force-pushed the shortcut-management branch 2 times, most recently from 254d652 to f7adbf7 Compare December 4, 2025 01:40
@zccrs zccrs requested a review from Copilot December 4, 2025 01:43
Copy link

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

This pull request refactors the shortcut management system from a hardcoded approach to a protocol-based, customizable implementation. The core change involves migrating shortcut handling logic from Helper::beforeDisposeEvent to a new shortcut management protocol (treeland-shortcut-manager-v2) with dedicated controller and runner components. Additionally, gesture handling is moved from hardcoded TogglableGesture instances in Helper to the protocol implementation, making shortcuts and gestures configurable via Wayland clients.

Key changes:

  • Introduced ShortcutManagerV2, ShortcutController, and ShortcutRunner classes to manage shortcut registration, dispatch, and execution
  • Removed ~150 lines of hardcoded shortcut logic from Helper::beforeDisposeEvent and replaced with protocol-based dispatch
  • Created ShortcutAction enum to categorize 23 different shortcut actions (workspace switching, window management, system actions, etc.)

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
tests/test_protocol_shortcut/main.cpp Updated test to use new ShortcutManagerV2 class name
src/seat/helper.h Removed gesture properties and updated shortcut protocol reference
src/seat/helper.cpp Removed ~200 lines of hardcoded shortcut/gesture logic; integrated new protocol-based system
src/modules/shortcut/shortcutrunner.h New class to execute shortcut actions based on protocol requests
src/modules/shortcut/shortcutrunner.cpp Implements action handlers for all 23 shortcut actions including workspace swipe animations
src/modules/shortcut/shortcutmanager.h Defines V2 protocol interface and ShortcutAction enum
src/modules/shortcut/shortcutmanager.cpp Implements session-aware shortcut management with pending/committed shortcut tracking
src/modules/shortcut/shortcutcontroller.h Controller for registering and dispatching keyboard/gesture shortcuts
src/modules/shortcut/shortcutcontroller.cpp Implements shortcut registration with conflict detection and gesture lifecycle management
src/modules/shortcut/impl/shortcut_manager_impl.h Low-level protocol struct definitions for V2 manager
src/modules/shortcut/impl/shortcut_manager_impl.cpp Wayland protocol implementation for bind/unbind/commit operations
src/modules/shortcut/CMakeLists.txt Updated to build new shortcut components and use V2 protocol XML
src/input/togglablegesture.h Removed workspace swipe-specific members (moved to ShortcutRunner)
src/input/togglablegesture.cpp Removed workspace swipe implementation (~150 lines)
src/input/inputdevice.h Added return values and unregister methods for gesture management
src/input/inputdevice.cpp Implements gesture unregistration for cleanup
src/input/gestures.h Added static opposite() helper for direction reversal
src/input/gestures.cpp Implements SwipeGesture::opposite() utility function
examples/test_shortcut_manager/main.cpp New example client demonstrating protocol usage
examples/test_shortcut_manager/CMakeLists.txt Build configuration for example client
examples/CMakeLists.txt Added new example subdirectory

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

This commit introduces a major refactoring of the shortcut and gesture
management system, moving away from hardcoded logic in `Helper` to the
fully configurable treeland-shortcut-manager-v2 protocol.

The shortcut management system has been refactored to be more modular
and maintainable. Protocol interactions are handled in `ShortcutManagerV2`,
with shortcut activation logic delegated to `ShortcutController` and
shortcut execution handled by `ShortcutRunner`.

TODO: A temporary shortcut manager client is written in `src/treeland-shortcut`
for backward compatibility and to facilitate the transition to the new
protocol. This needs to be removed once shortcut management is fully supported
in DDE.

Key Changes:
- Introduced `ShortcutManagerV2` and `ShortcutController` to handle
  shortcut registration and dispatching via the Wayland protocol.
- Added `ShortcutRunner` to execute actions triggered by shortcuts,
  replacing the monolithic switch-case logic in `Helper`.
- Refactored `Helper::beforeDisposeEvent` to delegate key events to
  the new shortcut controller.
- Removed `m_windowGesture` and `m_multiTaskViewGesture` from `Helper`.
  Gesture handling is now managed through the shortcut protocol.
- Moved workspace swipe gesture handling from `TogglableGesture` into
  `ShortcutRunner`.
- Added `test_shortcut_manager` example to demonstrate and test the
  new V2 protocol capabilities and usage.
- Updated `test_protocol_shortcut` to verify the new server interface.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants