• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 1985, 1987, 1990, 1998  The Open Group
3  * Copyright 2008  Dan Nicholson
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Except as contained in this notice, the names of the authors or their
23  * institutions shall not be used in advertising or otherwise to promote the
24  * sale, use or other dealings in this Software without prior written
25  * authorization from the authors.
26  */
27 
28 /************************************************************
29  * Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
30  *
31  * Permission to use, copy, modify, and distribute this
32  * software and its documentation for any purpose and without
33  * fee is hereby granted, provided that the above copyright
34  * notice appear in all copies and that both that copyright
35  * notice and this permission notice appear in supporting
36  * documentation, and that the name of Silicon Graphics not be
37  * used in advertising or publicity pertaining to distribution
38  * of the software without specific prior written permission.
39  * Silicon Graphics makes no representation about the suitability
40  * of this software for any purpose. It is provided "as is"
41  * without any express or implied warranty.
42  *
43  * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
44  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
45  * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
46  * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
47  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
48  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
49  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
50  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
51  *
52  ********************************************************/
53 
54 /*
55  * Copyright © 2009-2012 Daniel Stone
56  * Copyright © 2012 Intel Corporation
57  * Copyright © 2012 Ran Benita
58  *
59  * Permission is hereby granted, free of charge, to any person obtaining a
60  * copy of this software and associated documentation files (the "Software"),
61  * to deal in the Software without restriction, including without limitation
62  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
63  * and/or sell copies of the Software, and to permit persons to whom the
64  * Software is furnished to do so, subject to the following conditions:
65  *
66  * The above copyright notice and this permission notice (including the next
67  * paragraph) shall be included in all copies or substantial portions of the
68  * Software.
69  *
70  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
71  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
72  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
73  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
74  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
75  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
76  * DEALINGS IN THE SOFTWARE.
77  *
78  * Author: Daniel Stone <daniel@fooishbar.org>
79  */
80 
81 #ifndef _XKBCOMMON_H_
82 #define _XKBCOMMON_H_
83 
84 #include <stdint.h>
85 #include <stdio.h>
86 #include <stdarg.h>
87 
88 #include <xkbcommon/xkbcommon-names.h>
89 #include <xkbcommon/xkbcommon-keysyms.h>
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
95 /**
96  * @file
97  * Main libxkbcommon API.
98  */
99 
100 /**
101  * @struct xkb_context
102  * Opaque top level library context object.
103  *
104  * The context contains various general library data and state, like
105  * logging level and include paths.
106  *
107  * Objects are created in a specific context, and multiple contexts may
108  * coexist simultaneously.  Objects from different contexts are completely
109  * separated and do not share any memory or state.
110  */
111 struct xkb_context;
112 
113 /**
114  * @struct xkb_keymap
115  * Opaque compiled keymap object.
116  *
117  * The keymap object holds all of the static keyboard information obtained
118  * from compiling XKB files.
119  *
120  * A keymap is immutable after it is created (besides reference counts, etc.);
121  * if you need to change it, you must create a new one.
122  */
123 struct xkb_keymap;
124 
125 /**
126  * @struct xkb_state
127  * Opaque keyboard state object.
128  *
129  * State objects contain the active state of a keyboard (or keyboards), such
130  * as the currently effective layout and the active modifiers.  It acts as a
131  * simple state machine, wherein key presses and releases are the input, and
132  * key symbols (keysyms) are the output.
133  */
134 struct xkb_state;
135 
136 /**
137  * A number used to represent a physical key on a keyboard.
138  *
139  * A standard PC-compatible keyboard might have 102 keys.  An appropriate
140  * keymap would assign each of them a keycode, by which the user should
141  * refer to the key throughout the library.
142  *
143  * Historically, the X11 protocol, and consequentially the XKB protocol,
144  * assign only 8 bits for keycodes.  This limits the number of different
145  * keys that can be used simultaneously in a single keymap to 256
146  * (disregarding other limitations).  This library does not share this limit;
147  * keycodes beyond 255 ('extended keycodes') are not treated specially.
148  * Keymaps and applications which are compatible with X11 should not use
149  * these keycodes.
150  *
151  * The values of specific keycodes are determined by the keymap and the
152  * underlying input system.  For example, with an X11-compatible keymap
153  * and Linux evdev scan codes (see linux/input.h), a fixed offset is used:
154  *
155  * The keymap defines a canonical name for each key, plus possible aliases.
156  * Historically, the XKB protocol restricts these names to at most 4 (ASCII)
157  * characters, but this library does not share this limit.
158  *
159  * @code
160  * xkb_keycode_t keycode_A = KEY_A + 8;
161  * @endcode
162  *
163  * @sa xkb_keycode_is_legal_ext() xkb_keycode_is_legal_x11()
164  */
165 typedef uint32_t xkb_keycode_t;
166 
167 /**
168  * A number used to represent the symbols generated from a key on a keyboard.
169  *
170  * A key, represented by a keycode, may generate different symbols according
171  * to keyboard state.  For example, on a QWERTY keyboard, pressing the key
172  * labled \<A\> generates the symbol 'a'.  If the Shift key is held, it
173  * generates the symbol 'A'.  If a different layout is used, say Greek,
174  * it generates the symbol 'α'.  And so on.
175  *
176  * Each such symbol is represented by a keysym.  Note that keysyms are
177  * somewhat more general, in that they can also represent some "function",
178  * such as "Left" or "Right" for the arrow keys.  For more information,
179  * see:
180  * https://www.x.org/releases/current/doc/xproto/x11protocol.html#keysym_encoding
181  *
182  * Specifically named keysyms can be found in the
183  * xkbcommon/xkbcommon-keysyms.h header file.  Their name does not include
184  * the XKB_KEY_ prefix.
185  *
186  * Besides those, any Unicode/ISO 10646 character in the range U0100 to
187  * U10FFFF can be represented by a keysym value in the range 0x01000100 to
188  * 0x0110FFFF.  The name of Unicode keysyms is "U<codepoint>", e.g. "UA1B2".
189  *
190  * The name of other unnamed keysyms is the hexadecimal representation of
191  * their value, e.g. "0xabcd1234".
192  *
193  * Keysym names are case-sensitive.
194  */
195 typedef uint32_t xkb_keysym_t;
196 
197 /**
198  * Index of a keyboard layout.
199  *
200  * The layout index is a state component which detemines which <em>keyboard
201  * layout</em> is active.  These may be different alphabets, different key
202  * arrangements, etc.
203  *
204  * Layout indices are consecutive.  The first layout has index 0.
205  *
206  * Each layout is not required to have a name, and the names are not
207  * guaranteed to be unique (though they are usually provided and unique).
208  * Therefore, it is not safe to use the name as a unique identifier for a
209  * layout.  Layout names are case-sensitive.
210  *
211  * Layout names are specified in the layout's definition, for example
212  * "English (US)".  These are different from the (conventionally) short names
213  * which are used to locate the layout, for example "us" or "us(intl)".  These
214  * names are not present in a compiled keymap.
215  *
216  * If the user selects layouts from a list generated from the XKB registry
217  * (using libxkbregistry or directly), and this metadata is needed later on, it
218  * is recommended to store it along with the keymap.
219  *
220  * Layouts are also called "groups" by XKB.
221  *
222  * @sa xkb_keymap_num_layouts() xkb_keymap_num_layouts_for_key()
223  */
224 typedef uint32_t xkb_layout_index_t;
225 /** A mask of layout indices. */
226 typedef uint32_t xkb_layout_mask_t;
227 
228 /**
229  * Index of a shift level.
230  *
231  * Any key, in any layout, can have several <em>shift levels</em>.  Each
232  * shift level can assign different keysyms to the key.  The shift level
233  * to use is chosen according to the current keyboard state; for example,
234  * if no keys are pressed, the first level may be used; if the Left Shift
235  * key is pressed, the second; if Num Lock is pressed, the third; and
236  * many such combinations are possible (see xkb_mod_index_t).
237  *
238  * Level indices are consecutive.  The first level has index 0.
239  */
240 typedef uint32_t xkb_level_index_t;
241 
242 /**
243  * Index of a modifier.
244  *
245  * A @e modifier is a state component which changes the way keys are
246  * interpreted.  A keymap defines a set of modifiers, such as Alt, Shift,
247  * Num Lock or Meta, and specifies which keys may @e activate which
248  * modifiers (in a many-to-many relationship, i.e. a key can activate
249  * several modifiers, and a modifier may be activated by several keys.
250  * Different keymaps do this differently).
251  *
252  * When retrieving the keysyms for a key, the active modifier set is
253  * consulted; this detemines the correct shift level to use within the
254  * currently active layout (see xkb_level_index_t).
255  *
256  * Modifier indices are consecutive.  The first modifier has index 0.
257  *
258  * Each modifier must have a name, and the names are unique.  Therefore, it
259  * is safe to use the name as a unique identifier for a modifier.  The names
260  * of some common modifiers are provided in the xkbcommon/xkbcommon-names.h
261  * header file.  Modifier names are case-sensitive.
262  *
263  * @sa xkb_keymap_num_mods()
264  */
265 typedef uint32_t xkb_mod_index_t;
266 /** A mask of modifier indices. */
267 typedef uint32_t xkb_mod_mask_t;
268 
269 /**
270  * Index of a keyboard LED.
271  *
272  * LEDs are logical objects which may be @e active or @e inactive.  They
273  * typically correspond to the lights on the keyboard. Their state is
274  * determined by the current keyboard state.
275  *
276  * LED indices are non-consecutive.  The first LED has index 0.
277  *
278  * Each LED must have a name, and the names are unique. Therefore,
279  * it is safe to use the name as a unique identifier for a LED.  The names
280  * of some common LEDs are provided in the xkbcommon/xkbcommon-names.h
281  * header file.  LED names are case-sensitive.
282  *
283  * @warning A given keymap may specify an exact index for a given LED.
284  * Therefore, LED indexing is not necessarily sequential, as opposed to
285  * modifiers and layouts.  This means that when iterating over the LEDs
286  * in a keymap using e.g. xkb_keymap_num_leds(), some indices might be
287  * invalid.  Given such an index, functions like xkb_keymap_led_get_name()
288  * will return NULL, and xkb_state_led_index_is_active() will return -1.
289  *
290  * LEDs are also called "indicators" by XKB.
291  *
292  * @sa xkb_keymap_num_leds()
293  */
294 typedef uint32_t xkb_led_index_t;
295 /** A mask of LED indices. */
296 typedef uint32_t xkb_led_mask_t;
297 
298 #define XKB_KEYCODE_INVALID (0xffffffff)
299 #define XKB_LAYOUT_INVALID  (0xffffffff)
300 #define XKB_LEVEL_INVALID   (0xffffffff)
301 #define XKB_MOD_INVALID     (0xffffffff)
302 #define XKB_LED_INVALID     (0xffffffff)
303 
304 #define XKB_KEYCODE_MAX     (0xffffffff - 1)
305 
306 /**
307  * Test whether a value is a valid extended keycode.
308  * @sa xkb_keycode_t
309  **/
310 #define xkb_keycode_is_legal_ext(key) (key <= XKB_KEYCODE_MAX)
311 
312 /**
313  * Test whether a value is a valid X11 keycode.
314  * @sa xkb_keycode_t
315  */
316 #define xkb_keycode_is_legal_x11(key) (key >= 8 && key <= 255)
317 
318 /**
319  * Names to compile a keymap with, also known as RMLVO.
320  *
321  * The names are the common configuration values by which a user picks
322  * a keymap.
323  *
324  * If the entire struct is NULL, then each field is taken to be NULL.
325  * You should prefer passing NULL instead of choosing your own defaults.
326  */
327 struct xkb_rule_names {
328     /**
329      * The rules file to use. The rules file describes how to interpret
330      * the values of the model, layout, variant and options fields.
331      *
332      * If NULL or the empty string "", a default value is used.
333      * If the XKB_DEFAULT_RULES environment variable is set, it is used
334      * as the default.  Otherwise the system default is used.
335      */
336     const char *rules;
337     /**
338      * The keyboard model by which to interpret keycodes and LEDs.
339      *
340      * If NULL or the empty string "", a default value is used.
341      * If the XKB_DEFAULT_MODEL environment variable is set, it is used
342      * as the default.  Otherwise the system default is used.
343      */
344     const char *model;
345     /**
346      * A comma separated list of layouts (languages) to include in the
347      * keymap.
348      *
349      * If NULL or the empty string "", a default value is used.
350      * If the XKB_DEFAULT_LAYOUT environment variable is set, it is used
351      * as the default.  Otherwise the system default is used.
352      */
353     const char *layout;
354     /**
355      * A comma separated list of variants, one per layout, which may
356      * modify or augment the respective layout in various ways.
357      *
358      * If NULL or the empty string "", and a default value is also used
359      * for the layout, a default value is used.  Otherwise no variant is
360      * used.
361      * If the XKB_DEFAULT_VARIANT environment variable is set, it is used
362      * as the default.  Otherwise the system default is used.
363      */
364     const char *variant;
365     /**
366      * A comma separated list of options, through which the user specifies
367      * non-layout related preferences, like which key combinations are used
368      * for switching layouts, or which key is the Compose key.
369      *
370      * If NULL, a default value is used.  If the empty string "", no
371      * options are used.
372      * If the XKB_DEFAULT_OPTIONS environment variable is set, it is used
373      * as the default.  Otherwise the system default is used.
374      */
375     const char *options;
376 };
377 
378 /**
379  * @defgroup keysyms Keysyms
380  * Utility functions related to keysyms.
381  *
382  * @{
383  */
384 
385 /**
386  * @page keysym-transformations Keysym Transformations
387  *
388  * Keysym translation is subject to several "keysym transformations",
389  * as described in the XKB specification.  These are:
390  *
391  * - Capitalization transformation.  If the Caps Lock modifier is
392  *   active and was not consumed by the translation process, a single
393  *   keysym is transformed to its upper-case form (if applicable).
394  *   Similarly, the UTF-8/UTF-32 string produced is capitalized.
395  *
396  *   This is described in:
397  *   https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Interpreting_the_Lock_Modifier
398  *
399  * - Control transformation.  If the Control modifier is active and
400  *   was not consumed by the translation process, the string produced
401  *   is transformed to its matching ASCII control character (if
402  *   applicable).  Keysyms are not affected.
403  *
404  *   This is described in:
405  *   https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Interpreting_the_Control_Modifier
406  *
407  * Each relevant function discusses which transformations it performs.
408  *
409  * These transformations are not applicable when a key produces multiple
410  * keysyms.
411  */
412 
413 
414 /**
415  * Get the name of a keysym.
416  *
417  * For a description of how keysyms are named, see @ref xkb_keysym_t.
418  *
419  * @param[in]  keysym The keysym.
420  * @param[out] buffer A string buffer to write the name into.
421  * @param[in]  size   Size of the buffer.
422  *
423  * @warning If the buffer passed is too small, the string is truncated
424  * (though still NUL-terminated); a size of at least 64 bytes is recommended.
425  *
426  * @returns The number of bytes in the name, excluding the NUL byte. If
427  * the keysym is invalid, returns -1.
428  *
429  * You may check if truncation has occurred by comparing the return value
430  * with the length of buffer, similarly to the snprintf(3) function.
431  *
432  * @sa xkb_keysym_t
433  */
434 int
435 xkb_keysym_get_name(xkb_keysym_t keysym, char *buffer, size_t size);
436 
437 /** Flags for xkb_keysym_from_name(). */
438 enum xkb_keysym_flags {
439     /** Do not apply any flags. */
440     XKB_KEYSYM_NO_FLAGS = 0,
441     /** Find keysym by case-insensitive search. */
442     XKB_KEYSYM_CASE_INSENSITIVE = (1 << 0)
443 };
444 
445 /**
446  * Get a keysym from its name.
447  *
448  * @param name The name of a keysym. See remarks in xkb_keysym_get_name();
449  * this function will accept any name returned by that function.
450  * @param flags A set of flags controlling how the search is done. If
451  * invalid flags are passed, this will fail with XKB_KEY_NoSymbol.
452  *
453  * If you use the XKB_KEYSYM_CASE_INSENSITIVE flag and two keysym names
454  * differ only by case, then the lower-case keysym is returned.  For
455  * instance, for KEY_a and KEY_A, this function would return KEY_a for the
456  * case-insensitive search.  If this functionality is needed, it is
457  * recommended to first call this function without this flag; and if that
458  * fails, only then to try with this flag, while possibly warning the user
459  * he had misspelled the name, and might get wrong results.
460  *
461  * Case folding is done according to the C locale; the current locale is not
462  * consulted.
463  *
464  * @returns The keysym. If the name is invalid, returns XKB_KEY_NoSymbol.
465  *
466  * @sa xkb_keysym_t
467  */
468 xkb_keysym_t
469 xkb_keysym_from_name(const char *name, enum xkb_keysym_flags flags);
470 
471 /**
472  * Get the Unicode/UTF-8 representation of a keysym.
473  *
474  * @param[in]  keysym The keysym.
475  * @param[out] buffer A buffer to write the UTF-8 string into.
476  * @param[in]  size   The size of buffer.  Must be at least 7.
477  *
478  * @returns The number of bytes written to the buffer (including the
479  * terminating byte).  If the keysym does not have a Unicode
480  * representation, returns 0.  If the buffer is too small, returns -1.
481  *
482  * This function does not perform any @ref keysym-transformations.
483  * Therefore, prefer to use xkb_state_key_get_utf8() if possible.
484  *
485  * @sa xkb_state_key_get_utf8()
486  */
487 int
488 xkb_keysym_to_utf8(xkb_keysym_t keysym, char *buffer, size_t size);
489 
490 /**
491  * Get the Unicode/UTF-32 representation of a keysym.
492  *
493  * @returns The Unicode/UTF-32 representation of keysym, which is also
494  * compatible with UCS-4.  If the keysym does not have a Unicode
495  * representation, returns 0.
496  *
497  * This function does not perform any @ref keysym-transformations.
498  * Therefore, prefer to use xkb_state_key_get_utf32() if possible.
499  *
500  * @sa xkb_state_key_get_utf32()
501  */
502 uint32_t
503 xkb_keysym_to_utf32(xkb_keysym_t keysym);
504 
505 /**
506  * Get the keysym corresponding to a Unicode/UTF-32 codepoint.
507  *
508  * @returns The keysym corresponding to the specified Unicode
509  * codepoint, or XKB_KEY_NoSymbol if there is none.
510  *
511  * This function is the inverse of @ref xkb_keysym_to_utf32. In cases
512  * where a single codepoint corresponds to multiple keysyms, returns
513  * the keysym with the lowest value.
514  *
515  * Unicode codepoints which do not have a special (legacy) keysym
516  * encoding use a direct encoding scheme. These keysyms don't usually
517  * have an associated keysym constant (XKB_KEY_*).
518  *
519  * For noncharacter Unicode codepoints and codepoints outside of the
520  * defined Unicode planes this function returns XKB_KEY_NoSymbol.
521  *
522  * @sa xkb_keysym_to_utf32()
523  * @since 1.0.0
524  */
525 xkb_keysym_t
526 xkb_utf32_to_keysym(uint32_t ucs);
527 
528 /**
529  * Convert a keysym to its uppercase form.
530  *
531  * If there is no such form, the keysym is returned unchanged.
532  *
533  * The conversion rules may be incomplete; prefer to work with the Unicode
534  * representation instead, when possible.
535  */
536 xkb_keysym_t
537 xkb_keysym_to_upper(xkb_keysym_t ks);
538 
539 /**
540  * Convert a keysym to its lowercase form.
541  *
542  * The conversion rules may be incomplete; prefer to work with the Unicode
543  * representation instead, when possible.
544  */
545 xkb_keysym_t
546 xkb_keysym_to_lower(xkb_keysym_t ks);
547 
548 /** @} */
549 
550 /**
551  * @defgroup context Library Context
552  * Creating, destroying and using library contexts.
553  *
554  * Every keymap compilation request must have a context associated with
555  * it.  The context keeps around state such as the include path.
556  *
557  * @{
558  */
559 
560 /**
561  * @page envvars Environment Variables
562  *
563  * The user may set some environment variables which affect the library:
564  *
565  * - `XKB_CONFIG_ROOT`, `XKB_EXTRA_PATH`, `XDG_CONFIG_DIR`, `HOME` - see @ref include-path.
566  * - `XKB_LOG_LEVEL` - see xkb_context_set_log_level().
567  * - `XKB_LOG_VERBOSITY` - see xkb_context_set_log_verbosity().
568  * - `XKB_DEFAULT_RULES`, `XKB_DEFAULT_MODEL`, `XKB_DEFAULT_LAYOUT`,
569  *   `XKB_DEFAULT_VARIANT`, `XKB_DEFAULT_OPTIONS` - see xkb_rule_names.
570  */
571 
572 /** Flags for context creation. */
573 enum xkb_context_flags {
574     /** Do not apply any context flags. */
575     XKB_CONTEXT_NO_FLAGS = 0,
576     /** Create this context with an empty include path. */
577     XKB_CONTEXT_NO_DEFAULT_INCLUDES = (1 << 0),
578     /**
579      * Don't take RMLVO names from the environment.
580      * @since 0.3.0
581      */
582     XKB_CONTEXT_NO_ENVIRONMENT_NAMES = (1 << 1)
583 };
584 
585 /**
586  * Create a new context.
587  *
588  * @param flags Optional flags for the context, or 0.
589  *
590  * @returns A new context, or NULL on failure.
591  *
592  * @memberof xkb_context
593  */
594 struct xkb_context *
595 xkb_context_new(enum xkb_context_flags flags);
596 
597 /**
598  * Take a new reference on a context.
599  *
600  * @returns The passed in context.
601  *
602  * @memberof xkb_context
603  */
604 struct xkb_context *
605 xkb_context_ref(struct xkb_context *context);
606 
607 /**
608  * Release a reference on a context, and possibly free it.
609  *
610  * @param context The context.  If it is NULL, this function does nothing.
611  *
612  * @memberof xkb_context
613  */
614 void
615 xkb_context_unref(struct xkb_context *context);
616 
617 /**
618  * Store custom user data in the context.
619  *
620  * This may be useful in conjunction with xkb_context_set_log_fn() or other
621  * callbacks.
622  *
623  * @memberof xkb_context
624  */
625 void
626 xkb_context_set_user_data(struct xkb_context *context, void *user_data);
627 
628 /**
629  * Retrieves stored user data from the context.
630  *
631  * @returns The stored user data.  If the user data wasn't set, or the
632  * passed in context is NULL, returns NULL.
633  *
634  * This may be useful to access private user data from callbacks like a
635  * custom logging function.
636  *
637  * @memberof xkb_context
638  **/
639 void *
640 xkb_context_get_user_data(struct xkb_context *context);
641 
642 /** @} */
643 
644 /**
645  * @defgroup include-path Include Paths
646  * Manipulating the include paths in a context.
647  *
648  * The include paths are the file-system paths that are searched when an
649  * include statement is encountered during keymap compilation.
650  *
651  * The default include paths are, in that lookup order:
652  * - The path `$XDG_CONFIG_HOME/xkb`, with the usual `XDG_CONFIG_HOME`
653  *   fallback to `$HOME/.config/` if unset.
654  * - The path `$HOME/.xkb`, where $HOME is the value of the environment
655  *   variable `HOME`.
656  * - The `XKB_EXTRA_PATH` environment variable, if defined, otherwise the
657  *   system configuration directory, defined at library configuration time
658  *   (usually `/etc/xkb`).
659  * - The `XKB_CONFIG_ROOT` environment variable, if defined, otherwise
660  *   the system XKB root, defined at library configuration time.
661  *
662  * @{
663  */
664 
665 /**
666  * Append a new entry to the context's include path.
667  *
668  * @returns 1 on success, or 0 if the include path could not be added or is
669  * inaccessible.
670  *
671  * @memberof xkb_context
672  */
673 int
674 xkb_context_include_path_append(struct xkb_context *context, const char *path);
675 
676 /**
677  * Append the default include paths to the context's include path.
678  *
679  * @returns 1 on success, or 0 if the primary include path could not be added.
680  *
681  * @memberof xkb_context
682  */
683 int
684 xkb_context_include_path_append_default(struct xkb_context *context);
685 
686 /**
687  * Reset the context's include path to the default.
688  *
689  * Removes all entries from the context's include path, and inserts the
690  * default paths.
691  *
692  * @returns 1 on success, or 0 if the primary include path could not be added.
693  *
694  * @memberof xkb_context
695  */
696 int
697 xkb_context_include_path_reset_defaults(struct xkb_context *context);
698 
699 /**
700  * Remove all entries from the context's include path.
701  *
702  * @memberof xkb_context
703  */
704 void
705 xkb_context_include_path_clear(struct xkb_context *context);
706 
707 /**
708  * Get the number of paths in the context's include path.
709  *
710  * @memberof xkb_context
711  */
712 unsigned int
713 xkb_context_num_include_paths(struct xkb_context *context);
714 
715 /**
716  * Get a specific include path from the context's include path.
717  *
718  * @returns The include path at the specified index.  If the index is
719  * invalid, returns NULL.
720  *
721  * @memberof xkb_context
722  */
723 const char *
724 xkb_context_include_path_get(struct xkb_context *context, unsigned int index);
725 
726 /** @} */
727 
728 /**
729  * @defgroup logging Logging Handling
730  * Manipulating how logging from this library is handled.
731  *
732  * @{
733  */
734 
735 /** Specifies a logging level. */
736 enum xkb_log_level {
737     XKB_LOG_LEVEL_CRITICAL = 10, /**< Log critical internal errors only. */
738     XKB_LOG_LEVEL_ERROR = 20,    /**< Log all errors. */
739     XKB_LOG_LEVEL_WARNING = 30,  /**< Log warnings and errors. */
740     XKB_LOG_LEVEL_INFO = 40,     /**< Log information, warnings, and errors. */
741     XKB_LOG_LEVEL_DEBUG = 50     /**< Log everything. */
742 };
743 
744 /**
745  * Set the current logging level.
746  *
747  * @param context The context in which to set the logging level.
748  * @param level   The logging level to use.  Only messages from this level
749  * and below will be logged.
750  *
751  * The default level is XKB_LOG_LEVEL_ERROR.  The environment variable
752  * XKB_LOG_LEVEL, if set in the time the context was created, overrides the
753  * default value.  It may be specified as a level number or name.
754  *
755  * @memberof xkb_context
756  */
757 void
758 xkb_context_set_log_level(struct xkb_context *context,
759                           enum xkb_log_level level);
760 
761 /**
762  * Get the current logging level.
763  *
764  * @memberof xkb_context
765  */
766 enum xkb_log_level
767 xkb_context_get_log_level(struct xkb_context *context);
768 
769 /**
770  * Sets the current logging verbosity.
771  *
772  * The library can generate a number of warnings which are not helpful to
773  * ordinary users of the library.  The verbosity may be increased if more
774  * information is desired (e.g. when developing a new keymap).
775  *
776  * The default verbosity is 0.  The environment variable XKB_LOG_VERBOSITY,
777  * if set in the time the context was created, overrides the default value.
778  *
779  * @param context   The context in which to use the set verbosity.
780  * @param verbosity The verbosity to use.  Currently used values are
781  * 1 to 10, higher values being more verbose.  0 would result in no verbose
782  * messages being logged.
783  *
784  * Most verbose messages are of level XKB_LOG_LEVEL_WARNING or lower.
785  *
786  * @memberof xkb_context
787  */
788 void
789 xkb_context_set_log_verbosity(struct xkb_context *context, int verbosity);
790 
791 /**
792  * Get the current logging verbosity of the context.
793  *
794  * @memberof xkb_context
795  */
796 int
797 xkb_context_get_log_verbosity(struct xkb_context *context);
798 
799 /**
800  * Set a custom function to handle logging messages.
801  *
802  * @param context The context in which to use the set logging function.
803  * @param log_fn  The function that will be called for logging messages.
804  * Passing NULL restores the default function, which logs to stderr.
805  *
806  * By default, log messages from this library are printed to stderr.  This
807  * function allows you to replace the default behavior with a custom
808  * handler.  The handler is only called with messages which match the
809  * current logging level and verbosity settings for the context.
810  * level is the logging level of the message.  @a format and @a args are
811  * the same as in the vprintf(3) function.
812  *
813  * You may use xkb_context_set_user_data() on the context, and then call
814  * xkb_context_get_user_data() from within the logging function to provide
815  * it with additional private context.
816  *
817  * @memberof xkb_context
818  */
819 void
820 xkb_context_set_log_fn(struct xkb_context *context,
821                        void (*log_fn)(struct xkb_context *context,
822                                       enum xkb_log_level level,
823                                       const char *format, va_list args));
824 
825 /** @} */
826 
827 /**
828  * @defgroup keymap Keymap Creation
829  * Creating and destroying keymaps.
830  *
831  * @{
832  */
833 
834 /** Flags for keymap compilation. */
835 enum xkb_keymap_compile_flags {
836     /** Do not apply any flags. */
837     XKB_KEYMAP_COMPILE_NO_FLAGS = 0
838 };
839 
840 /**
841  * Create a keymap from RMLVO names.
842  *
843  * The primary keymap entry point: creates a new XKB keymap from a set of
844  * RMLVO (Rules + Model + Layouts + Variants + Options) names.
845  *
846  * @param context The context in which to create the keymap.
847  * @param names   The RMLVO names to use.  See xkb_rule_names.
848  * @param flags   Optional flags for the keymap, or 0.
849  *
850  * @returns A keymap compiled according to the RMLVO names, or NULL if
851  * the compilation failed.
852  *
853  * @sa xkb_rule_names
854  * @memberof xkb_keymap
855  */
856 struct xkb_keymap *
857 xkb_keymap_new_from_names(struct xkb_context *context,
858                           const struct xkb_rule_names *names,
859                           enum xkb_keymap_compile_flags flags);
860 
861 /** The possible keymap formats. */
862 enum xkb_keymap_format {
863     /** The current/classic XKB text format, as generated by xkbcomp -xkb. */
864     XKB_KEYMAP_FORMAT_TEXT_V1 = 1
865 };
866 
867 /**
868  * Create a keymap from a keymap file.
869  *
870  * @param context The context in which to create the keymap.
871  * @param file    The keymap file to compile.
872  * @param format  The text format of the keymap file to compile.
873  * @param flags   Optional flags for the keymap, or 0.
874  *
875  * @returns A keymap compiled from the given XKB keymap file, or NULL if
876  * the compilation failed.
877  *
878  * The file must contain a complete keymap.  For example, in the
879  * XKB_KEYMAP_FORMAT_TEXT_V1 format, this means the file must contain one
880  * top level '%xkb_keymap' section, which in turn contains other required
881  * sections.
882  *
883  * @memberof xkb_keymap
884  */
885 struct xkb_keymap *
886 xkb_keymap_new_from_file(struct xkb_context *context, FILE *file,
887                          enum xkb_keymap_format format,
888                          enum xkb_keymap_compile_flags flags);
889 
890 /**
891  * Create a keymap from a keymap string.
892  *
893  * This is just like xkb_keymap_new_from_file(), but instead of a file, gets
894  * the keymap as one enormous string.
895  *
896  * @see xkb_keymap_new_from_file()
897  * @memberof xkb_keymap
898  */
899 struct xkb_keymap *
900 xkb_keymap_new_from_string(struct xkb_context *context, const char *string,
901                            enum xkb_keymap_format format,
902                            enum xkb_keymap_compile_flags flags);
903 
904 /**
905  * Create a keymap from a memory buffer.
906  *
907  * This is just like xkb_keymap_new_from_string(), but takes a length argument
908  * so the input string does not have to be zero-terminated.
909  *
910  * @see xkb_keymap_new_from_string()
911  * @memberof xkb_keymap
912  * @since 0.3.0
913  */
914 struct xkb_keymap *
915 xkb_keymap_new_from_buffer(struct xkb_context *context, const char *buffer,
916                            size_t length, enum xkb_keymap_format format,
917                            enum xkb_keymap_compile_flags flags);
918 
919 /**
920  * Take a new reference on a keymap.
921  *
922  * @returns The passed in keymap.
923  *
924  * @memberof xkb_keymap
925  */
926 struct xkb_keymap *
927 xkb_keymap_ref(struct xkb_keymap *keymap);
928 
929 /**
930  * Release a reference on a keymap, and possibly free it.
931  *
932  * @param keymap The keymap.  If it is NULL, this function does nothing.
933  *
934  * @memberof xkb_keymap
935  */
936 void
937 xkb_keymap_unref(struct xkb_keymap *keymap);
938 
939 /**
940  * Get the keymap as a string in the format from which it was created.
941  * @sa xkb_keymap_get_as_string()
942  **/
943 #define XKB_KEYMAP_USE_ORIGINAL_FORMAT ((enum xkb_keymap_format) -1)
944 
945 /**
946  * Get the compiled keymap as a string.
947  *
948  * @param keymap The keymap to get as a string.
949  * @param format The keymap format to use for the string.  You can pass
950  * in the special value XKB_KEYMAP_USE_ORIGINAL_FORMAT to use the format
951  * from which the keymap was originally created.
952  *
953  * @returns The keymap as a NUL-terminated string, or NULL if unsuccessful.
954  *
955  * The returned string may be fed back into xkb_keymap_new_from_string() to get
956  * the exact same keymap (possibly in another process, etc.).
957  *
958  * The returned string is dynamically allocated and should be freed by the
959  * caller.
960  *
961  * @memberof xkb_keymap
962  */
963 char *
964 xkb_keymap_get_as_string(struct xkb_keymap *keymap,
965                          enum xkb_keymap_format format);
966 
967 /** @} */
968 
969 /**
970  * @defgroup components Keymap Components
971  * Enumeration of state components in a keymap.
972  *
973  * @{
974  */
975 
976 /**
977  * Get the minimum keycode in the keymap.
978  *
979  * @sa xkb_keycode_t
980  * @memberof xkb_keymap
981  * @since 0.3.1
982  */
983 xkb_keycode_t
984 xkb_keymap_min_keycode(struct xkb_keymap *keymap);
985 
986 /**
987  * Get the maximum keycode in the keymap.
988  *
989  * @sa xkb_keycode_t
990  * @memberof xkb_keymap
991  * @since 0.3.1
992  */
993 xkb_keycode_t
994 xkb_keymap_max_keycode(struct xkb_keymap *keymap);
995 
996 /**
997  * The iterator used by xkb_keymap_key_for_each().
998  *
999  * @sa xkb_keymap_key_for_each
1000  * @memberof xkb_keymap
1001  * @since 0.3.1
1002  */
1003 typedef void
1004 (*xkb_keymap_key_iter_t)(struct xkb_keymap *keymap, xkb_keycode_t key,
1005                          void *data);
1006 
1007 /**
1008  * Run a specified function for every valid keycode in the keymap.  If a
1009  * keymap is sparse, this function may be called fewer than
1010  * (max_keycode - min_keycode + 1) times.
1011  *
1012  * @sa xkb_keymap_min_keycode() xkb_keymap_max_keycode() xkb_keycode_t
1013  * @memberof xkb_keymap
1014  * @since 0.3.1
1015  */
1016 void
1017 xkb_keymap_key_for_each(struct xkb_keymap *keymap, xkb_keymap_key_iter_t iter,
1018                         void *data);
1019 
1020 /**
1021  * Find the name of the key with the given keycode.
1022  *
1023  * This function always returns the canonical name of the key (see
1024  * description in xkb_keycode_t).
1025  *
1026  * @returns The key name. If no key with this keycode exists,
1027  * returns NULL.
1028  *
1029  * @sa xkb_keycode_t
1030  * @memberof xkb_keymap
1031  * @since 0.6.0
1032  */
1033 const char *
1034 xkb_keymap_key_get_name(struct xkb_keymap *keymap, xkb_keycode_t key);
1035 
1036 /**
1037  * Find the keycode of the key with the given name.
1038  *
1039  * The name can be either a canonical name or an alias.
1040  *
1041  * @returns The keycode. If no key with this name exists,
1042  * returns XKB_KEYCODE_INVALID.
1043  *
1044  * @sa xkb_keycode_t
1045  * @memberof xkb_keymap
1046  * @since 0.6.0
1047  */
1048 xkb_keycode_t
1049 xkb_keymap_key_by_name(struct xkb_keymap *keymap, const char *name);
1050 
1051 /**
1052  * Get the number of modifiers in the keymap.
1053  *
1054  * @sa xkb_mod_index_t
1055  * @memberof xkb_keymap
1056  */
1057 xkb_mod_index_t
1058 xkb_keymap_num_mods(struct xkb_keymap *keymap);
1059 
1060 /**
1061  * Get the name of a modifier by index.
1062  *
1063  * @returns The name.  If the index is invalid, returns NULL.
1064  *
1065  * @sa xkb_mod_index_t
1066  * @memberof xkb_keymap
1067  */
1068 const char *
1069 xkb_keymap_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx);
1070 
1071 /**
1072  * Get the index of a modifier by name.
1073  *
1074  * @returns The index.  If no modifier with this name exists, returns
1075  * XKB_MOD_INVALID.
1076  *
1077  * @sa xkb_mod_index_t
1078  * @memberof xkb_keymap
1079  */
1080 xkb_mod_index_t
1081 xkb_keymap_mod_get_index(struct xkb_keymap *keymap, const char *name);
1082 
1083 /**
1084  * Get the number of layouts in the keymap.
1085  *
1086  * @sa xkb_layout_index_t xkb_rule_names xkb_keymap_num_layouts_for_key()
1087  * @memberof xkb_keymap
1088  */
1089 xkb_layout_index_t
1090 xkb_keymap_num_layouts(struct xkb_keymap *keymap);
1091 
1092 /**
1093  * Get the name of a layout by index.
1094  *
1095  * @returns The name.  If the index is invalid, or the layout does not have
1096  * a name, returns NULL.
1097  *
1098  * @sa xkb_layout_index_t
1099  *     For notes on layout names.
1100  * @memberof xkb_keymap
1101  */
1102 const char *
1103 xkb_keymap_layout_get_name(struct xkb_keymap *keymap, xkb_layout_index_t idx);
1104 
1105 /**
1106  * Get the index of a layout by name.
1107  *
1108  * @returns The index.  If no layout exists with this name, returns
1109  * XKB_LAYOUT_INVALID.  If more than one layout in the keymap has this name,
1110  * returns the lowest index among them.
1111  *
1112  * @sa xkb_layout_index_t
1113  *     For notes on layout names.
1114  * @memberof xkb_keymap
1115  */
1116 xkb_layout_index_t
1117 xkb_keymap_layout_get_index(struct xkb_keymap *keymap, const char *name);
1118 
1119 /**
1120  * Get the number of LEDs in the keymap.
1121  *
1122  * @warning The range [ 0...xkb_keymap_num_leds() ) includes all of the LEDs
1123  * in the keymap, but may also contain inactive LEDs.  When iterating over
1124  * this range, you need the handle this case when calling functions such as
1125  * xkb_keymap_led_get_name() or xkb_state_led_index_is_active().
1126  *
1127  * @sa xkb_led_index_t
1128  * @memberof xkb_keymap
1129  */
1130 xkb_led_index_t
1131 xkb_keymap_num_leds(struct xkb_keymap *keymap);
1132 
1133 /**
1134  * Get the name of a LED by index.
1135  *
1136  * @returns The name.  If the index is invalid, returns NULL.
1137  *
1138  * @memberof xkb_keymap
1139  */
1140 const char *
1141 xkb_keymap_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx);
1142 
1143 /**
1144  * Get the index of a LED by name.
1145  *
1146  * @returns The index.  If no LED with this name exists, returns
1147  * XKB_LED_INVALID.
1148  *
1149  * @memberof xkb_keymap
1150  */
1151 xkb_led_index_t
1152 xkb_keymap_led_get_index(struct xkb_keymap *keymap, const char *name);
1153 
1154 /**
1155  * Get the number of layouts for a specific key.
1156  *
1157  * This number can be different from xkb_keymap_num_layouts(), but is always
1158  * smaller.  It is the appropriate value to use when iterating over the
1159  * layouts of a key.
1160  *
1161  * @sa xkb_layout_index_t
1162  * @memberof xkb_keymap
1163  */
1164 xkb_layout_index_t
1165 xkb_keymap_num_layouts_for_key(struct xkb_keymap *keymap, xkb_keycode_t key);
1166 
1167 /**
1168  * Get the number of shift levels for a specific key and layout.
1169  *
1170  * If @c layout is out of range for this key (that is, larger or equal to
1171  * the value returned by xkb_keymap_num_layouts_for_key()), it is brought
1172  * back into range in a manner consistent with xkb_state_key_get_layout().
1173  *
1174  * @sa xkb_level_index_t
1175  * @memberof xkb_keymap
1176  */
1177 xkb_level_index_t
1178 xkb_keymap_num_levels_for_key(struct xkb_keymap *keymap, xkb_keycode_t key,
1179                               xkb_layout_index_t layout);
1180 
1181 /**
1182  * Retrieves every possible modifier mask that produces the specified
1183  * shift level for a specific key and layout.
1184  *
1185  * This API is useful for inverse key transformation; i.e. finding out
1186  * which modifiers need to be active in order to be able to type the
1187  * keysym(s) corresponding to the specific key code, layout and level.
1188  *
1189  * @warning It returns only up to masks_size modifier masks. If the
1190  * buffer passed is too small, some of the possible modifier combinations
1191  * will not be returned.
1192  *
1193  * @param[in] keymap      The keymap.
1194  * @param[in] key         The keycode of the key.
1195  * @param[in] layout      The layout for which to get modifiers.
1196  * @param[in] level       The shift level in the layout for which to get the
1197  * modifiers. This should be smaller than:
1198  * @code xkb_keymap_num_levels_for_key(keymap, key) @endcode
1199  * @param[out] masks_out  A buffer in which the requested masks should be
1200  * stored.
1201  * @param[out] masks_size The size of the buffer pointed to by masks_out.
1202  *
1203  * If @c layout is out of range for this key (that is, larger or equal to
1204  * the value returned by xkb_keymap_num_layouts_for_key()), it is brought
1205  * back into range in a manner consistent with xkb_state_key_get_layout().
1206  *
1207  * @returns The number of modifier masks stored in the masks_out array.
1208  * If the key is not in the keymap or if the specified shift level cannot
1209  * be reached it returns 0 and does not modify the masks_out buffer.
1210  *
1211  * @sa xkb_level_index_t
1212  * @sa xkb_mod_mask_t
1213  * @memberof xkb_keymap
1214  * @since 1.0.0
1215  */
1216 size_t
1217 xkb_keymap_key_get_mods_for_level(struct xkb_keymap *keymap,
1218                                   xkb_keycode_t key,
1219                                   xkb_layout_index_t layout,
1220                                   xkb_level_index_t level,
1221                                   xkb_mod_mask_t *masks_out,
1222                                   size_t masks_size);
1223 
1224 /**
1225  * Get the keysyms obtained from pressing a key in a given layout and
1226  * shift level.
1227  *
1228  * This function is like xkb_state_key_get_syms(), only the layout and
1229  * shift level are not derived from the keyboard state but are instead
1230  * specified explicitly.
1231  *
1232  * @param[in] keymap    The keymap.
1233  * @param[in] key       The keycode of the key.
1234  * @param[in] layout    The layout for which to get the keysyms.
1235  * @param[in] level     The shift level in the layout for which to get the
1236  * keysyms. This should be smaller than:
1237  * @code xkb_keymap_num_levels_for_key(keymap, key) @endcode
1238  * @param[out] syms_out An immutable array of keysyms corresponding to the
1239  * key in the given layout and shift level.
1240  *
1241  * If @c layout is out of range for this key (that is, larger or equal to
1242  * the value returned by xkb_keymap_num_layouts_for_key()), it is brought
1243  * back into range in a manner consistent with xkb_state_key_get_layout().
1244  *
1245  * @returns The number of keysyms in the syms_out array.  If no keysyms
1246  * are produced by the key in the given layout and shift level, returns 0
1247  * and sets syms_out to NULL.
1248  *
1249  * @sa xkb_state_key_get_syms()
1250  * @memberof xkb_keymap
1251  */
1252 int
1253 xkb_keymap_key_get_syms_by_level(struct xkb_keymap *keymap,
1254                                  xkb_keycode_t key,
1255                                  xkb_layout_index_t layout,
1256                                  xkb_level_index_t level,
1257                                  const xkb_keysym_t **syms_out);
1258 
1259 /**
1260  * Determine whether a key should repeat or not.
1261  *
1262  * A keymap may specify different repeat behaviors for different keys.
1263  * Most keys should generally exhibit repeat behavior; for example, holding
1264  * the 'a' key down in a text editor should normally insert a single 'a'
1265  * character every few milliseconds, until the key is released.  However,
1266  * there are keys which should not or do not need to be repeated.  For
1267  * example, repeating modifier keys such as Left/Right Shift or Caps Lock
1268  * is not generally useful or desired.
1269  *
1270  * @returns 1 if the key should repeat, 0 otherwise.
1271  *
1272  * @memberof xkb_keymap
1273  */
1274 int
1275 xkb_keymap_key_repeats(struct xkb_keymap *keymap, xkb_keycode_t key);
1276 
1277 /** @} */
1278 
1279 /**
1280  * @defgroup state Keyboard State
1281  * Creating, destroying and manipulating keyboard state objects.
1282  *
1283  * @{
1284  */
1285 
1286 /**
1287  * Create a new keyboard state object.
1288  *
1289  * @param keymap The keymap which the state will use.
1290  *
1291  * @returns A new keyboard state object, or NULL on failure.
1292  *
1293  * @memberof xkb_state
1294  */
1295 struct xkb_state *
1296 xkb_state_new(struct xkb_keymap *keymap);
1297 
1298 /**
1299  * Take a new reference on a keyboard state object.
1300  *
1301  * @returns The passed in object.
1302  *
1303  * @memberof xkb_state
1304  */
1305 struct xkb_state *
1306 xkb_state_ref(struct xkb_state *state);
1307 
1308 /**
1309  * Release a reference on a keybaord state object, and possibly free it.
1310  *
1311  * @param state The state.  If it is NULL, this function does nothing.
1312  *
1313  * @memberof xkb_state
1314  */
1315 void
1316 xkb_state_unref(struct xkb_state *state);
1317 
1318 /**
1319  * Get the keymap which a keyboard state object is using.
1320  *
1321  * @returns The keymap which was passed to xkb_state_new() when creating
1322  * this state object.
1323  *
1324  * This function does not take a new reference on the keymap; you must
1325  * explicitly reference it yourself if you plan to use it beyond the
1326  * lifetime of the state.
1327  *
1328  * @memberof xkb_state
1329  */
1330 struct xkb_keymap *
1331 xkb_state_get_keymap(struct xkb_state *state);
1332 
1333 /** Specifies the direction of the key (press / release). */
1334 enum xkb_key_direction {
1335     XKB_KEY_UP,   /**< The key was released. */
1336     XKB_KEY_DOWN  /**< The key was pressed. */
1337 };
1338 
1339 /**
1340  * Modifier and layout types for state objects.  This enum is bitmaskable,
1341  * e.g. (XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED) is valid to
1342  * exclude locked modifiers.
1343  *
1344  * In XKB, the DEPRESSED components are also known as 'base'.
1345  */
1346 enum xkb_state_component {
1347     /** Depressed modifiers, i.e. a key is physically holding them. */
1348     XKB_STATE_MODS_DEPRESSED = (1 << 0),
1349     /** Latched modifiers, i.e. will be unset after the next non-modifier
1350      *  key press. */
1351     XKB_STATE_MODS_LATCHED = (1 << 1),
1352     /** Locked modifiers, i.e. will be unset after the key provoking the
1353      *  lock has been pressed again. */
1354     XKB_STATE_MODS_LOCKED = (1 << 2),
1355     /** Effective modifiers, i.e. currently active and affect key
1356      *  processing (derived from the other state components).
1357      *  Use this unless you explicitly care how the state came about. */
1358     XKB_STATE_MODS_EFFECTIVE = (1 << 3),
1359     /** Depressed layout, i.e. a key is physically holding it. */
1360     XKB_STATE_LAYOUT_DEPRESSED = (1 << 4),
1361     /** Latched layout, i.e. will be unset after the next non-modifier
1362      *  key press. */
1363     XKB_STATE_LAYOUT_LATCHED = (1 << 5),
1364     /** Locked layout, i.e. will be unset after the key provoking the lock
1365      *  has been pressed again. */
1366     XKB_STATE_LAYOUT_LOCKED = (1 << 6),
1367     /** Effective layout, i.e. currently active and affects key processing
1368      *  (derived from the other state components).
1369      *  Use this unless you explicitly care how the state came about. */
1370     XKB_STATE_LAYOUT_EFFECTIVE = (1 << 7),
1371     /** LEDs (derived from the other state components). */
1372     XKB_STATE_LEDS = (1 << 8)
1373 };
1374 
1375 /**
1376  * Update the keyboard state to reflect a given key being pressed or
1377  * released.
1378  *
1379  * This entry point is intended for programs which track the keyboard state
1380  * explicitly (like an evdev client).  If the state is serialized to you by
1381  * a master process (like a Wayland compositor) using functions like
1382  * xkb_state_serialize_mods(), you should use xkb_state_update_mask() instead.
1383  * The two functions should not generally be used together.
1384  *
1385  * A series of calls to this function should be consistent; that is, a call
1386  * with XKB_KEY_DOWN for a key should be matched by an XKB_KEY_UP; if a key
1387  * is pressed twice, it should be released twice; etc. Otherwise (e.g. due
1388  * to missed input events), situations like "stuck modifiers" may occur.
1389  *
1390  * This function is often used in conjunction with the function
1391  * xkb_state_key_get_syms() (or xkb_state_key_get_one_sym()), for example,
1392  * when handling a key event.  In this case, you should prefer to get the
1393  * keysyms *before* updating the key, such that the keysyms reported for
1394  * the key event are not affected by the event itself.  This is the
1395  * conventional behavior.
1396  *
1397  * @returns A mask of state components that have changed as a result of
1398  * the update.  If nothing in the state has changed, returns 0.
1399  *
1400  * @memberof xkb_state
1401  *
1402  * @sa xkb_state_update_mask()
1403  */
1404 enum xkb_state_component
1405 xkb_state_update_key(struct xkb_state *state, xkb_keycode_t key,
1406                      enum xkb_key_direction direction);
1407 
1408 /**
1409  * Update a keyboard state from a set of explicit masks.
1410  *
1411  * This entry point is intended for window systems and the like, where a
1412  * master process holds an xkb_state, then serializes it over a wire
1413  * protocol, and clients then use the serialization to feed in to their own
1414  * xkb_state.
1415  *
1416  * All parameters must always be passed, or the resulting state may be
1417  * incoherent.
1418  *
1419  * The serialization is lossy and will not survive round trips; it must only
1420  * be used to feed slave state objects, and must not be used to update the
1421  * master state.
1422  *
1423  * If you do not fit the description above, you should use
1424  * xkb_state_update_key() instead.  The two functions should not generally be
1425  * used together.
1426  *
1427  * @returns A mask of state components that have changed as a result of
1428  * the update.  If nothing in the state has changed, returns 0.
1429  *
1430  * @memberof xkb_state
1431  *
1432  * @sa xkb_state_component
1433  * @sa xkb_state_update_key
1434  */
1435 enum xkb_state_component
1436 xkb_state_update_mask(struct xkb_state *state,
1437                       xkb_mod_mask_t depressed_mods,
1438                       xkb_mod_mask_t latched_mods,
1439                       xkb_mod_mask_t locked_mods,
1440                       xkb_layout_index_t depressed_layout,
1441                       xkb_layout_index_t latched_layout,
1442                       xkb_layout_index_t locked_layout);
1443 
1444 /**
1445  * Get the keysyms obtained from pressing a particular key in a given
1446  * keyboard state.
1447  *
1448  * Get the keysyms for a key according to the current active layout,
1449  * modifiers and shift level for the key, as determined by a keyboard
1450  * state.
1451  *
1452  * @param[in]  state    The keyboard state object.
1453  * @param[in]  key      The keycode of the key.
1454  * @param[out] syms_out An immutable array of keysyms corresponding the
1455  * key in the given keyboard state.
1456  *
1457  * As an extension to XKB, this function can return more than one keysym.
1458  * If you do not want to handle this case, you can use
1459  * xkb_state_key_get_one_sym() for a simpler interface.
1460  *
1461  * This function does not perform any @ref keysym-transformations.
1462  * (This might change).
1463  *
1464  * @returns The number of keysyms in the syms_out array.  If no keysyms
1465  * are produced by the key in the given keyboard state, returns 0 and sets
1466  * syms_out to NULL.
1467  *
1468  * @memberof xkb_state
1469  */
1470 int
1471 xkb_state_key_get_syms(struct xkb_state *state, xkb_keycode_t key,
1472                        const xkb_keysym_t **syms_out);
1473 
1474 /**
1475  * Get the Unicode/UTF-8 string obtained from pressing a particular key
1476  * in a given keyboard state.
1477  *
1478  * @param[in]  state  The keyboard state object.
1479  * @param[in]  key    The keycode of the key.
1480  * @param[out] buffer A buffer to write the string into.
1481  * @param[in]  size   Size of the buffer.
1482  *
1483  * @warning If the buffer passed is too small, the string is truncated
1484  * (though still NUL-terminated).
1485  *
1486  * @returns The number of bytes required for the string, excluding the
1487  * NUL byte.  If there is nothing to write, returns 0.
1488  *
1489  * You may check if truncation has occurred by comparing the return value
1490  * with the size of @p buffer, similarly to the snprintf(3) function.
1491  * You may safely pass NULL and 0 to @p buffer and @p size to find the
1492  * required size (without the NUL-byte).
1493  *
1494  * This function performs Capitalization and Control @ref
1495  * keysym-transformations.
1496  *
1497  * @memberof xkb_state
1498  * @since 0.4.1
1499  */
1500 int
1501 xkb_state_key_get_utf8(struct xkb_state *state, xkb_keycode_t key,
1502                        char *buffer, size_t size);
1503 
1504 /**
1505  * Get the Unicode/UTF-32 codepoint obtained from pressing a particular
1506  * key in a a given keyboard state.
1507  *
1508  * @returns The UTF-32 representation for the key, if it consists of only
1509  * a single codepoint.  Otherwise, returns 0.
1510  *
1511  * This function performs Capitalization and Control @ref
1512  * keysym-transformations.
1513  *
1514  * @memberof xkb_state
1515  * @since 0.4.1
1516  */
1517 uint32_t
1518 xkb_state_key_get_utf32(struct xkb_state *state, xkb_keycode_t key);
1519 
1520 /**
1521  * Get the single keysym obtained from pressing a particular key in a
1522  * given keyboard state.
1523  *
1524  * This function is similar to xkb_state_key_get_syms(), but intended
1525  * for users which cannot or do not want to handle the case where
1526  * multiple keysyms are returned (in which case this function is
1527  * preferred).
1528  *
1529  * @returns The keysym.  If the key does not have exactly one keysym,
1530  * returns XKB_KEY_NoSymbol
1531  *
1532  * This function performs Capitalization @ref keysym-transformations.
1533  *
1534  * @sa xkb_state_key_get_syms()
1535  * @memberof xkb_state
1536  */
1537 xkb_keysym_t
1538 xkb_state_key_get_one_sym(struct xkb_state *state, xkb_keycode_t key);
1539 
1540 /**
1541  * Get the effective layout index for a key in a given keyboard state.
1542  *
1543  * @returns The layout index for the key in the given keyboard state.  If
1544  * the given keycode is invalid, or if the key is not included in any
1545  * layout at all, returns XKB_LAYOUT_INVALID.
1546  *
1547  * @invariant If the returned layout is valid, the following always holds:
1548  * @code
1549  * xkb_state_key_get_layout(state, key) < xkb_keymap_num_layouts_for_key(keymap, key)
1550  * @endcode
1551  *
1552  * @memberof xkb_state
1553  */
1554 xkb_layout_index_t
1555 xkb_state_key_get_layout(struct xkb_state *state, xkb_keycode_t key);
1556 
1557 /**
1558  * Get the effective shift level for a key in a given keyboard state and
1559  * layout.
1560  *
1561  * @param state The keyboard state.
1562  * @param key The keycode of the key.
1563  * @param layout The layout for which to get the shift level.  This must be
1564  * smaller than:
1565  * @code xkb_keymap_num_layouts_for_key(keymap, key) @endcode
1566  * usually it would be:
1567  * @code xkb_state_key_get_layout(state, key) @endcode
1568  *
1569  * @return The shift level index.  If the key or layout are invalid,
1570  * returns XKB_LEVEL_INVALID.
1571  *
1572  * @invariant If the returned level is valid, the following always holds:
1573  * @code
1574  * xkb_state_key_get_level(state, key, layout) < xkb_keymap_num_levels_for_key(keymap, key, layout)
1575  * @endcode
1576  *
1577  * @memberof xkb_state
1578  */
1579 xkb_level_index_t
1580 xkb_state_key_get_level(struct xkb_state *state, xkb_keycode_t key,
1581                         xkb_layout_index_t layout);
1582 
1583 /**
1584  * Match flags for xkb_state_mod_indices_are_active() and
1585  * xkb_state_mod_names_are_active(), specifying the conditions for a
1586  * successful match.  XKB_STATE_MATCH_NON_EXCLUSIVE is bitmaskable with
1587  * the other modes.
1588  */
1589 enum xkb_state_match {
1590     /** Returns true if any of the modifiers are active. */
1591     XKB_STATE_MATCH_ANY = (1 << 0),
1592     /** Returns true if all of the modifiers are active. */
1593     XKB_STATE_MATCH_ALL = (1 << 1),
1594     /** Makes matching non-exclusive, i.e. will not return false if a
1595      *  modifier not specified in the arguments is active. */
1596     XKB_STATE_MATCH_NON_EXCLUSIVE = (1 << 16)
1597 };
1598 
1599 /**
1600  * The counterpart to xkb_state_update_mask for modifiers, to be used on
1601  * the server side of serialization.
1602  *
1603  * @param state      The keyboard state.
1604  * @param components A mask of the modifier state components to serialize.
1605  * State components other than XKB_STATE_MODS_* are ignored.
1606  * If XKB_STATE_MODS_EFFECTIVE is included, all other state components are
1607  * ignored.
1608  *
1609  * @returns A xkb_mod_mask_t representing the given components of the
1610  * modifier state.
1611  *
1612  * This function should not be used in regular clients; please use the
1613  * xkb_state_mod_*_is_active API instead.
1614  *
1615  * @memberof xkb_state
1616  */
1617 xkb_mod_mask_t
1618 xkb_state_serialize_mods(struct xkb_state *state,
1619                          enum xkb_state_component components);
1620 
1621 /**
1622  * The counterpart to xkb_state_update_mask for layouts, to be used on
1623  * the server side of serialization.
1624  *
1625  * @param state      The keyboard state.
1626  * @param components A mask of the layout state components to serialize.
1627  * State components other than XKB_STATE_LAYOUT_* are ignored.
1628  * If XKB_STATE_LAYOUT_EFFECTIVE is included, all other state components are
1629  * ignored.
1630  *
1631  * @returns A layout index representing the given components of the
1632  * layout state.
1633  *
1634  * This function should not be used in regular clients; please use the
1635  * xkb_state_layout_*_is_active API instead.
1636  *
1637  * @memberof xkb_state
1638  */
1639 xkb_layout_index_t
1640 xkb_state_serialize_layout(struct xkb_state *state,
1641                            enum xkb_state_component components);
1642 
1643 /**
1644  * Test whether a modifier is active in a given keyboard state by name.
1645  *
1646  * @returns 1 if the modifier is active, 0 if it is not.  If the modifier
1647  * name does not exist in the keymap, returns -1.
1648  *
1649  * @memberof xkb_state
1650  */
1651 int
1652 xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
1653                              enum xkb_state_component type);
1654 
1655 /**
1656  * Test whether a set of modifiers are active in a given keyboard state by
1657  * name.
1658  *
1659  * @param state The keyboard state.
1660  * @param type  The component of the state against which to match the
1661  * given modifiers.
1662  * @param match The manner by which to match the state against the
1663  * given modifiers.
1664  * @param ...   The set of of modifier names to test, terminated by a NULL
1665  * argument (sentinel).
1666  *
1667  * @returns 1 if the modifiers are active, 0 if they are not.  If any of
1668  * the modifier names do not exist in the keymap, returns -1.
1669  *
1670  * @memberof xkb_state
1671  */
1672 int
1673 xkb_state_mod_names_are_active(struct xkb_state *state,
1674                                enum xkb_state_component type,
1675                                enum xkb_state_match match,
1676                                ...);
1677 
1678 /**
1679  * Test whether a modifier is active in a given keyboard state by index.
1680  *
1681  * @returns 1 if the modifier is active, 0 if it is not.  If the modifier
1682  * index is invalid in the keymap, returns -1.
1683  *
1684  * @memberof xkb_state
1685  */
1686 int
1687 xkb_state_mod_index_is_active(struct xkb_state *state, xkb_mod_index_t idx,
1688                               enum xkb_state_component type);
1689 
1690 /**
1691  * Test whether a set of modifiers are active in a given keyboard state by
1692  * index.
1693  *
1694  * @param state The keyboard state.
1695  * @param type  The component of the state against which to match the
1696  * given modifiers.
1697  * @param match The manner by which to match the state against the
1698  * given modifiers.
1699  * @param ...   The set of of modifier indices to test, terminated by a
1700  * XKB_MOD_INVALID argument (sentinel).
1701  *
1702  * @returns 1 if the modifiers are active, 0 if they are not.  If any of
1703  * the modifier indices are invalid in the keymap, returns -1.
1704  *
1705  * @memberof xkb_state
1706  */
1707 int
1708 xkb_state_mod_indices_are_active(struct xkb_state *state,
1709                                  enum xkb_state_component type,
1710                                  enum xkb_state_match match,
1711                                  ...);
1712 
1713 /**
1714  * @page consumed-modifiers Consumed Modifiers
1715  * @parblock
1716  *
1717  * Some functions, like xkb_state_key_get_syms(), look at the state of
1718  * the modifiers in the keymap and derive from it the correct shift level
1719  * to use for the key.  For example, in a US layout, pressing the key
1720  * labeled \<A\> while the Shift modifier is active, generates the keysym
1721  * 'A'.  In this case, the Shift modifier is said to be "consumed".
1722  * However, the Num Lock modifier does not affect this translation at all,
1723  * even if it is active, so it is not consumed by this translation.
1724  *
1725  * It may be desirable for some application to not reuse consumed modifiers
1726  * for further processing, e.g. for hotkeys or keyboard shortcuts.  To
1727  * understand why, consider some requirements from a standard shortcut
1728  * mechanism, and how they are implemented:
1729  *
1730  * 1. The shortcut's modifiers must match exactly to the state.  For
1731  *    example, it is possible to bind separate actions to \<Alt\>\<Tab\>
1732  *    and to \<Alt\>\<Shift\>\<Tab\>.  Further, if only \<Alt\>\<Tab\> is
1733  *    bound to an action, pressing \<Alt\>\<Shift\>\<Tab\> should not
1734  *    trigger the shortcut.
1735  *    Effectively, this means that the modifiers are compared using the
1736  *    equality operator (==).
1737  *
1738  * 2. Only relevant modifiers are considered for the matching.  For example,
1739  *    Caps Lock and Num Lock should not generally affect the matching, e.g.
1740  *    when matching \<Alt\>\<Tab\> against the state, it does not matter
1741  *    whether Num Lock is active or not.  These relevant, or "significant",
1742  *    modifiers usually include Alt, Control, Shift, Super and similar.
1743  *    Effectively, this means that non-significant modifiers are masked out,
1744  *    before doing the comparison as described above.
1745  *
1746  * 3. The matching must be independent of the layout/keymap.  For example,
1747  *    the \<Plus\> (+) symbol is found on the first level on some layouts,
1748  *    but requires holding Shift on others.  If you simply bind the action
1749  *    to the \<Plus\> keysym, it would work for the unshifted kind, but
1750  *    not for the others, because the match against Shift would fail.  If
1751  *    you bind the action to \<Shift\>\<Plus\>, only the shifted kind would
1752  *    work.  So what is needed is to recognize that Shift is used up in the
1753  *    translation of the keysym itself, and therefore should not be included
1754  *    in the matching.
1755  *    Effectively, this means that consumed modifiers (Shift in this example)
1756  *    are masked out as well, before doing the comparison.
1757  *
1758  * In summary, this is approximately how the matching would be performed:
1759  * @code
1760  *   (keysym == shortcut_keysym) &&
1761  *   ((state_mods & ~consumed_mods & significant_mods) == shortcut_mods)
1762  * @endcode
1763  *
1764  * @c state_mods are the modifiers reported by
1765  * xkb_state_mod_index_is_active() and similar functions.
1766  * @c consumed_mods are the modifiers reported by
1767  * xkb_state_mod_index_is_consumed() and similar functions.
1768  * @c significant_mods are decided upon by the application/toolkit/user;
1769  * it is up to them to decide whether these are configurable or hard-coded.
1770  *
1771  * @endparblock
1772  */
1773 
1774 /**
1775  * Consumed modifiers mode.
1776  *
1777  * There are several possible methods for deciding which modifiers are
1778  * consumed and which are not, each applicable for different systems or
1779  * situations. The mode selects the method to use.
1780  *
1781  * Keep in mind that in all methods, the keymap may decide to "preserve"
1782  * a modifier, meaning it is not reported as consumed even if it would
1783  * have otherwise.
1784  */
1785 enum xkb_consumed_mode {
1786     /**
1787      * This is the mode defined in the XKB specification and used by libX11.
1788      *
1789      * A modifier is consumed if and only if it *may affect* key translation.
1790      *
1791      * For example, if `Control+Alt+<Backspace>` produces some assigned keysym,
1792      * then when pressing just `<Backspace>`, `Control` and `Alt` are consumed,
1793      * even though they are not active, since if they *were* active they would
1794      * have affected key translation.
1795      */
1796     XKB_CONSUMED_MODE_XKB,
1797     /**
1798      * This is the mode used by the GTK+ toolkit.
1799      *
1800      * The mode consists of the following two independent heuristics:
1801      *
1802      * - The currently active set of modifiers, excluding modifiers which do
1803      *   not affect the key (as described for @ref XKB_CONSUMED_MODE_XKB), are
1804      *   considered consumed, if the keysyms produced when all of them are
1805      *   active are different from the keysyms produced when no modifiers are
1806      *   active.
1807      *
1808      * - A single modifier is considered consumed if the keysyms produced for
1809      *   the key when it is the only active modifier are different from the
1810      *   keysyms produced when no modifiers are active.
1811      */
1812     XKB_CONSUMED_MODE_GTK
1813 };
1814 
1815 /**
1816  * Get the mask of modifiers consumed by translating a given key.
1817  *
1818  * @param state The keyboard state.
1819  * @param key   The keycode of the key.
1820  * @param mode  The consumed modifiers mode to use; see enum description.
1821  *
1822  * @returns a mask of the consumed modifiers.
1823  *
1824  * @memberof xkb_state
1825  * @since 0.7.0
1826  */
1827 xkb_mod_mask_t
1828 xkb_state_key_get_consumed_mods2(struct xkb_state *state, xkb_keycode_t key,
1829                                  enum xkb_consumed_mode mode);
1830 
1831 /**
1832  * Same as xkb_state_key_get_consumed_mods2() with mode XKB_CONSUMED_MODE_XKB.
1833  *
1834  * @memberof xkb_state
1835  * @since 0.4.1
1836  */
1837 xkb_mod_mask_t
1838 xkb_state_key_get_consumed_mods(struct xkb_state *state, xkb_keycode_t key);
1839 
1840 /**
1841  * Test whether a modifier is consumed by keyboard state translation for
1842  * a key.
1843  *
1844  * @param state The keyboard state.
1845  * @param key   The keycode of the key.
1846  * @param idx   The index of the modifier to check.
1847  * @param mode  The consumed modifiers mode to use; see enum description.
1848  *
1849  * @returns 1 if the modifier is consumed, 0 if it is not.  If the modifier
1850  * index is not valid in the keymap, returns -1.
1851  *
1852  * @sa xkb_state_mod_mask_remove_consumed()
1853  * @sa xkb_state_key_get_consumed_mods()
1854  * @memberof xkb_state
1855  * @since 0.7.0
1856  */
1857 int
1858 xkb_state_mod_index_is_consumed2(struct xkb_state *state,
1859                                  xkb_keycode_t key,
1860                                  xkb_mod_index_t idx,
1861                                  enum xkb_consumed_mode mode);
1862 
1863 /**
1864  * Same as xkb_state_mod_index_is_consumed2() with mode XKB_CONSUMED_MOD_XKB.
1865  *
1866  * @memberof xkb_state
1867  * @since 0.4.1
1868  */
1869 int
1870 xkb_state_mod_index_is_consumed(struct xkb_state *state, xkb_keycode_t key,
1871                                 xkb_mod_index_t idx);
1872 
1873 /**
1874  * Remove consumed modifiers from a modifier mask for a key.
1875  *
1876  * @deprecated Use xkb_state_key_get_consumed_mods2() instead.
1877  *
1878  * Takes the given modifier mask, and removes all modifiers which are
1879  * consumed for that particular key (as in xkb_state_mod_index_is_consumed()).
1880  *
1881  * @sa xkb_state_mod_index_is_consumed()
1882  * @memberof xkb_state
1883  */
1884 xkb_mod_mask_t
1885 xkb_state_mod_mask_remove_consumed(struct xkb_state *state, xkb_keycode_t key,
1886                                    xkb_mod_mask_t mask);
1887 
1888 /**
1889  * Test whether a layout is active in a given keyboard state by name.
1890  *
1891  * @returns 1 if the layout is active, 0 if it is not.  If no layout with
1892  * this name exists in the keymap, return -1.
1893  *
1894  * If multiple layouts in the keymap have this name, the one with the lowest
1895  * index is tested.
1896  *
1897  * @sa xkb_layout_index_t
1898  * @memberof xkb_state
1899  */
1900 int
1901 xkb_state_layout_name_is_active(struct xkb_state *state, const char *name,
1902                                 enum xkb_state_component type);
1903 
1904 /**
1905  * Test whether a layout is active in a given keyboard state by index.
1906  *
1907  * @returns 1 if the layout is active, 0 if it is not.  If the layout index
1908  * is not valid in the keymap, returns -1.
1909  *
1910  * @sa xkb_layout_index_t
1911  * @memberof xkb_state
1912  */
1913 int
1914 xkb_state_layout_index_is_active(struct xkb_state *state,
1915                                  xkb_layout_index_t idx,
1916                                  enum xkb_state_component type);
1917 
1918 /**
1919  * Test whether a LED is active in a given keyboard state by name.
1920  *
1921  * @returns 1 if the LED is active, 0 if it not.  If no LED with this name
1922  * exists in the keymap, returns -1.
1923  *
1924  * @sa xkb_led_index_t
1925  * @memberof xkb_state
1926  */
1927 int
1928 xkb_state_led_name_is_active(struct xkb_state *state, const char *name);
1929 
1930 /**
1931  * Test whether a LED is active in a given keyboard state by index.
1932  *
1933  * @returns 1 if the LED is active, 0 if it not.  If the LED index is not
1934  * valid in the keymap, returns -1.
1935  *
1936  * @sa xkb_led_index_t
1937  * @memberof xkb_state
1938  */
1939 int
1940 xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx);
1941 
1942 /** @} */
1943 
1944 /* Leave this include last, so it can pick up our types, etc. */
1945 #include <xkbcommon/xkbcommon-compat.h>
1946 
1947 #ifdef __cplusplus
1948 } /* extern "C" */
1949 #endif
1950 
1951 #endif /* _XKBCOMMON_H_ */
1952