xkbcommon.h 58 KB

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