Does Wayland use XKB for keyboard layouts?

9,072

Yes, Wayland uses XKB for keyboard layouts. But it's not quite the right question, because things work different than in X. Remember that Wayland is only a protocol (plus a wrapper library).

At the protocol level, wayland has a wl_keyboard.keymap event. This event contains a file descriptor to the keymap and a format classifier. Right now, only one format is defined: "xkb". So a wayland client will receive an XKB-compatible keymap and can use libxkbcommon to interpret that to get the right glyph on the screen, etc.

But Wayland does not define how this keymap is decided on. This decision is up to the compositor. In Weston, it is read from the config file on startup, in GNOME it comes from gsettings, etc. And this decision thus also defines how you can change keymaps at runtime (if at all possible). In GNOME you'd either use the config panel or you'd set the gsettings keys directly.

The X protocol has requests to set the keymap on the protocol level and these are what makes tools like setxkbmap possible. The Wayland does not have these requests, it's not possible to set the keymap using the Wayland protocol alone.

Share:
9,072

Related videos on Youtube

knezi
Author by

knezi

Updated on September 18, 2022

Comments

  • knezi
    knezi over 1 year

    As XKB is part of X window, is it XKB used in Wayland as well? If so, is there any utility planed to replace XKB at some point?

    In weston, setxkbmap does not work obviously. What is the currently recommended way to change keyboard layout?

  • alejandrodnm
    alejandrodnm about 7 years
    Hi, could you please post and example on how to map keys on Gnome, or some reference material, I'm trying to change my right alt to enter.