Copyright
SPDX-FileCopyrightText: 2024-2025 UnionTech Software Technology Co., Ltd.
SPDX-License-Identifier: MIT
keyboard shortcut management
Warning! This protocol is EXPERIMENTAL and under active development.
It may change at any time, including in backward-incompatible ways,
without incrementing the interface major version and without prior
notice. No compatibility guarantees of any kind are provided. Clients
and compositors must track the upstream definition in treeland-protocols
and must not rely on the current interface names, requests, events, or
semantics remaining stable across releases.
Version 3
Compositor Support
global shortcuts manager for treeland
This interface allows privileged clients to register global shortcuts.
In treeland, global shortcuts are managed in a per-user context.
Shortcuts for different users are isolated, and will not interfere with each other.
This allows multiple users to use their own set of global shortcuts
on the same system without conflicts.
This behavior is transparent to the clients of this interface (i.e.,
the user context used by this protocol is the same as that of the client.)
treeland_shortcut_manager_v2
enum action {
notify = 1,
workspace_1 = 2,
workspace_2 = 3,
workspace_3 = 4,
workspace_4 = 5,
workspace_5 = 6,
workspace_6 = 7,
prev_workspace = 8,
next_workspace = 9,
show_desktop = 10,
maximize = 11,
cancel_maximize = 12,
move_window = 13,
close_window = 14,
show_window_menu = 15,
open_multitask_view = 16,
close_multitask_view = 17,
toggle_multitask_view = 18,
toggle_fps_display = 19,
lockscreen = 20,
shutdown_menu = 21,
quit = 22,
taskswitch_enter = 23,
taskswitch_next = 24,
taskswitch_prev = 25,
taskswitch_sameapp_next = 26,
taskswitch_sameapp_prev = 27,
tile_left = 28,
tile_right = 29,
}compositor actions
Compositor actions that can be assigned to a shortcut.
treeland_shortcut_manager_v2
enum keybind_flag {
key_press = 0x1,
key_release = 0x2,
repeat = 0x4,
}This is a bitfield
- key_press — bind key press events
- key_release — bind key release events
- repeat — bind autorepeat events.
keybinding flags
Flags to specify the keybinding mode.
With key_press, the action is triggered on key press.
With key_release, the action is triggered on key release.
With repeat, the action is repeatedly triggered if the key is held down.
Examples:
key_press | repeat: the action is triggered on key press, and repeatedly
triggered if the key is held down.
key_press | key_release: the action is triggered on both key press and
key release, auto-repeated events are ignored.
key_press | key_release | repeat: note that treeland repeats both key
press and key release events.
treeland_shortcut_manager_v2
enum bind_error {
name_conflict = 1,
duplicate_binding = 2,
invalid_argument = 3,
internal_error = 4,
}- name_conflict — a binding with this name already exists
- duplicate_binding — a binding with this key sequence and action already exists
- invalid_argument — an argument has an invalid value
- internal_error — an internal compositor error occurred
binding error codes
Error codes indicating the reason of a binding failure.
treeland_shortcut_manager_v2
request destroy()
Destructor
destroy the shortcut manager
Destroy the shortcut manager.
Existing shortcuts created through this interface remain valid.
treeland_shortcut_manager_v2
request acquire()
acquire the shortcut manager
Acquire the shortcut manager for the current client.
This request must be sent before any bind/unbind request can be performed.
Only one client can hold exclusive control of the shortcut manager at a time,
for a given session.
If the shortcut manager is already acquired by another client,
the compositor will raise the occupied protocol error.
treeland_shortcut_manager_v2
request bind_key(
name: string,
key: string,
flags: uint<keybind_flag>,
action: uint<action>,
)- name — unique name for the keybinding
- key — key sequence for the keybinding
- flags — flags for the keybinding
- action — compositor action to be executed
bind a key sequence to a compositor action
Bind a key sequence to a compositor action.
The key sequence is specified in the string format used by QKeySequence,
see https://doc.qt.io/qt-6/qkeysequence.html#toString for details.
Sending this request without first acquiring the shortcut manager
will result in a not_acquired protocol error.
The name argument must be unique among all existing bindings.
If a binding with the same name already exists, the bind_key request will fail.
The action argument specifies the compositor action to be executed
when the key sequence is activated.
Each keybind has a flags argument that specifies the exact triggering condition,
see the documentation of the keybind_flag enum for details.
If a binding with the same key sequence and action already exists,
its flags will be updated to the new value.
Note that the binding will not take effect until a commit request is sent.
treeland_shortcut_manager_v2
request bind_swipe_gesture(
name: string,
finger: uint,
direction: uint<direction>,
action: uint<action>,
)- name — unique name for the swipe gesture
- finger — number of fingers required for the swipe gesture
- direction — direction of the swipe gesture
- action — compositor action to be executed
bind a swipe gesture to a compositor action
Bind a swipe gesture to a compositor action.
Sending this request without first acquiring the shortcut manager
will result in a not_acquired protocol error.
The name argument must be unique among all existing bindings.
If a binding with the same name already exists, the bind_swipe_gesture request will fail.
The direction argument specifies the direction towards which the swipe gesture must be performed.
If this argument is not one of the defined enum values, the bind_swipe_gesture request will fail.
The action argument specifies the compositor action to be executed
when the swipe gesture is activated.
If a binding with the same gesture and action already exists,
the bind_swipe_gesture request will fail.
Note that the binding will not take effect until a commit request is sent.
treeland_shortcut_manager_v2
request bind_hold_gesture(
name: string,
finger: uint,
action: uint<action>,
)- name — unique name for the hold gesture
- finger — number of fingers required for the hold gesture
- action — compositor action to be executed
bind a hold gesture to a compositor action
Bind a hold gesture to a compositor action.
Sending this request without first acquiring the shortcut manager
will result in a not_acquired protocol error.
The name argument must be unique among all existing bindings.
If a binding with the same name already exists, the bind_hold_gesture request will fail.
The action argument specifies the compositor action to be executed
when the hold gesture is activated.
If a binding with the same gesture and action already exists,
the bind_hold_gesture request will fail.
Note that the binding will not take effect until a commit request is sent.
treeland_shortcut_manager_v2
request commit()
commit the pending bindings
Commit the pending bindings.
This request applies all the bind_key, bind_swipe_gesture and bind_hold_gesture
requests sent since the last commit.
After processing this request, the compositor will emit a commit_success event
if the commit was successful or commit_failure event if the commit failed.
On a successful commit, all the pending bindings will take effect.
On a failed commit, none of the pending bindings will take effect.
Sending this request without first acquiring the shortcut manager
will result in a not_acquired protocol error.
Sending further commit requests before commit_success or commit_failure
is sent is a protocol error.
treeland_shortcut_manager_v2
request unbind(
name: string,
)- name — unique name of the binding to be removed
remove an existing binding
Remove an existing binding.
Sending this request without first acquiring the shortcut manager
will result in a not_acquired protocol error.
The binding to be removed is identified by its unique name.
If no binding with the specified name exists, the unbind request has no effect.
treeland_shortcut_manager_v2
request capture_next_shortcut(
surface: object<wl_surface>,
seat: nullable object<wl_seat>,
capture: new_id<treeland_shortcut_capture_v1>,
)Available since version 2
- surface — surface used for focus or active validation
- seat — seat to capture from, or null to capture from any seat
- capture — one-shot capture object
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.
The compositor must verify that the provided surface currently has
keyboard focus or is active before starting capture.
If this check fails, the compositor must first decide that capture
does not start, and then 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 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.
This request does not modify existing shortcut bindings.
This request does not require acquire.
treeland_shortcut_manager_v2
event activated(
name: string,
flags: uint<keybind_flag>,
)- name — binding id of the activated shortcut
- flags — flags for the key event
a shortcut has been activated
This event is emitted when a binding registered with action notify is activated.
The flags argument indicates the type of key event as defined in the keybind_flag enum.
treeland_shortcut_manager_v2
event commit_failure(
name: string,
error: uint<bind_error>,
)- name — binding name that caused the failure
- error — error code indicating the reason of the failure
the last commit has failed
This event is emitted in response to a commit request,
indicating that the commit has failed.
The error argument indicates the first error that caused the commit to fail.
Version 1
one-shot shortcut capture object
This object represents one request to capture the next shortcut input.
After creation, the compositor captures input once and may send at most one
terminal event: either captured or failed.
If the client destroys this object while capture is pending,
no terminal event is sent.
After a terminal event is sent, this object becomes inert.
The client should destroy this object promptly after receiving
captured or failed.
treeland_shortcut_capture_v1
enum failed_reason {
busy = 1,
aborted = 2,
not_active = 3,
interrupted = 4,
}- busy — another capture is in progress
- aborted — capture was aborted by compositor policy
- not_active — surface focus or active validation failed
- interrupted — capture was interrupted by a non-shortcut intercepted input
capture failure reason
Reasons why a one-shot capture could not complete.
treeland_shortcut_capture_v1
event captured(
key: string,
)- key — captured shortcut sequence
a shortcut input was captured
The compositor captured one shortcut input for this request.
The key argument uses the same textual format as bind_key.