Documentation
¶
Overview ¶
Package xkb binds libxkbcommon (through purego, SPEC §8.1) and turns key presses into Flutter key data: the physical key, the logical key and the text, for any keyboard layout, with dead keys and compose sequences. Wayland and X11 both use it.
Flutter: no counterpart (the embedders use GTK or the platform's own key code for this)
Index ¶
- Constants
- func KeysymToUTF32(sym Keysym) (rune, error)
- func LocaleFromEnv(getenv func(string) string) string
- type Compose
- type ComposeStatus
- type Context
- func (c *Context) Close()
- func (c *Context) KeymapFromFD(fd int, size uint32) (*Keymap, error)
- func (c *Context) KeymapFromNames(n Names) (*Keymap, error)
- func (c *Context) KeymapFromString(text string) (*Keymap, error)
- func (c *Context) KeymapFromX11(conn uintptr) (*Keymap, int32, error)
- func (c *Context) NewCompose(locale string) (*Compose, error)
- type Key
- type Keycode
- type Keymap
- func (k *Keymap) Close()
- func (k *Keymap) KeyRepeats(key Keycode) bool
- func (k *Keymap) NewState() (*State, error)
- func (k *Keymap) NewStateFromX11(conn uintptr, device int32) (*State, error)
- func (k *Keymap) NumLayouts(key Keycode) uint32
- func (k *Keymap) String() string
- func (k *Keymap) SymAt(key Keycode, layout, level uint32) (Keysym, bool)
- type Keysym
- type Layout
- func (l *Layout) Close()
- func (l *Layout) Keymap() *Keymap
- func (l *Layout) Keysym(evdev uint32) Keysym
- func (l *Layout) Lookup(evdev uint32) (Key, error)
- func (l *Layout) ModActive(name string) bool
- func (l *Layout) Press(evdev uint32) (Key, error)
- func (l *Layout) UpdateMask(depressed, latched, locked, group uint32)
- func (l *Layout) UpdateMaskGroups(depressed, latched, locked, baseGroup, latchedGroup, lockedGroup uint32)
- func (l *Layout) XState() uint32
- type Names
- type State
- func (s *State) Close()
- func (s *State) KeyLayout(key Keycode) uint32
- func (s *State) KeyOneSym(key Keycode) Keysym
- func (s *State) KeyUTF8(key Keycode) string
- func (s *State) ModActive(name string) bool
- func (s *State) UpdateMask(depressed, latched, locked, group uint32)
- func (s *State) UpdateMaskGroups(depressed, latched, locked, baseGroup, latchedGroup, lockedGroup uint32)
Constants ¶
const LibraryEnv = "GLUTTER_XKBCOMMON_LIBRARY"
LibraryEnv names the environment variable that overrides the path of libxkbcommon, for setups such as NixOS (SPEC §8.1).
const X11LibraryEnv = "GLUTTER_XKBCOMMON_X11_LIBRARY"
X11LibraryEnv names the environment variable that overrides the path of libxkbcommon-x11.
Variables ¶
This section is empty.
Functions ¶
func KeysymToUTF32 ¶
KeysymToUTF32 returns the Unicode character of a keysym, or 0 when it has none (dead keys, function keys). Keysyms for control keys give the control characters: Return gives 13, BackSpace 8.
Flutter: no counterpart
func LocaleFromEnv ¶
LocaleFromEnv picks the locale for the compose table the way libc does: LC_ALL, then LC_CTYPE, then LANG, then "C".
Flutter: no counterpart
Types ¶
type Compose ¶
type Compose struct {
// contains filtered or unexported fields
}
Compose is the compose state for dead keys and the Compose key. A sequence such as dead_circumflex then "e" turns into "ê".
Flutter: no counterpart
func (*Compose) Close ¶
func (c *Compose) Close()
Close releases the compose state and table. It is safe to call twice.
Flutter: no counterpart
func (*Compose) Feed ¶
func (c *Compose) Feed(sym Keysym) ComposeStatus
Feed gives a pressed key's keysym to the sequence and returns the status after it. Modifier keysyms leave the sequence alone.
Flutter: no counterpart
func (*Compose) Reset ¶
func (c *Compose) Reset()
Reset drops the sequence in progress.
Flutter: no counterpart
type ComposeStatus ¶
type ComposeStatus int
ComposeStatus is the state of a compose sequence (enum xkb_compose_status).
Flutter: no counterpart
const ( // ComposeNothing means no sequence is in progress and the key is not part of // one: the key's own text applies. // // Flutter: no counterpart ComposeNothing ComposeStatus = 0 // Composing means a sequence is in progress; the keys produce no text yet. // // Flutter: no counterpart Composing ComposeStatus = 1 // Composed means the sequence is complete; Compose.UTF8 holds the result. // // Flutter: no counterpart Composed ComposeStatus = 2 // ComposeCancelled means the key did not continue the sequence, which was // dropped. // // Flutter: no counterpart ComposeCancelled ComposeStatus = 3 )
The values of ComposeStatus are those of enum xkb_compose_status.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is an xkb_context. Close releases it. It must outlive the keymaps made with it only until they exist: keymaps keep their own reference.
Flutter: no counterpart
func NewContext ¶
NewContext opens libxkbcommon and creates a context with the default include path. It fails with XKBLoadFailed (or SymbolMissing) when the library is unusable and with XKBContextFailed when the context cannot be created.
Flutter: no counterpart
func (*Context) Close ¶
func (c *Context) Close()
Close releases the context. It is safe to call twice.
Flutter: no counterpart
func (*Context) KeymapFromFD ¶
KeymapFromFD compiles the keymap that a compositor sends: size bytes of text in the file fd, which are read through a read-only mapping. The caller keeps ownership of fd. A trailing NUL byte is not part of the text.
Flutter: no counterpart
func (*Context) KeymapFromNames ¶
KeymapFromNames compiles the keymap that the rule names select. It fails with XKBKeymapFailed when the xkb data files lack that layout.
Flutter: no counterpart
func (*Context) KeymapFromString ¶
KeymapFromString compiles a keymap in the text format (what xkb_keymap_get_as_string and a compositor's keymap file contain).
Flutter: no counterpart
func (*Context) KeymapFromX11 ¶
KeymapFromX11 reads the keymap of the X server's core keyboard through the XKB extension, on the xcb connection (Xlib's, from XGetXCBConnection). It returns the keymap and the device id that NewStateFromX11 needs. It fails with XKBLoadFailed when libxkbcommon-x11 is missing, XKBX11SetupFailed when the server has no XKB extension or no core keyboard, and XKBKeymapFailed when the keymap cannot be read.
Flutter: no counterpart
type Key ¶
type Key struct {
// Physical is the id of the PhysicalKeyboardKey: the place of the key on the
// keyboard, the same on every layout.
Physical uint64
// Logical is the id of the LogicalKeyboardKey: what the key means in the
// current layout.
Logical uint64
// Character is the text the key press produces, or "" (for a key that makes
// no text, and while a dead key or compose sequence is in progress).
Character string
// Repeats is whether holding the key produces repeats.
Repeats bool
}
Key is a key press translated to Flutter's terms.
Flutter: no counterpart
type Keycode ¶
type Keycode = uint32
Keycode is an XKB keycode: the evdev scancode plus 8.
Flutter: no counterpart
type Keymap ¶
type Keymap struct {
// contains filtered or unexported fields
}
Keymap is an xkb_keymap: the layouts of one keyboard.
Flutter: no counterpart
func (*Keymap) Close ¶
func (k *Keymap) Close()
Close releases the keymap. It is safe to call twice.
Flutter: no counterpart
func (*Keymap) KeyRepeats ¶
KeyRepeats reports whether holding the key produces repeats (modifiers do not).
Flutter: no counterpart
func (*Keymap) NewState ¶
NewState creates the state of a keyboard with no key pressed. It fails with XKBStateFailed.
Flutter: no counterpart
func (*Keymap) NewStateFromX11 ¶
NewStateFromX11 creates the state of the X server's keyboard, with the modifiers and layout that are active now. It fails with XKBStateFailed.
Flutter: no counterpart
func (*Keymap) NumLayouts ¶
NumLayouts returns the number of layouts (groups) that the key has.
Flutter: no counterpart
func (*Keymap) String ¶
String returns the keymap in the text format, which KeymapFromString reads back.
Flutter: no counterpart
type Keysym ¶
type Keysym = uint32
Keysym is an XKB keysym, such as 0x61 for "a".
Flutter: no counterpart
func KeysymToLower ¶
KeysymToLower returns the lower-case keysym of a keysym, or the keysym itself when it has no case.
Flutter: no counterpart
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
Layout translates evdev key presses with a keymap, its modifier state and a compose table. It is the keyboard of one seat. A Layout is used on the UI thread only.
Flutter: no counterpart (the GTK embedder's FlKeyboardManager and FlKeyEmbedderResponder do this on Linux)
func NewLayout ¶
NewLayout makes the keyboard from a keymap and, optionally, a compose table. The Layout takes ownership of both and releases them in Close; on an error they are released at once. It fails with XKBStateFailed.
Flutter: no counterpart
func NewLayoutWithState ¶
NewLayoutWithState is NewLayout with a state that already exists, such as one from NewStateFromX11. The Layout takes ownership of the state as well.
Flutter: no counterpart
func (*Layout) Close ¶
func (l *Layout) Close()
Close releases the keymap, the state and the compose table.
Flutter: no counterpart
func (*Layout) Keysym ¶
Keysym returns the keysym that the key has with the modifiers and the group that apply now, without touching the compose state. An input method gets this together with XState.
Flutter: no counterpart
func (*Layout) Lookup ¶
Lookup translates a key without touching the compose state: for key releases and repeats.
Flutter: no counterpart
func (*Layout) ModActive ¶
ModActive reports whether an xkb modifier ("Shift", "Control", "Mod1", ...) is effective.
Flutter: no counterpart
func (*Layout) Press ¶
Press translates a key press. evdev is the scancode that the compositor sends. The character goes through the compose state, so a dead key gives no text and the key after it gives the composed character.
Flutter: no counterpart
func (*Layout) UpdateMask ¶
UpdateMask sets the modifiers and the layout group, as wl_keyboard.modifiers reports them. A pending compose sequence is not touched.
Flutter: no counterpart
func (*Layout) UpdateMaskGroups ¶
func (l *Layout) UpdateMaskGroups(depressed, latched, locked, baseGroup, latchedGroup, lockedGroup uint32)
UpdateMaskGroups sets the modifiers and the layout group the way X11 reports them: the group in its base, latched and locked parts.
Flutter: no counterpart
type Names ¶
type Names struct {
// Rules is the rules file, such as "evdev".
Rules string
// Model is the keyboard model, such as "pc105".
Model string
// Layout is the layout, or a comma-separated list of layouts, such as "de" or
// "us,ru".
Layout string
// Variant is the variant of each layout, such as "nodeadkeys".
Variant string
// Options is a comma-separated list of options, such as "grp:alt_shift_toggle".
Options string
}
Names selects a keymap from the xkb data files, like setxkbmap does. An empty field uses the default from the environment (XKB_DEFAULT_*) or the library.
Flutter: no counterpart
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is an xkb_state: the keymap plus which modifiers and layout are active.
Flutter: no counterpart
func (*State) Close ¶
func (s *State) Close()
Close releases the state. It is safe to call twice.
Flutter: no counterpart
func (*State) KeyLayout ¶
KeyLayout returns the layout (group) that applies to the key now.
Flutter: no counterpart
func (*State) KeyOneSym ¶
KeyOneSym returns the keysym that the key produces now, with the active modifiers and layout, or 0 when there is none or there are several.
Flutter: no counterpart
func (*State) KeyUTF8 ¶
KeyUTF8 returns the text that the key produces now, with the active modifiers (so Control+a gives "\x01"), or "".
Flutter: no counterpart
func (*State) ModActive ¶
ModActive reports whether the modifier, named as in xkb ("Shift", "Control", "Mod1" for Alt, "Lock" for Caps Lock, "Mod2" for Num Lock), is effective now.
Flutter: no counterpart
func (*State) UpdateMask ¶
UpdateMask sets the modifiers and layout from what the compositor sent in wl_keyboard.modifiers (depressed, latched, locked and the group). The compositor, not the client, tracks which keys are down.
Flutter: no counterpart
func (*State) UpdateMaskGroups ¶
func (s *State) UpdateMaskGroups(depressed, latched, locked, baseGroup, latchedGroup, lockedGroup uint32)
UpdateMaskGroups is UpdateMask for a source that reports the layout group in three parts, as X11 does: the base (depressed), latched and locked group.
Flutter: no counterpart