Go to index / Go to protocols

treeland_shortcut_manager_unstable_v3 ↗

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.

This protocol allows privileged clients to register and manage global shortcuts for keyboard key sequences, touch swipe gestures, and touch hold gestures. It also provides a one-shot shortcut capture facility for clients that need to read the next shortcut input from the user.

Global shortcuts are managed in a per-user context. Shortcuts for different users are isolated and will not interfere with each other. This behavior is transparent to clients of this interface.

The terms "must", "must not", "should", and "may" in this document are to be interpreted as described in RFC 2119.

treeland_shortcut_manager_unstable_v3
treeland_shortcut_manager_v3

Version 1

global shortcut manager

A singleton global that manages global shortcut bindings for key sequences, swipe gestures, and hold gestures.

Before registering or removing bindings the client must acquire exclusive control by sending the acquire request. Only one client may hold the manager at a time within a given user session.

Bindings are registered via bind_key, bind_swipe_gesture, and bind_hold_gesture, and removed via unbind. All of these requests take effect immediately. A bind request that cannot be applied is reported with a bind_failure event; successful bind and unbind requests generate no event, and the client can use the wl_display.sync request to confirm that earlier requests have been processed.

If the client's user session is not the currently active session, bind and unbind requests are deferred: they are applied when that session becomes active again.

Destroying the manager object implicitly releases the exclusive control acquired via acquire; no separate release request is needed.

The capture_next_shortcut request is independent of acquire and may be sent at any time.

treeland_shortcut_manager_v3
enum direction {
    down = 1,
    left = 2,
    up = 3,
    right = 4,
}
  • down — swipe towards the bottom of the screen
  • left — swipe towards the left of the screen
  • up — swipe towards the top of the screen
  • right — swipe towards the right of the screen

swipe gesture direction

Cardinal directions used to specify the direction of a swipe gesture binding. The value 0 is reserved and must not be used as a direction argument.

treeland_shortcut_manager_v3
enum action {
    notify = 0,
    workspace_1 = 1,
    workspace_2 = 2,
    workspace_3 = 3,
    workspace_4 = 4,
    workspace_5 = 5,
    workspace_6 = 6,
    workspace_7 = 7,
    workspace_8 = 8,
    workspace_9 = 9,
    workspace_10 = 10,
    workspace_11 = 11,
    workspace_12 = 12,
    prev_workspace = 13,
    next_workspace = 14,
    maximize = 15,
    cancel_maximize = 16,
    minimize = 17,
    move_window = 18,
    resize_window = 19,
    close_window = 20,
    show_window_menu = 21,
    move_window_to_prev_workspace = 22,
    move_window_to_next_workspace = 23,
    show_desktop = 24,
    open_multitask_view = 25,
    close_multitask_view = 26,
    toggle_multitask_view = 27,
    taskswitch_next = 28,
    taskswitch_prev = 29,
    taskswitch_sameapp_next = 30,
    taskswitch_sameapp_prev = 31,
    tile_left = 32,
    tile_right = 33,
    tile_top = 34,
    tile_bottom = 35,
    tile_top_left = 36,
    tile_top_right = 37,
    tile_bottom_left = 38,
    tile_bottom_right = 39,
    zoom_in = 40,
    zoom_out = 41,
    zoom_reset = 42,
    toggle_fps_display = 43,
    lockscreen = 44,
    shutdown_menu = 45,
}
  • notify — emit an activated event to the client
  • workspace_1 — switch to workspace 1
  • workspace_2 — switch to workspace 2
  • workspace_3 — switch to workspace 3
  • workspace_4 — switch to workspace 4
  • workspace_5 — switch to workspace 5
  • workspace_6 — switch to workspace 6
  • workspace_7 — switch to workspace 7
  • workspace_8 — switch to workspace 8
  • workspace_9 — switch to workspace 9
  • workspace_10 — switch to workspace 10
  • workspace_11 — switch to workspace 11
  • workspace_12 — switch to workspace 12
  • prev_workspace — switch to the previous workspace
  • next_workspace — switch to the next workspace
  • maximize — maximize the active window
  • cancel_maximize — restore the active window from maximized state
  • minimize — minimize the active window
  • move_window — enter window move mode for the active window
  • resize_window — enter window resize mode for the active window
  • close_window — close the active window
  • show_window_menu — show the window menu for the active window
  • move_window_to_prev_workspace — move the active window to the previous workspace
  • move_window_to_next_workspace — move the active window to the next workspace
  • show_desktop — toggle show-desktop mode
  • open_multitask_view — open the multitask overview
  • close_multitask_view — close the multitask overview
  • toggle_multitask_view — toggle the multitask overview
  • taskswitch_next — select the next task in the switcher
  • taskswitch_prev — select the previous task in the switcher
  • taskswitch_sameapp_next — select the next window of the same application in the switcher
  • taskswitch_sameapp_prev — select the previous window of the same application in the switcher
  • tile_left — tile the active window to the left half of the screen
  • tile_right — tile the active window to the right half of the screen
  • tile_top — tile the active window to the top half of the screen
  • tile_bottom — tile the active window to the bottom half of the screen
  • tile_top_left — tile the active window to the top-left quarter of the screen
  • tile_top_right — tile the active window to the top-right quarter of the screen
  • tile_bottom_left — tile the active window to the bottom-left quarter of the screen
  • tile_bottom_right — tile the active window to the bottom-right quarter of the screen
  • zoom_in — zoom in the screen
  • zoom_out — zoom out the screen
  • zoom_reset — reset the screen zoom level
  • toggle_fps_display — toggle the compositor FPS overlay
  • lockscreen — lock the screen
  • shutdown_menu — show the shutdown/session menu

