fb5d4505240633cd8bcde505962ea57a9ac7fa17
[platform/upstream/libxkbcommon.git] / xkbcommon / xkbcommon.h
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  *
58  * Permission is hereby granted, free of charge, to any person obtaining a
59  * copy of this software and associated documentation files (the "Software"),
60  * to deal in the Software without restriction, including without limitation
61  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
62  * and/or sell copies of the Software, and to permit persons to whom the
63  * Software is furnished to do so, subject to the following conditions:
64  *
65  * The above copyright notice and this permission notice (including the next
66  * paragraph) shall be included in all copies or substantial portions of the
67  * Software.
68  *
69  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
72  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
74  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
75  * DEALINGS IN THE SOFTWARE.
76  *
77  * Author: Daniel Stone <daniel@fooishbar.org>
78  */
79
80 #ifndef _XKBCOMMON_H_
81 #define _XKBCOMMON_H_
82
83 #include <stdint.h>
84 #include <stdio.h>
85 #include <stdarg.h>
86
87 #include <xkbcommon/xkbcommon-names.h>
88 #include <xkbcommon/xkbcommon-keysyms.h>
89
90 typedef uint32_t xkb_keycode_t;
91 typedef uint32_t xkb_keysym_t;
92 typedef uint32_t xkb_mod_index_t;
93 typedef uint32_t xkb_mod_mask_t;
94 typedef uint32_t xkb_group_index_t;
95 typedef uint32_t xkb_group_mask_t;
96 typedef uint32_t xkb_led_index_t;
97
98 #define XKB_MOD_INVALID     (0xffffffff)
99 #define XKB_GROUP_INVALID   (0xffffffff)
100 #define XKB_KEYCODE_INVALID (0xffffffff)
101 #define XKB_LED_INVALID     (0xffffffff)
102
103 #define XKB_KEYCODE_MAX     (0xffffffff - 1)
104 #define xkb_keycode_is_legal_ext(kc) (kc <= XKB_KEYCODE_MAX)
105 #define xkb_keycode_is_legal_x11(kc) (kc >= 8 && kc <= 255)
106
107 /**
108  * Names to compile a keymap with, also known as RMLVO.  These names together
109  * should be the primary identifier for a keymap.
110  */
111 struct xkb_rule_names {
112     const char *rules;
113     const char *model;
114     const char *layout;
115     const char *variant;
116     const char *options;
117 };
118
119 /**
120  * Opaque context object; may only be created, accessed, manipulated and
121  * destroyed through the xkb_context_*() API.
122  */
123 struct xkb_context;
124
125 /**
126  * Opaque keymap object; may only be created, accessed, manipulated and
127  * destroyed through the xkb_state_*() API.
128  */
129 struct xkb_keymap;
130
131 /**
132  * Opaque state object; may only be created, accessed, manipulated and
133  * destroyed through the xkb_state_*() API.
134  */
135 struct xkb_state;
136
137 #ifdef __cplusplus
138 extern "C" {
139 #endif
140
141 /*
142  * Returns the name for a keysym as a string; will return unknown Unicode
143  * codepoints as "Ua1b2", and other unknown keysyms as "0xabcd1234".
144  * If the buffer passed is too small, the string is truncated; a size of
145  * at least 32 bytes is recommended.
146  */
147 void
148 xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size);
149
150 /*
151  * See xkb_keysym_get_name comments: this function will accept any string
152  * from that function.
153  */
154 xkb_keysym_t
155 xkb_keysym_from_name(const char *s);
156
157 /**
158  * Return the printable representation of the keystring in Unicode/UTF-8.
159  * The buffer passed must be at least 7 bytes long.  The return value
160  * is the number of bytes written to the buffer.  A return value of zero
161  * means that the keysym does not have a known printable Unicode
162  * representation, and a return value of -1 means that the buffer was too
163  * small to contain the return.
164  */
165 int
166 xkb_keysym_to_utf8(xkb_keysym_t keysym, char *buffer, size_t size);
167
168 /**
169  * Returns the Unicode/UTF-32 representation of the provided keysym, which is
170  * also compatible with UCS-4.  A return value of zero means the keysym does
171  * not have a known printable Unicode representation.
172  */
173 uint32_t
174 xkb_keysym_to_utf32(xkb_keysym_t keysym);
175
176 /**
177  * @defgroup context XKB contexts
178  * Every keymap compilation request must have an XKB context associated with
179  * it.  The context keeps around state such as the include path.
180  *
181  * @{
182  */
183
184 enum xkb_context_flags {
185     /** Create this context with an empty include path. */
186     XKB_CONTEXT_NO_DEFAULT_INCLUDES = 1,
187 };
188
189 /**
190  * Returns a new XKB context, or NULL on failure.  If successful, the caller
191  * holds a reference on the context, and must free it when finished with
192  * xkb_context_unref().
193  */
194 struct xkb_context *
195 xkb_context_new(enum xkb_context_flags flags);
196
197 /**
198  * Appends a new entry to the include path used for keymap compilation.
199  * Returns 1 on success, or 0 if the include path could not be added or is
200  * inaccessible.
201  */
202 int
203 xkb_context_include_path_append(struct xkb_context *context, const char *path);
204
205 /**
206  * Appends the default include paths to the context's current include path.
207  * Returns 1 on success, or 0 if the primary include path could not be
208  * added.
209  */
210 int
211 xkb_context_include_path_append_default(struct xkb_context *context);
212
213 /**
214  * Removes all entries from the context's include path, and inserts the
215  * default paths.  Returns 1 on success, or 0 if the primary include path
216  * could not be added.
217  */
218 int
219 xkb_context_include_path_reset_defaults(struct xkb_context *context);
220
221 /**
222  * Removes all entries from the context's include path.
223  */
224 void
225 xkb_context_include_path_clear(struct xkb_context *context);
226
227 /**
228  * Returns the number of include paths currently active in the context.
229  */
230 unsigned int
231 xkb_context_num_include_paths(struct xkb_context *context);
232
233 /**
234  * Returns the include path at the specified index within the context.
235  */
236 const char *
237 xkb_context_include_path_get(struct xkb_context *context, unsigned int index);
238
239 /**
240  * Takes a new reference on an XKB context.
241  */
242 struct xkb_context *
243 xkb_context_ref(struct xkb_context *context);
244
245 /**
246  * Releases a reference on an XKB context, and possibly frees it.
247  */
248 void
249 xkb_context_unref(struct xkb_context *context);
250
251 /** @} */
252
253 /**
254  * @defgroup logging Logging handling
255  * These functions allow you to manipulate how logging from this library
256  * will be handled.
257  *
258  * @{
259  */
260
261 enum xkb_log_level {
262     /** Log critical internal errors only */
263     XKB_LOG_LEVEL_CRITICAL = 10,
264     /** Log all errors */
265     XKB_LOG_LEVEL_ERROR = 20,
266     /** Log warnings and errors */
267     XKB_LOG_LEVEL_WARNING = 30,
268     /** Log information, warnings, and errors */
269     XKB_LOG_LEVEL_INFO = 40,
270     /** Log all the things */
271     XKB_LOG_LEVEL_DEBUG = 50,
272 };
273
274 /**
275  * Sets the function to be called for logging messages.
276  * Passing NULL restores the default function, which logs to stderr.
277  **/
278 void
279 xkb_set_log_fn(struct xkb_context *context,
280                void (*log_fn)(struct xkb_context *context,
281                               enum xkb_log_level level,
282                               const char *format, va_list args));
283 /**
284  * Sets the current logging level.  The value controls which messages
285  * are logged.  The default level is XKB_LOG_LEVEL_ERROR.
286  *
287  * The environment variable XKB_LOG, if set, overrides the default value
288  * and may be specified as a level number or name.
289  */
290 void
291 xkb_set_log_level(struct xkb_context *context, enum xkb_log_level level);
292
293 /**
294  * Returns the current logging level.
295  */
296 enum xkb_log_level
297 xkb_get_log_level(struct xkb_context *context);
298
299 /**
300  * Sets the current logging verbosity, a value from 0 to 10.
301  *
302  * The library can generate a number of warnings which are not helpful to
303  * ordinary users of the library.  The verbosity may be increased if more
304  * information is desired (e.g. when developing a keymap).  Defaults to 0.
305  * The environment variable XKB_VERBOSITY, if set, overrdies the default
306  * value.
307  *
308  * Note that most verbose messages are of level XKB_LOG_LEVEL_WARNING
309  * or lower.
310  */
311 void
312 xkb_set_log_verbosity(struct xkb_context *ctx, int verbosity);
313
314 /**
315  * Returns the current logging verbosity.
316  */
317 int
318 xkb_get_log_verbosity(struct xkb_context *ctx);
319
320 /**
321  * Retrieves stored data pointer from the context.  This might be useful
322  * to access from callbacks like a custom logging function.
323  *
324  * If context is NULL, returns NULL.
325  **/
326 void *
327 xkb_get_user_data(struct xkb_context *context);
328
329 /**
330  * Store custom user data in the context.
331  */
332 void
333 xkb_set_user_data(struct xkb_context *context, void *user_data);
334
335 /** @} */
336
337 /**
338  * @defgroup map Keymap management
339  * These utility functions allow you to create and deallocate XKB keymaps.
340  *
341  * @{
342  */
343
344 enum xkb_map_compile_flags {
345     /** Apparently you can't have empty enums.  What a drag. */
346     XKB_MAP_COMPILE_PLACEHOLDER = 0,
347 };
348
349 /**
350  * The primary keymap entry point: creates a new XKB keymap from a set of
351  * RMLVO (Rules + Model + Layout + Variant + Option) names.
352  *
353  * You should almost certainly be using this and nothing else to create
354  * keymaps.
355  */
356 struct xkb_keymap *
357 xkb_map_new_from_names(struct xkb_context *context,
358                        const struct xkb_rule_names *names,
359                        enum xkb_map_compile_flags flags);
360
361 enum xkb_keymap_format {
362     /** The current/classic XKB text format, as generated by xkbcomp -xkb. */
363     XKB_KEYMAP_FORMAT_TEXT_V1 = 1,
364 };
365
366 /**
367  * Creates an XKB keymap from a full text XKB keymap passed into the
368  * file.
369  */
370 struct xkb_keymap *
371 xkb_map_new_from_file(struct xkb_context *context, FILE *file,
372                       enum xkb_keymap_format format,
373                       enum xkb_map_compile_flags flags);
374
375 /**
376  * Creates an XKB keymap from a full text XKB keymap serialized into one
377  * enormous string.
378  */
379 struct xkb_keymap *
380 xkb_map_new_from_string(struct xkb_context *context, const char *string,
381                         enum xkb_keymap_format format,
382                         enum xkb_map_compile_flags flags);
383
384 /**
385  * Returns the compiled XKB map as a string which can later be fed back into
386  * xkb_map_new_from_string to return the exact same keymap.
387  */
388 char *
389 xkb_map_get_as_string(struct xkb_keymap *keymap);
390
391 /**
392  * Takes a new reference on a keymap.
393  */
394 struct xkb_keymap *
395 xkb_map_ref(struct xkb_keymap *keymap);
396
397 /**
398  * Releases a reference on a keymap.
399  */
400 void
401 xkb_map_unref(struct xkb_keymap *keymap);
402
403 /** @} */
404
405 /**
406  * @defgroup components XKB state components
407  * Allows enumeration of state components such as modifiers and groups within
408  * the current keymap.
409  *
410  * @{
411  */
412
413 /**
414  * Returns the number of modifiers active in the keymap.
415  */
416 xkb_mod_index_t
417 xkb_map_num_mods(struct xkb_keymap *keymap);
418
419 /**
420  * Returns the name of the modifier specified by 'idx', or NULL if invalid.
421  */
422 const char *
423 xkb_map_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx);
424
425 /**
426  * Returns the index of the modifier specified by 'name', or XKB_MOD_INVALID.
427  */
428 xkb_mod_index_t
429 xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name);
430
431 /**
432  * Returns the number of groups active in the keymap.
433  */
434 xkb_group_index_t
435 xkb_map_num_groups(struct xkb_keymap *keymap);
436
437 /**
438  * Returns the name of the group specified by 'idx', or NULL if invalid.
439  */
440 const char *
441 xkb_map_group_get_name(struct xkb_keymap *keymap, xkb_group_index_t idx);
442
443 /**
444  * Returns the index of the group specified by 'name', or XKB_GROUP_INVALID.
445  */
446 xkb_group_index_t
447 xkb_map_group_get_index(struct xkb_keymap *keymap, const char *name);
448
449 /**
450  * Returns the number of groups active for the specified key.
451  */
452 xkb_group_index_t
453 xkb_key_num_groups(struct xkb_keymap *keymap, xkb_keycode_t key);
454
455 /**
456  * Returns 1 if the key should repeat, or 0 otherwise.
457  */
458 int
459 xkb_key_repeats(struct xkb_keymap *keymap, xkb_keycode_t key);
460
461 /**
462  * Returns the number of LEDs in the given map.
463  */
464 xkb_led_index_t
465 xkb_map_num_leds(struct xkb_keymap *keymap);
466
467 /**
468  * Returns the name of the LED specified by 'idx', or NULL if invalid.
469  */
470 const char *
471 xkb_map_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx);
472
473 /**
474  * Returns the index of the LED specified by 'name', or XKB_LED_INVALID.
475  */
476 xkb_led_index_t
477 xkb_map_led_get_index(struct xkb_keymap *keymap, const char *name);
478
479 /** @} */
480
481 /**
482  * @defgroup state XKB state objects
483  * Creation, destruction and manipulation of keyboard state objects,
484  * representing modifier and group state.
485  *
486  * @{
487  */
488
489 /**
490  * Returns a new XKB state object for use with the given keymap, or NULL on
491  * failure.
492  */
493 struct xkb_state *
494 xkb_state_new(struct xkb_keymap *keymap);
495
496 /**
497  * Takes a new reference on a state object.
498  */
499 struct xkb_state *
500 xkb_state_ref(struct xkb_state *state);
501
502 /**
503  * Unrefs and potentially deallocates a state object; the caller must not
504  * use the state object after calling this.
505  */
506 void
507 xkb_state_unref(struct xkb_state *state);
508
509 /**
510  * Get the keymap from which the state object was created.  Does not take
511  * a new reference on the map; you must explicitly reference it yourself
512  * if you plan to use it beyond the lifetime of the state.
513  */
514 struct xkb_keymap *
515 xkb_state_get_map(struct xkb_state *state);
516
517 enum xkb_key_direction {
518     XKB_KEY_UP,
519     XKB_KEY_DOWN,
520 };
521
522 /**
523  * Updates a state object to reflect the given key being pressed or released.
524  */
525 void
526 xkb_state_update_key(struct xkb_state *state, xkb_keycode_t key,
527                      enum xkb_key_direction direction);
528
529 /**
530  * Gives the symbols obtained from pressing a particular key with the given
531  * state.  *syms_out will be set to point to an array of keysyms, with the
532  * return value being the number of symbols in *syms_out.  If the return
533  * value is 0, *syms_out will be set to NULL, as there are no symbols produced
534  * by this event.
535  *
536  * This should be called before xkb_state_update_key.
537  */
538 int
539 xkb_key_get_syms(struct xkb_state *state, xkb_keycode_t key,
540                  const xkb_keysym_t **syms_out);
541
542 /**
543  * Modifier and group types for state objects.  This enum is bitmaskable,
544  * e.g. (XKB_STATE_DEPRESSED | XKB_STATE_LATCHED) is valid to exclude
545  * locked modifiers.
546  */
547 enum xkb_state_component {
548     /** A key holding this modifier or group is currently physically
549      *  depressed; also known as 'base'. */
550     XKB_STATE_DEPRESSED = (1 << 0),
551     /** Modifier or group is latched, i.e. will be unset after the next
552      *  non-modifier key press. */
553     XKB_STATE_LATCHED = (1 << 1),
554     /** Modifier or group is locked, i.e. will be unset after the key
555      *  provoking the lock has been pressed again. */
556     XKB_STATE_LOCKED = (1 << 2),
557     /** Combinatination of depressed, latched, and locked. */
558     XKB_STATE_EFFECTIVE =
559         (XKB_STATE_DEPRESSED | XKB_STATE_LATCHED | XKB_STATE_LOCKED),
560 };
561
562 /**
563  * Match flags for xkb_state_mod_indices_are_active and
564  * xkb_state_mod_names_are_active, specifying how the conditions for a
565  * successful match.  XKB_STATE_MATCH_NON_EXCLUSIVE is bitmaskable with
566  * the other modes.
567  */
568 enum xkb_state_match {
569     /** Returns true if any of the modifiers are active. */
570     XKB_STATE_MATCH_ANY = (1 << 0),
571     /** Returns true if all of the modifiers are active. */
572     XKB_STATE_MATCH_ALL = (1 << 1),
573     /** Makes matching non-exclusive, i.e. will not return false if a
574      *  modifier not specified in the arguments is active. */
575     XKB_STATE_MATCH_NON_EXCLUSIVE = (1 << 16),
576 };
577
578 /**
579  * Updates a state object from a set of explicit masks.  This entrypoint is
580  * really only for window systems and the like, where a master process
581  * holds an xkb_state, then serializes it over a wire protocol, and clients
582  * then use the serialization to feed in to their own xkb_state.
583  *
584  * All parameters must always be passed, or the resulting state may be
585  * incoherent.
586  *
587  * The serialization is lossy and will not survive round trips; it must only
588  * be used to feed slave state objects, and must not be used to update the
589  * master state.
590  *
591  * Please do not use this unless you fit the description above.
592  */
593 void
594 xkb_state_update_mask(struct xkb_state *state, xkb_mod_mask_t base_mods,
595                       xkb_mod_mask_t latched_mods, xkb_mod_mask_t locked_mods,
596                       xkb_group_index_t base_group,
597                       xkb_group_index_t latched_group,
598                       xkb_group_index_t locked_group);
599
600 /**
601  * The counterpart to xkb_state_update_mask, to be used on the server side
602  * of serialization.  Returns a xkb_mod_mask_t representing the given
603  * component(s) of the state.
604  *
605  * This function should not be used in regular clients; please use the
606  * xkb_state_mod_*_is_active or xkb_state_foreach_active_mod API instead.
607  *
608  * Can return NULL on failure.
609  */
610 xkb_mod_mask_t
611 xkb_state_serialize_mods(struct xkb_state *state,
612                          enum xkb_state_component component);
613
614 /**
615  * The group equivalent of xkb_state_serialize_mods: please see its
616  * documentation.
617  */
618 xkb_group_index_t
619 xkb_state_serialize_group(struct xkb_state *state,
620                           enum xkb_state_component component);
621
622 /**
623  * Returns 1 if the modifier specified by 'name' is active in the manner
624  * specified by 'type', 0 if it is unset, or -1 if the modifier does not
625  * exist in the map.
626  */
627 int
628 xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
629                              enum xkb_state_component type);
630
631 /**
632  * Returns 1 if the modifiers specified by the varargs (NULL-terminated
633  * strings, with a NULL sentinel) are active in the manner specified by
634  * 'match', 0 otherwise, or -1 if any of the modifiers do not exist in
635  * the map.
636  */
637 int
638 xkb_state_mod_names_are_active(struct xkb_state *state,
639                                enum xkb_state_component type,
640                                enum xkb_state_match match,
641                                ...);
642
643 /**
644  * Returns 1 if the modifier specified by 'idx' is active in the manner
645  * specified by 'type', 0 if it is unset, or -1 if the modifier does not
646  * exist in the current map.
647  */
648 int
649 xkb_state_mod_index_is_active(struct xkb_state *state, xkb_mod_index_t idx,
650                               enum xkb_state_component type);
651
652 /**
653  * Returns 1 if the modifiers specified by the varargs (of type
654  * xkb_mod_index_t, with a XKB_MOD_INVALID sentinel) are active in the
655  * manner specified by 'match' and 'type', 0 otherwise, or -1 if any of
656  * the modifiers do not exist in the map.
657  */
658 int
659 xkb_state_mod_indices_are_active(struct xkb_state *state,
660                                  enum xkb_state_component type,
661                                  enum xkb_state_match match,
662                                  ...);
663
664 /**
665  * Returns 1 if the modifier specified by 'idx' is used in the
666  * translation of the keycode 'key' to the key symbols obtained by
667  * pressing it (as in xkb_key_get_syms), given the current state.
668  * Returns 0 otherwise.
669  */
670 int
671 xkb_key_mod_index_is_consumed(struct xkb_state *state, xkb_keycode_t key,
672                               xkb_mod_index_t idx);
673
674 /**
675  * Takes the given modifier mask, and removes all modifiers which are
676  * marked as 'consumed' (see xkb_key_mod_index_is_consumed definition)
677  * for that particular key.
678  */
679 xkb_mod_mask_t
680 xkb_key_mod_mask_remove_consumed(struct xkb_state *state, xkb_keycode_t key,
681                                  xkb_mod_mask_t mask);
682
683 /**
684  * Returns 1 if the group specified by 'name' is active in the manner
685  * specified by 'type', 0 if it is unset, or -1 if the group does not
686  * exist in the current map.
687  */
688 int
689 xkb_state_group_name_is_active(struct xkb_state *state, const char *name,
690                                enum xkb_state_component type);
691
692 /**
693  * Returns 1 if the group specified by 'idx' is active in the manner
694  * specified by 'type', 0 if it is unset, or -1 if the group does not
695  * exist in the current map.
696  */
697 int
698 xkb_state_group_index_is_active(struct xkb_state *state,
699                                 xkb_group_index_t idx,
700                                 enum xkb_state_component type);
701
702 /**
703  * Returns 1 if the LED specified by 'name' is active, 0 if it is unset, or
704  * -1 if the LED does not exist in the current map.
705  */
706 int
707 xkb_state_led_name_is_active(struct xkb_state *state, const char *name);
708
709 /**
710  * Returns 1 if the LED specified by 'idx' is active, 0 if it is unset, or
711  * -1 if the LED does not exist in the current map.
712  */
713 int
714 xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx);
715
716 /** @} */
717
718 /* Leave this include last, so it can pick up our types, etc. */
719 #include <xkbcommon/xkbcommon-compat.h>
720
721 #ifdef __cplusplus
722 } /* extern "C" */
723 #endif
724
725 #endif /* _XKBCOMMON_H_ */