libxkbcommon  0.2.0
Keymap Creation

Creating and destroying keymaps. More...

Macros

#define XKB_KEYMAP_USE_ORIGINAL_FORMAT   ((enum xkb_keymap_format) -1)
 Get the keymap as a string in the format from which it was created.

Enumerations

enum  xkb_keymap_compile_flags { XKB_MAP_COMPILE_PLACEHOLDER = 0 }
 Flags for keymap compilation. More...
enum  xkb_keymap_format { XKB_KEYMAP_FORMAT_TEXT_V1 = 1 }
 The possible keymap text formats. More...

Functions

struct xkb_keymapxkb_keymap_new_from_names (struct xkb_context *context, const struct xkb_rule_names *names, enum xkb_keymap_compile_flags flags)
 Create a keymap from RMLVO names.
struct xkb_keymapxkb_keymap_new_from_file (struct xkb_context *context, FILE *file, enum xkb_keymap_format format, enum xkb_keymap_compile_flags flags)
 Create a keymap from a keymap file.
struct xkb_keymapxkb_keymap_new_from_string (struct xkb_context *context, const char *string, enum xkb_keymap_format format, enum xkb_keymap_compile_flags flags)
 Create a keymap from a keymap string.
struct xkb_keymapxkb_keymap_ref (struct xkb_keymap *keymap)
 Take a new reference on a keymap.
void xkb_keymap_unref (struct xkb_keymap *keymap)
 Release a reference on a keymap, and possibly free it.
char * xkb_keymap_get_as_string (struct xkb_keymap *keymap, enum xkb_keymap_format format)
 Get the compiled keymap as a string.

Detailed Description

Creating and destroying keymaps.

Macro Definition Documentation

#define XKB_KEYMAP_USE_ORIGINAL_FORMAT   ((enum xkb_keymap_format) -1)

Get the keymap as a string in the format from which it was created.

See Also
xkb_keymap_get_as_string()

Enumeration Type Documentation

Flags for keymap compilation.

Enumerator:
XKB_MAP_COMPILE_PLACEHOLDER 

Apparently you can't have empty enums.

What a drag.

The possible keymap text formats.

Enumerator:
XKB_KEYMAP_FORMAT_TEXT_V1 

The current/classic XKB text format, as generated by xkbcomp -xkb.

Function Documentation

struct xkb_keymap * xkb_keymap_new_from_names ( struct xkb_context context,
const struct xkb_rule_names names,
enum xkb_keymap_compile_flags  flags 
)
read

Create a keymap from RMLVO names.

The primary keymap entry point: creates a new XKB keymap from a set of RMLVO (Rules + Model + Layouts + Variants + Options) names.

You should almost certainly be using this and nothing else to create keymaps.

Parameters
contextThe context in which to create the keymap.
namesThe RMLVO names to use.
flagsOptional flags for the keymap, or 0.
Returns
A keymap compiled according to the RMLVO names, or NULL if the compilation failed.
See Also
xkb_rule_names
struct xkb_keymap * xkb_keymap_new_from_file ( struct xkb_context context,
FILE *  file,
enum xkb_keymap_format  format,
enum xkb_keymap_compile_flags  flags 
)
read

Create a keymap from a keymap file.

Parameters
contextThe context in which to create the keymap.
fileThe keymap file to compile.
formatThe text format of the keymap file to compile.
flagsOptional flags for the keymap, or 0.
Returns
A keymap compiled from the given XKB keymap file, or NULL if the compilation failed.

The file must contain a complete keymap. For example, in the XKB_KEYMAP_FORMAT_TEXT_V1 format, this means the file must contain one top level 'xkb_keymap' section, which in turn contains other required sections.

struct xkb_keymap * xkb_keymap_new_from_string ( struct xkb_context context,
const char *  string,
enum xkb_keymap_format  format,
enum xkb_keymap_compile_flags  flags 
)
read

Create a keymap from a keymap string.

This is just like xkb_keymap_new_from_file(), but instead of a file, gets the keymap as one enormous string.

See Also
xkb_keymap_new_from_string()
struct xkb_keymap * xkb_keymap_ref ( struct xkb_keymap keymap)
read

Take a new reference on a keymap.

Returns
The passed in keymap.
char * xkb_keymap_get_as_string ( struct xkb_keymap keymap,
enum xkb_keymap_format  format 
)

Get the compiled keymap as a string.

Parameters
keymapThe keymap to get as a string.
formatThe keymap format to use for the string. You can pass in the special value XKB_KEYMAP_USE_ORIGINAL_FORMAT to use the format from which the keymap was originally created.
Returns
The keymap as a NUL-terminated string, or NULL if unsuccessful.

The returned string may be fed back into xkb_map_new_from_string() to get the exact same keymap (possibly in another process, etc.).

The returned string is dynamically allocated and should be freed by the caller.