compositor actions assignable to a shortcut

Actions that the compositor executes when a shortcut with this action is activated.

The notify action is special: instead of performing a compositor-side operation, the compositor emits an activated event on this interface so the client can respond.

treeland_shortcut_manager_v3
enum keybind_flag {
    key_press = 0x1,
    key_release = 0x2,
    repeat = 0x4,
}
This is a bitfield
  • key_press — trigger on key press
  • key_release — trigger on key release
  • repeat — trigger on auto-repeat while the key is held

keybinding trigger flags

Flags that control when a key binding fires relative to the key event lifecycle.

key_press: fires when the key is pressed. key_release: fires when the key is released. repeat: fires repeatedly while the key is held down (auto-repeat). Only meaningful when combined with key_press; combining with key_release causes both the press and the release auto-repeat events to fire.

Common combinations:

  • key_press only: fires once on press; ignores repeat and release.

  • key_press | repeat: fires on press and on every auto-repeat tick.

  • key_press | key_release: fires on press and release; auto-repeat events are ignored.

  • key_press | key_release | repeat: fires on press, every auto-repeat tick, and on release.

treeland_shortcut_manager_v3
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 — an identical trigger-and-action combination already exists
  • invalid_argument — an argument has an invalid or out-of-range value
  • internal_error — an unrecoverable compositor-internal error occurred

bind request failure codes

Error codes carried by the bind_failure event to describe why a bind request was rejected.

treeland_shortcut_manager_v3
enum error {
    occupied = 1,
    not_acquired = 2,
    invalid_surface = 3,
}
  • occupied — the shortcut manager is already held by another client
  • not_acquired — the client sent a bind or unbind request without first acquiring the manager
  • invalid_surface — the surface argument is not owned by the requesting client

protocol errors for this interface

Error codes sent as protocol errors via wl_display.error.

