Struct wayland_kbd::MappedKeyboard [] [src]

pub struct MappedKeyboard {
    // some fields omitted
}

A wayland keyboard mapped to its keymap

Methods

impl MappedKeyboard

fn new(keyboard: Keyboard) -> Result<MappedKeyboard, Keyboard>

Creates a mapped keyboard from a regular wayland keyboard.

Make sure the initialization phase of the keyboard is finished (with Display::sync_roundtrip() for example), otherwise the keymap won't be available.

Will return Err() and hand back the untouched keyboard if libxkbcommon.so is not available or the keyboard had no associated keymap.

fn release(self) -> Keyboard

Releases the keyboard from this MappedKeyboard and returns it.

fn set_key_action<F>(&self, f: F) where F: Fn(&KbState, Serial, KeyboardId, u32, u32, KeyState) + Send + Sync + 'static

Sets the action to perform when a key is pressed or released.

The closure is given an handle to a KbState that will allow to translate the keycode into a key symbol or an UTF8 sequence.

arguments are:

  • KbState handle
  • KeyboardId of the event
  • time of the event
  • raw keycode
  • new KeyState

fn set_enter_action<F>(&mut self, f: F) where F: Fn(KeyboardId, Serial, SurfaceId, &[u32]) + 'static + Send + Sync

Defines the action to be executed when a surface gains keyboard focus.

Arguments are:

  • Id of the keyboard
  • Id of the surface
  • a slice of the keycodes of the currenlty pressed keys

fn set_leave_action<F>(&mut self, f: F) where F: Fn(KeyboardId, Serial, SurfaceId) + 'static + Send + Sync

Defines the action to be executed when a surface loses keyboard focus.

This event is generated before the enter event is generated for the new surface the focus goes to.

Arguments are:

  • Id of the keyboard
  • Id of the surface