treeland_shortcut_manager_v3
request destroy()
Destructor

    destroy the shortcut manager

    Destroy the shortcut manager object. If the client currently holds exclusive control via acquire, that control is implicitly released so another client may acquire it. Existing shortcut bindings registered by this client remain active in the compositor until the compositor or another client removes them.

    treeland_shortcut_manager_v3
    request acquire()

      acquire exclusive control of the shortcut manager

      Acquire exclusive control of the shortcut manager for this client. The client must send this request before any bind_key, bind_swipe_gesture, bind_hold_gesture, or unbind request. Sending those requests without first acquiring is a protocol error (not_acquired).

      Only one client may hold the manager at a time within a given user session. If another client already holds it, the compositor sends a protocol error (occupied).

      Exclusive control is released implicitly when the client destroys the manager object.

      treeland_shortcut_manager_v3
      request bind_key(
          name: string,
          key: string,
          flags: uint<keybind_flag>,
          action: uint<action>,
      )
      • name — unique name for this keybinding
      • key — key sequence in QKeySequence portable text format
      • flags — trigger conditions for this keybinding
      • action — compositor action to execute on activation

      register a key sequence binding

      Register a key sequence binding. The binding takes effect immediately.

      The key argument uses the portable textual format of QKeySequence (PortableText); see https://doc.qt.io/qt-6/qkeysequence.html#toString for the format specification. Only combinations that form a valid shortcut can be registered; see the capture_next_shortcut request for the validity rules. An invalid combination is reported with bind_failure and the invalid_argument error.

      The name argument must be unique among all existing bindings. If a binding with the same name already exists, this request is reported with bind_failure and the name_conflict error.

      If a binding with the same key sequence and action already exists, this request updates its flags to the new value rather than failing. This upsert-on-trigger semantics applies only to bind_key; bind_swipe_gesture and bind_hold_gesture treat duplicate trigger-action pairs as errors.

      Sending this request without first acquiring is a protocol error (not_acquired).

      treeland_shortcut_manager_v3
      request bind_swipe_gesture(
          name: string,
          finger: uint,
          direction: uint<direction>,
          action: uint<action>,
      )
      • name — unique name for this swipe gesture binding
      • finger — number of fingers required for the swipe
      • direction — required swipe direction
      • action — compositor action to execute on activation

      register a swipe gesture binding

      Register a swipe gesture binding. The binding takes effect immediately.

      The name argument must be unique among all existing bindings. If a binding with the same name already exists, this request is reported with bind_failure and the name_conflict error.

      If a binding with the same finger count, direction, and action already exists, this request is reported with bind_failure and the duplicate_binding error.

      If direction is not one of the defined direction enum values, this request is reported with bind_failure and the invalid_argument error.

      Sending this request without first acquiring is a protocol error (not_acquired).

      treeland_shortcut_manager_v3
      request bind_hold_gesture(
          name: string,
          finger: uint,
          action: uint<action>,
      )
      • name — unique name for this hold gesture binding
      • finger — number of fingers required for the hold
      • action — compositor action to execute on activation

      register a hold gesture binding

      Register a hold gesture binding. The binding takes effect immediately.

      The name argument must be unique among all existing bindings. If a binding with the same name already exists, this request is reported with bind_failure and the name_conflict error.

      If a binding with the same finger count and action already exists, this request is reported with bind_failure and the duplicate_binding error.

      Sending this request without first acquiring is a protocol error (not_acquired).

      treeland_shortcut_manager_v3
      request unbind(
          name: string,
      )
      • name — name of the binding to remove

      remove an existing binding

      Remove the binding identified by name. The removal takes effect immediately. If no binding with the given name exists, this request is silently ignored.

      Sending this request without first acquiring is a protocol error (not_acquired).

      treeland_shortcut_manager_v3
      request capture_next_shortcut(
          surface: object<wl_surface>,
          seat: nullable object<wl_seat>,
          capture: new_id<treeland_shortcut_capture_v3>,
      )
      • surface — surface used to validate keyboard focus
      • seat — seat to capture from, or null to capture from any available seat
      • capture — one-shot capture object

      start a one-shot shortcut capture

      Create a treeland_shortcut_capture_v3 object and start a one-shot capture of the next shortcut input. This request does not require acquire and does not modify existing bindings.

      The surface argument must be a wl_surface owned by the requesting client. If it is not, the compositor sends a protocol error (invalid_surface).

      The compositor handles at most one capture at a time, regardless of which client requested it. A capture is also considered in progress until the compositor has consumed the key_release of the last captured key, so that the release cannot trigger a shortcut bound in the meantime. If a capture is already in progress, the compositor emits failed with reason busy on the newly created object immediately after creation.

      If the seat argument is not null, the compositor verifies that the keyboard focus of that seat is on the surface. If the seat argument is null, the compositor selects a seat whose keyboard focus is on the surface. If no seat has keyboard focus on the surface, the compositor emits failed with reason not_active on the newly created object immediately after creation. Clients must be prepared to handle a capture object that fails immediately.

      Input from seats other than the validated seat is not intercepted and is processed normally. On the validated seat the capture intercepts input with priority over registered shortcut bindings.

      While the capture is pending, input from the validated seat is handled as follows. If the surface loses keyboard focus, the compositor emits failed with reason aborted and lets the current event continue to its new focus target. Auto-repeat events are consumed silently. A pointer button or wheel event terminates the capture with reason interrupted and is consumed. A key_press of a pure modifier key (Ctrl, Alt, Shift, and similar) is consumed silently; its key_release terminates the capture with reason interrupted, unless the key is the Meta (Super) key: releasing Meta with no other modifier held emits captured with the shortcut "Meta". A key_press of any other key terminates the capture immediately on the press. If the pressed combination is a valid shortcut the compositor emits captured and consumes the key_release that follows; otherwise it emits failed with reason interrupted. In the captured and interrupted cases the triggering input event is consumed and not forwarded to any client.

      A valid shortcut is one of: a non-modifier key combined with Ctrl, Alt, or Meta; a standalone function key (F1 to F35); a standalone key such as Delete, Backspace, Pause, Print, Insert, Help, Menu, or Cancel; Shift combined with Space, Escape, Tab, or a navigation key (Home, End, PageUp, PageDown, and arrows); a standalone media, browser, brightness, or launch key; or the Meta (Super) key pressed alone. An unmodified alphanumeric key and an unmodified Escape are not valid shortcuts.

      treeland_shortcut_manager_v3
      event activated(
          name: string,
          flags: uint<keybind_flag>,
      )
      • name — name of the activated binding
      • flags — key event type that triggered activation

      a notify-action shortcut was activated

      Emitted when a binding registered with action notify is activated. The name argument identifies the binding by its unique name. The flags argument indicates which key event triggered the activation, using the keybind_flag enum values.

      treeland_shortcut_manager_v3
      event bind_failure(
          name: string,
          error: uint<bind_error>,
      )
      • name — name of the rejected binding
      • error — reason for the failure

      a bind request was rejected

      Emitted when a bind_key, bind_swipe_gesture, or bind_hold_gesture request could not be applied; the rejected binding has no effect. The name argument identifies the rejected binding; the error argument provides the reason.

      If the requesting client's session is not active, the bind request is applied (and possibly rejected) only when that session becomes active again, so this event may be emitted long after the request was sent. Each rejected request is reported separately; other bindings of the same client are not affected.

      treeland_shortcut_manager_unstable_v3
      treeland_shortcut_capture_v3

      Version 1

      one-shot shortcut capture object

      Represents a single pending request to capture the next shortcut input from the user, created by treeland_shortcut_manager_v3.capture_next_shortcut.

      The compositor captures input once and emits at most one terminal event: either captured or failed. After a terminal event is sent this object becomes inert; the client should destroy it promptly.

      If the client destroys this object while capture is still pending, the capture is cancelled and no terminal event is sent.

      treeland_shortcut_capture_v3
      enum failed_reason {
          busy = 1,
          aborted = 2,
          not_active = 3,
          interrupted = 4,
      }
      • busy — a capture is already in progress, or the release of the last captured key is still being consumed
      • aborted — the surface lost keyboard focus while the capture was pending
      • not_active — the provided surface did not have keyboard focus at the time of the request
      • interrupted — the first intercepted input was not a valid shortcut sequence

      reasons a one-shot capture could not complete

      Describes why the compositor could not deliver a captured shortcut to the client.

      treeland_shortcut_capture_v3
      request destroy()
      Destructor

        destroy the capture object

        Destroy this capture object. If capture is still pending, destroying the object cancels it; no terminal event will be sent after this request is processed.

        treeland_shortcut_capture_v3
        event captured(
            key: string,
        )
        • key — captured shortcut sequence in QKeySequence portable text format

        a shortcut was successfully captured

        Emitted when the compositor captured one shortcut input for this request. The key argument carries the shortcut sequence in the same QKeySequence portable text format used by treeland_shortcut_manager_v3.bind_key. A capture of the Meta (Super) key pressed alone is reported as the shortcut "Meta".

        This is a terminal event; the object is now inert.

        treeland_shortcut_capture_v3
        event failed(
            reason: uint<failed_reason>,
        )
        • reason — reason the capture failed

        the capture could not be completed

        Emitted when the compositor could not deliver a captured shortcut. The reason argument describes why. See the failed_reason enum for details.

        This is a terminal event; the object is now inert.