xkblib.nim 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. # $Xorg: XKBlib.h,v 1.6 2000/08/17 19:45:03 cpqbld Exp $
  2. #************************************************************
  3. #Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
  4. #
  5. #Permission to use, copy, modify, and distribute this
  6. #software and its documentation for any purpose and without
  7. #fee is hereby granted, provided that the above copyright
  8. #notice appear in all copies and that both that copyright
  9. #notice and this permission notice appear in supporting
  10. #documentation, and that the name of Silicon Graphics not be
  11. #used in advertising or publicity pertaining to distribution
  12. #of the software without specific prior written permission.
  13. #Silicon Graphics makes no representation about the suitability
  14. #of this software for any purpose. It is provided "as is"
  15. #without any express or implied warranty.
  16. #
  17. #SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  18. #SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  19. #AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
  20. #GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  21. #DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING `from` LOSS OF USE,
  22. #DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  23. #OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
  24. #THE USE OR PERFORMANCE OF THIS SOFTWARE.
  25. #
  26. #********************************************************/
  27. # $XFree86: xc/lib/X11/XKBlib.h,v 3.3 2001/08/01 00:44:38 tsi Exp $
  28. #
  29. # Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
  30. #
  31. #Thanks:
  32. # I want to thanks to oliebol for putting up with all of the problems that was found
  33. # while translating this code. ;)
  34. #
  35. # I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my
  36. # weird questions ;)
  37. #
  38. # Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to
  39. # understanding some of the problems I had converting this headers and pointing me to resources
  40. # that helped translating this headers.
  41. #
  42. # Ido
  43. #
  44. #History:
  45. # 2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and
  46. # chnaged it to "reocrd" only.
  47. # 2004/10/10 - Added to TXkbGetAtomNameFunc and TXkbInternAtomFunc the cdecl call.
  48. # 2004/10/06 - 09 - Convertion `from` the c header of XKBlib.h
  49. #
  50. #
  51. import
  52. X, Xlib, XKB
  53. include "x11pragma.nim"
  54. type
  55. PXkbAnyEvent* = ptr TXkbAnyEvent
  56. TXkbAnyEvent*{.final.} = object
  57. theType*: int16 # XkbAnyEvent
  58. serial*: int32 # # of last req processed by server
  59. send_event*: bool # is this `from` a SendEvent request?
  60. display*: PDisplay # Display the event was read `from`
  61. time*: TTime # milliseconds;
  62. xkb_type*: int16 # XKB event minor code
  63. device*: int16 # device ID
  64. type
  65. PXkbNewKeyboardNotifyEvent* = ptr TXkbNewKeyboardNotifyEvent
  66. TXkbNewKeyboardNotifyEvent*{.final.} = object
  67. theType*: int16 # XkbAnyEvent
  68. serial*: int32 # of last req processed by server
  69. send_event*: bool # is this `from` a SendEvent request?
  70. display*: PDisplay # Display the event was read `from`
  71. time*: TTime # milliseconds
  72. xkb_type*: int16 # XkbNewKeyboardNotify
  73. device*: int16 # device ID
  74. old_device*: int16 # device ID of previous keyboard
  75. min_key_code*: int16 # minimum key code
  76. max_key_code*: int16 # maximum key code
  77. old_min_key_code*: int16 # min key code of previous kbd
  78. old_max_key_code*: int16 # max key code of previous kbd
  79. changed*: int16 # changed aspects of the keyboard
  80. req_major*: int8 # major and minor opcode of req
  81. req_minor*: int8 # that caused change, if applicable
  82. type
  83. PXkbMapNotifyEvent* = ptr TXkbMapNotifyEvent
  84. TXkbMapNotifyEvent*{.final.} = object
  85. theType*: int16 # XkbAnyEvent
  86. serial*: int32 # of last req processed by server
  87. send_event*: bool # is this `from` a SendEvent request
  88. display*: PDisplay # Display the event was read `from`
  89. time*: TTime # milliseconds
  90. xkb_type*: int16 # XkbMapNotify
  91. device*: int16 # device ID
  92. changed*: int16 # fields which have been changed
  93. flags*: int16 # reserved
  94. first_type*: int16 # first changed key type
  95. num_types*: int16 # number of changed key types
  96. min_key_code*: TKeyCode
  97. max_key_code*: TKeyCode
  98. first_key_sym*: TKeyCode
  99. first_key_act*: TKeyCode
  100. first_key_behavior*: TKeyCode
  101. first_key_explicit*: TKeyCode
  102. first_modmap_key*: TKeyCode
  103. first_vmodmap_key*: TKeyCode
  104. num_key_syms*: int16
  105. num_key_acts*: int16
  106. num_key_behaviors*: int16
  107. num_key_explicit*: int16
  108. num_modmap_keys*: int16
  109. num_vmodmap_keys*: int16
  110. vmods*: int16 # mask of changed virtual mods
  111. type
  112. PXkbStateNotifyEvent* = ptr TXkbStateNotifyEvent
  113. TXkbStateNotifyEvent*{.final.} = object
  114. theType*: int16 # XkbAnyEvent
  115. serial*: int32 # # of last req processed by server
  116. send_event*: bool # is this `from` a SendEvent request?
  117. display*: PDisplay # Display the event was read `from`
  118. time*: TTime # milliseconds
  119. xkb_type*: int16 # XkbStateNotify
  120. device*: int16 # device ID
  121. changed*: int16 # mask of changed state components
  122. group*: int16 # keyboard group
  123. base_group*: int16 # base keyboard group
  124. latched_group*: int16 # latched keyboard group
  125. locked_group*: int16 # locked keyboard group
  126. mods*: int16 # modifier state
  127. base_mods*: int16 # base modifier state
  128. latched_mods*: int16 # latched modifiers
  129. locked_mods*: int16 # locked modifiers
  130. compat_state*: int16 # compatibility state
  131. grab_mods*: int8 # mods used for grabs
  132. compat_grab_mods*: int8 # grab mods for non-XKB clients
  133. lookup_mods*: int8 # mods sent to clients
  134. compat_lookup_mods*: int8 # mods sent to non-XKB clients
  135. ptr_buttons*: int16 # pointer button state
  136. keycode*: TKeyCode # keycode that caused the change
  137. event_type*: int8 # KeyPress or KeyRelease
  138. req_major*: int8 # Major opcode of request
  139. req_minor*: int8 # Minor opcode of request
  140. type
  141. PXkbControlsNotifyEvent* = ptr TXkbControlsNotifyEvent
  142. TXkbControlsNotifyEvent*{.final.} = object
  143. theType*: int16 # XkbAnyEvent
  144. serial*: int32 # of last req processed by server
  145. send_event*: bool # is this `from` a SendEvent request?
  146. display*: PDisplay # Display the event was read `from`
  147. time*: TTime # milliseconds
  148. xkb_type*: int16 # XkbControlsNotify
  149. device*: int16 # device ID
  150. changed_ctrls*: int16 # controls with changed sub-values
  151. enabled_ctrls*: int16 # controls currently enabled
  152. enabled_ctrl_changes*: int16 # controls just {en,dis}abled
  153. num_groups*: int16 # total groups on keyboard
  154. keycode*: TKeyCode # key that caused change or 0
  155. event_type*: int8 # type of event that caused change
  156. req_major*: int8 # if keycode==0, major and minor
  157. req_minor*: int8 # opcode of req that caused change
  158. type
  159. PXkbIndicatorNotifyEvent* = ptr TXkbIndicatorNotifyEvent
  160. TXkbIndicatorNotifyEvent*{.final.} = object
  161. theType*: int16 # XkbAnyEvent
  162. serial*: int32 # of last req processed by server
  163. send_event*: bool # is this `from` a SendEvent request?
  164. display*: PDisplay # Display the event was read `from`
  165. time*: TTime # milliseconds
  166. xkb_type*: int16 # XkbIndicatorNotify
  167. device*: int16 # device
  168. changed*: int16 # indicators with new state or map
  169. state*: int16 # current state of all indicators
  170. type
  171. PXkbNamesNotifyEvent* = ptr TXkbNamesNotifyEvent
  172. TXkbNamesNotifyEvent*{.final.} = object
  173. theType*: int16 # XkbAnyEvent
  174. serial*: int32 # of last req processed by server
  175. send_event*: bool # is this `from` a SendEvent request?
  176. display*: PDisplay # Display the event was read `from`
  177. time*: TTime # milliseconds
  178. xkb_type*: int16 # XkbNamesNotify
  179. device*: int16 # device ID
  180. changed*: int32 # names that have changed
  181. first_type*: int16 # first key type with new name
  182. num_types*: int16 # number of key types with new names
  183. first_lvl*: int16 # first key type new new level names
  184. num_lvls*: int16 # # of key types w/new level names
  185. num_aliases*: int16 # total number of key aliases
  186. num_radio_groups*: int16 # total number of radio groups
  187. changed_vmods*: int16 # virtual modifiers with new names
  188. changed_groups*: int16 # groups with new names
  189. changed_indicators*: int16 # indicators with new names
  190. first_key*: int16 # first key with new name
  191. num_keys*: int16 # number of keys with new names
  192. type
  193. PXkbCompatMapNotifyEvent* = ptr TXkbCompatMapNotifyEvent
  194. TXkbCompatMapNotifyEvent*{.final.} = object
  195. theType*: int16 # XkbAnyEvent
  196. serial*: int32 # of last req processed by server
  197. send_event*: bool # is this `from` a SendEvent request?
  198. display*: PDisplay # Display the event was read `from`
  199. time*: TTime # milliseconds
  200. xkb_type*: int16 # XkbCompatMapNotify
  201. device*: int16 # device ID
  202. changed_groups*: int16 # groups with new compat maps
  203. first_si*: int16 # first new symbol interp
  204. num_si*: int16 # number of new symbol interps
  205. num_total_si*: int16 # total # of symbol interps
  206. type
  207. PXkbBellNotifyEvent* = ptr TXkbBellNotifyEvent
  208. TXkbBellNotifyEvent*{.final.} = object
  209. theType*: int16 # XkbAnyEvent
  210. serial*: int32 # of last req processed by server
  211. send_event*: bool # is this `from` a SendEvent request?
  212. display*: PDisplay # Display the event was read `from`
  213. time*: TTime # milliseconds
  214. xkb_type*: int16 # XkbBellNotify
  215. device*: int16 # device ID
  216. percent*: int16 # requested volume as a % of maximum
  217. pitch*: int16 # requested pitch in Hz
  218. duration*: int16 # requested duration in useconds
  219. bell_class*: int16 # (input extension) feedback class
  220. bell_id*: int16 # (input extension) ID of feedback
  221. name*: TAtom # "name" of requested bell
  222. window*: TWindow # window associated with event
  223. event_only*: bool # "event only" requested
  224. type
  225. PXkbActionMessageEvent* = ptr TXkbActionMessageEvent
  226. TXkbActionMessageEvent*{.final.} = object
  227. theType*: int16 # XkbAnyEvent
  228. serial*: int32 # of last req processed by server
  229. send_event*: bool # is this `from` a SendEvent request?
  230. display*: PDisplay # Display the event was read `from`
  231. time*: TTime # milliseconds
  232. xkb_type*: int16 # XkbActionMessage
  233. device*: int16 # device ID
  234. keycode*: TKeyCode # key that generated the event
  235. press*: bool # true if act caused by key press
  236. key_event_follows*: bool # true if key event also generated
  237. group*: int16 # effective group
  238. mods*: int16 # effective mods
  239. message*: array[0..XkbActionMessageLength, char] # message -- leave space for NUL
  240. type
  241. PXkbAccessXNotifyEvent* = ptr TXkbAccessXNotifyEvent
  242. TXkbAccessXNotifyEvent*{.final.} = object
  243. theType*: int16 # XkbAnyEvent
  244. serial*: int32 # of last req processed by server
  245. send_event*: bool # is this `from` a SendEvent request?
  246. display*: PDisplay # Display the event was read `from`
  247. time*: TTime # milliseconds
  248. xkb_type*: int16 # XkbAccessXNotify
  249. device*: int16 # device ID
  250. detail*: int16 # XkbAXN_*
  251. keycode*: int16 # key of event
  252. sk_delay*: int16 # current slow keys delay
  253. debounce_delay*: int16 # current debounce delay
  254. type
  255. PXkbExtensionDeviceNotifyEvent* = ptr TXkbExtensionDeviceNotifyEvent
  256. TXkbExtensionDeviceNotifyEvent*{.final.} = object
  257. theType*: int16 # XkbAnyEvent
  258. serial*: int32 # of last req processed by server
  259. send_event*: bool # is this `from` a SendEvent request?
  260. display*: PDisplay # Display the event was read `from`
  261. time*: TTime # milliseconds
  262. xkb_type*: int16 # XkbExtensionDeviceNotify
  263. device*: int16 # device ID
  264. reason*: int16 # reason for the event
  265. supported*: int16 # mask of supported features
  266. unsupported*: int16 # mask of unsupported features
  267. # that some app tried to use
  268. first_btn*: int16 # first button that changed
  269. num_btns*: int16 # range of buttons changed
  270. leds_defined*: int16 # indicators with names or maps
  271. led_state*: int16 # current state of the indicators
  272. led_class*: int16 # feedback class for led changes
  273. led_id*: int16 # feedback id for led changes
  274. type
  275. PXkbEvent* = ptr TXkbEvent
  276. TXkbEvent*{.final.} = object
  277. theType*: int16
  278. any*: TXkbAnyEvent
  279. new_kbd*: TXkbNewKeyboardNotifyEvent
  280. map*: TXkbMapNotifyEvent
  281. state*: TXkbStateNotifyEvent
  282. ctrls*: TXkbControlsNotifyEvent
  283. indicators*: TXkbIndicatorNotifyEvent
  284. names*: TXkbNamesNotifyEvent
  285. compat*: TXkbCompatMapNotifyEvent
  286. bell*: TXkbBellNotifyEvent
  287. message*: TXkbActionMessageEvent
  288. accessx*: TXkbAccessXNotifyEvent
  289. device*: TXkbExtensionDeviceNotifyEvent
  290. core*: TXEvent
  291. type
  292. PXkbKbdDpyStatePtr* = ptr TXkbKbdDpyStateRec
  293. TXkbKbdDpyStateRec*{.final.} = object # XkbOpenDisplay error codes
  294. const
  295. XkbOD_Success* = 0
  296. XkbOD_BadLibraryVersion* = 1
  297. XkbOD_ConnectionRefused* = 2
  298. XkbOD_NonXkbServer* = 3
  299. XkbOD_BadServerVersion* = 4 # Values for XlibFlags
  300. const
  301. XkbLC_ForceLatin1Lookup* = 1 shl 0
  302. XkbLC_ConsumeLookupMods* = 1 shl 1
  303. XkbLC_AlwaysConsumeShiftAndLock* = 1 shl 2
  304. XkbLC_IgnoreNewKeyboards* = 1 shl 3
  305. XkbLC_ControlFallback* = 1 shl 4
  306. XkbLC_ConsumeKeysOnComposeFail* = 1 shl 29
  307. XkbLC_ComposeLED* = 1 shl 30
  308. XkbLC_BeepOnComposeFail* = 1 shl 31
  309. XkbLC_AllComposeControls* = 0xC0000000
  310. XkbLC_AllControls* = 0xC000001F
  311. proc XkbIgnoreExtension*(ignore: bool): bool{.libx11c,
  312. importc: "XkbIgnoreExtension".}
  313. proc XkbOpenDisplay*(name: cstring, ev_rtrn, err_rtrn, major_rtrn, minor_rtrn,
  314. reason: ptr int16): PDisplay{.libx11c, importc: "XkbOpenDisplay".}
  315. proc XkbQueryExtension*(dpy: PDisplay, opcodeReturn, eventBaseReturn,
  316. errorBaseReturn, majorRtrn, minorRtrn: ptr int16): bool{.
  317. libx11c, importc: "XkbQueryExtension".}
  318. proc XkbUseExtension*(dpy: PDisplay, major_rtrn, minor_rtrn: ptr int16): bool{.
  319. libx11c, importc: "XkbUseExtension".}
  320. proc XkbLibraryVersion*(libMajorRtrn, libMinorRtrn: ptr int16): bool{.libx11c, importc: "XkbLibraryVersion".}
  321. proc XkbSetXlibControls*(dpy: PDisplay, affect, values: int16): int16{.libx11c, importc: "XkbSetXlibControls".}
  322. proc XkbGetXlibControls*(dpy: PDisplay): int16{.libx11c,
  323. importc: "XkbGetXlibControls".}
  324. type
  325. TXkbInternAtomFunc* = proc (dpy: PDisplay, name: cstring, only_if_exists: bool): TAtom{.
  326. cdecl.}
  327. type
  328. TXkbGetAtomNameFunc* = proc (dpy: PDisplay, atom: TAtom): cstring{.cdecl.}
  329. proc XkbSetAtomFuncs*(getAtom: TXkbInternAtomFunc, getName: TXkbGetAtomNameFunc){.
  330. libx11c, importc: "XkbSetAtomFuncs".}
  331. proc XkbKeycodeToKeysym*(dpy: PDisplay, kc: TKeyCode, group, level: int16): TKeySym{.
  332. libx11c, importc: "XkbKeycodeToKeysym".}
  333. proc XkbKeysymToModifiers*(dpy: PDisplay, ks: TKeySym): int16{.libx11c, importc: "XkbKeysymToModifiers".}
  334. proc XkbLookupKeySym*(dpy: PDisplay, keycode: TKeyCode,
  335. modifiers, modifiers_return: int16, keysym_return: PKeySym): bool{.
  336. libx11c, importc: "XkbLookupKeySym".}
  337. proc XkbLookupKeyBinding*(dpy: PDisplay, sym_rtrn: TKeySym, mods: int16,
  338. buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
  339. libx11c, importc: "XkbLookupKeyBinding".}
  340. proc XkbTranslateKeyCode*(xkb: PXkbDescPtr, keycode: TKeyCode,
  341. modifiers, modifiers_return: int16,
  342. keysym_return: PKeySym): bool{.libx11c,
  343. importc: "XkbTranslateKeyCode".}
  344. proc XkbTranslateKeySym*(dpy: PDisplay, sym_return: TKeySym, modifiers: int16,
  345. buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
  346. libx11c, importc: "XkbTranslateKeySym".}
  347. proc XkbSetAutoRepeatRate*(dpy: PDisplay, deviceSpec, delay, interval: int16): bool{.
  348. libx11c, importc: "XkbSetAutoRepeatRate".}
  349. proc XkbGetAutoRepeatRate*(dpy: PDisplay, deviceSpec: int16,
  350. delayRtrn, intervalRtrn: PWord): bool{.libx11c, importc: "XkbGetAutoRepeatRate".}
  351. proc XkbChangeEnabledControls*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
  352. libx11c, importc: "XkbChangeEnabledControls".}
  353. proc XkbDeviceBell*(dpy: PDisplay, win: TWindow,
  354. deviceSpec, bellClass, bellID, percent: int16, name: TAtom): bool{.
  355. libx11c, importc: "XkbDeviceBell".}
  356. proc XkbForceDeviceBell*(dpy: PDisplay,
  357. deviceSpec, bellClass, bellID, percent: int16): bool{.
  358. libx11c, importc: "XkbForceDeviceBell".}
  359. proc XkbDeviceBellEvent*(dpy: PDisplay, win: TWindow,
  360. deviceSpec, bellClass, bellID, percent: int16,
  361. name: TAtom): bool{.libx11c,
  362. importc: "XkbDeviceBellEvent".}
  363. proc XkbBell*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
  364. libx11c, importc: "XkbBell".}
  365. proc XkbForceBell*(dpy: PDisplay, percent: int16): bool{.libx11c,
  366. importc: "XkbForceBell".}
  367. proc XkbBellEvent*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
  368. libx11c, importc: "XkbBellEvent".}
  369. proc XkbSelectEvents*(dpy: PDisplay, deviceID, affect, values: int16): bool{.
  370. libx11c, importc: "XkbSelectEvents".}
  371. proc XkbSelectEventDetails*(dpy: PDisplay, deviceID, eventType: int16,
  372. affect, details: int32): bool{.libx11c, importc: "XkbSelectEventDetails".}
  373. proc XkbNoteMapChanges*(old: PXkbMapChangesPtr, new: PXkbMapNotifyEvent,
  374. wanted: int16){.libx11c,
  375. importc: "XkbNoteMapChanges".}
  376. proc XkbNoteNameChanges*(old: PXkbNameChangesPtr, new: PXkbNamesNotifyEvent,
  377. wanted: int16){.libx11c,
  378. importc: "XkbNoteNameChanges".}
  379. proc XkbGetIndicatorState*(dpy: PDisplay, deviceSpec: int16, pStateRtrn: PWord): TStatus{.
  380. libx11c, importc: "XkbGetIndicatorState".}
  381. proc XkbGetDeviceIndicatorState*(dpy: PDisplay,
  382. deviceSpec, ledClass, ledID: int16,
  383. pStateRtrn: PWord): TStatus{.libx11c, importc: "XkbGetDeviceIndicatorState".}
  384. proc XkbGetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
  385. libx11c, importc: "XkbGetIndicatorMap".}
  386. proc XkbSetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
  387. libx11c, importc: "XkbSetIndicatorMap".}
  388. proc XkbNoteIndicatorMapChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
  389. proc XkbNoteIndicatorStateChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
  390. proc XkbGetIndicatorMapChanges*(d: PDisplay, x: PXkbDescPtr,
  391. c: PXkbIndicatorChangesPtr): TStatus
  392. proc XkbChangeIndicatorMaps*(d: PDisplay, x: PXkbDescPtr,
  393. c: PXkbIndicatorChangesPtr): bool
  394. proc XkbGetNamedIndicator*(dpy: PDisplay, name: TAtom, pNdxRtrn: ptr int16,
  395. pStateRtrn: ptr bool, pMapRtrn: PXkbIndicatorMapPtr,
  396. pRealRtrn: ptr bool): bool{.libx11c,
  397. importc: "XkbGetNamedIndicator".}
  398. proc XkbGetNamedDeviceIndicator*(dpy: PDisplay,
  399. deviceSpec, ledClass, ledID: int16,
  400. name: TAtom, pNdxRtrn: ptr int16,
  401. pStateRtrn: ptr bool,
  402. pMapRtrn: PXkbIndicatorMapPtr,
  403. pRealRtrn: ptr bool): bool{.libx11c, importc: "XkbGetNamedDeviceIndicator".}
  404. proc XkbSetNamedIndicator*(dpy: PDisplay, name: TAtom,
  405. changeState, state, createNewMap: bool,
  406. pMap: PXkbIndicatorMapPtr): bool{.libx11c, importc: "XkbSetNamedIndicator".}
  407. proc XkbSetNamedDeviceIndicator*(dpy: PDisplay,
  408. deviceSpec, ledClass, ledID: int16,
  409. name: TAtom,
  410. changeState, state, createNewMap: bool,
  411. pMap: PXkbIndicatorMapPtr): bool{.libx11c, importc: "XkbSetNamedDeviceIndicator".}
  412. proc XkbLockModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
  413. libx11c, importc: "XkbLockModifiers".}
  414. proc XkbLatchModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
  415. libx11c, importc: "XkbLatchModifiers".}
  416. proc XkbLockGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.libx11c, importc: "XkbLockGroup".}
  417. proc XkbLatchGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.libx11c, importc: "XkbLatchGroup".}
  418. proc XkbSetServerInternalMods*(dpy: PDisplay, deviceSpec, affectReal,
  419. realValues, affectVirtual, virtualValues: int16): bool{.libx11c, importc: "XkbSetServerInternalMods".}
  420. proc XkbSetIgnoreLockMods*(dpy: PDisplay, deviceSpec, affectReal, realValues,
  421. affectVirtual, virtualValues: int16): bool{.libx11c,
  422. importc: "XkbSetIgnoreLockMods".}
  423. proc XkbVirtualModsToReal*(dpy: PDisplay, virtual_mask: int16, mask_rtrn: PWord): bool{.
  424. libx11c, importc: "XkbVirtualModsToReal".}
  425. proc XkbComputeEffectiveMap*(xkb: PXkbDescPtr, theType: PXkbKeyTypePtr,
  426. map_rtrn: PByte): bool{.libx11c,
  427. importc: "XkbComputeEffectiveMap".}
  428. proc XkbInitCanonicalKeyTypes*(xkb: PXkbDescPtr, which: int16, keypadVMod: int16): TStatus{.
  429. libx11c, importc: "XkbInitCanonicalKeyTypes".}
  430. proc XkbAllocKeyboard*(): PXkbDescPtr{.libx11c,
  431. importc: "XkbAllocKeyboard".}
  432. proc XkbFreeKeyboard*(xkb: PXkbDescPtr, which: int16, freeDesc: bool){.libx11c, importc: "XkbFreeKeyboard".}
  433. proc XkbAllocClientMap*(xkb: PXkbDescPtr, which, nTypes: int16): TStatus{.libx11c, importc: "XkbAllocClientMap".}
  434. proc XkbAllocServerMap*(xkb: PXkbDescPtr, which, nActions: int16): TStatus{.
  435. libx11c, importc: "XkbAllocServerMap".}
  436. proc XkbFreeClientMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.libx11c, importc: "XkbFreeClientMap".}
  437. proc XkbFreeServerMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.libx11c, importc: "XkbFreeServerMap".}
  438. proc XkbAddKeyType*(xkb: PXkbDescPtr, name: TAtom, map_count: int16,
  439. want_preserve: bool, num_lvls: int16): PXkbKeyTypePtr{.
  440. libx11c, importc: "XkbAddKeyType".}
  441. proc XkbAllocIndicatorMaps*(xkb: PXkbDescPtr): TStatus{.libx11c,
  442. importc: "XkbAllocIndicatorMaps".}
  443. proc XkbFreeIndicatorMaps*(xkb: PXkbDescPtr){.libx11c,
  444. importc: "XkbFreeIndicatorMaps".}
  445. proc XkbGetMap*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.libx11c, importc: "XkbGetMap".}
  446. proc XkbGetUpdatedMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
  447. libx11c, importc: "XkbGetUpdatedMap".}
  448. proc XkbGetMapChanges*(dpy: PDisplay, xkb: PXkbDescPtr,
  449. changes: PXkbMapChangesPtr): TStatus{.libx11c, importc: "XkbGetMapChanges".}
  450. proc XkbRefreshKeyboardMapping*(event: PXkbMapNotifyEvent): TStatus{.libx11c, importc: "XkbRefreshKeyboardMapping".}
  451. proc XkbGetKeyTypes*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
  452. libx11c, importc: "XkbGetKeyTypes".}
  453. proc XkbGetKeySyms*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
  454. libx11c, importc: "XkbGetKeySyms".}
  455. proc XkbGetKeyActions*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
  456. libx11c, importc: "XkbGetKeyActions".}
  457. proc XkbGetKeyBehaviors*(dpy: PDisplay, firstKey, nKeys: int16,
  458. desc: PXkbDescPtr): TStatus{.libx11c,
  459. importc: "XkbGetKeyBehaviors".}
  460. proc XkbGetVirtualMods*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
  461. libx11c, importc: "XkbGetVirtualMods".}
  462. proc XkbGetKeyExplicitComponents*(dpy: PDisplay, firstKey, nKeys: int16,
  463. desc: PXkbDescPtr): TStatus{.libx11c, importc: "XkbGetKeyExplicitComponents".}
  464. proc XkbGetKeyModifierMap*(dpy: PDisplay, firstKey, nKeys: int16,
  465. desc: PXkbDescPtr): TStatus{.libx11c,
  466. importc: "XkbGetKeyModifierMap".}
  467. proc XkbAllocControls*(xkb: PXkbDescPtr, which: int16): TStatus{.libx11c, importc: "XkbAllocControls".}
  468. proc XkbFreeControls*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.libx11c, importc: "XkbFreeControls".}
  469. proc XkbGetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
  470. libx11c, importc: "XkbGetControls".}
  471. proc XkbSetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
  472. libx11c, importc: "XkbSetControls".}
  473. proc XkbNoteControlsChanges*(old: PXkbControlsChangesPtr,
  474. new: PXkbControlsNotifyEvent, wanted: int16){.
  475. libx11c, importc: "XkbNoteControlsChanges".}
  476. proc XkbGetControlsChanges*(d: PDisplay, x: PXkbDescPtr,
  477. c: PXkbControlsChangesPtr): TStatus
  478. proc XkbChangeControls*(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool
  479. proc XkbAllocCompatMap*(xkb: PXkbDescPtr, which, nInterpret: int16): TStatus{.
  480. libx11c, importc: "XkbAllocCompatMap".}
  481. proc XkbFreeCompatMap*(xkib: PXkbDescPtr, which: int16, freeMap: bool){.libx11c, importc: "XkbFreeCompatMap".}
  482. proc XkbGetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr): TStatus{.
  483. libx11c, importc: "XkbGetCompatMap".}
  484. proc XkbSetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr,
  485. updateActions: bool): bool{.libx11c,
  486. importc: "XkbSetCompatMap".}
  487. proc XkbAddSymInterpret*(xkb: PXkbDescPtr, si: PXkbSymInterpretPtr,
  488. updateMap: bool, changes: PXkbChangesPtr): PXkbSymInterpretPtr{.
  489. libx11c, importc: "XkbAddSymInterpret".}
  490. proc XkbAllocNames*(xkb: PXkbDescPtr, which: int16,
  491. nTotalRG, nTotalAliases: int16): TStatus{.libx11c, importc: "XkbAllocNames".}
  492. proc XkbGetNames*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
  493. libx11c, importc: "XkbGetNames".}
  494. proc XkbSetNames*(dpy: PDisplay, which, firstType, nTypes: int16,
  495. desc: PXkbDescPtr): bool{.libx11c,
  496. importc: "XkbSetNames".}
  497. proc XkbChangeNames*(dpy: PDisplay, xkb: PXkbDescPtr,
  498. changes: PXkbNameChangesPtr): bool{.libx11c,
  499. importc: "XkbChangeNames".}
  500. proc XkbFreeNames*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.libx11c, importc: "XkbFreeNames".}
  501. proc XkbGetState*(dpy: PDisplay, deviceSpec: int16, rtrnState: PXkbStatePtr): TStatus{.
  502. libx11c, importc: "XkbGetState".}
  503. proc XkbSetMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): bool{.libx11c, importc: "XkbSetMap".}
  504. proc XkbChangeMap*(dpy: PDisplay, desc: PXkbDescPtr, changes: PXkbMapChangesPtr): bool{.
  505. libx11c, importc: "XkbChangeMap".}
  506. proc XkbSetDetectableAutoRepeat*(dpy: PDisplay, detectable: bool,
  507. supported: ptr bool): bool{.libx11c, importc: "XkbSetDetectableAutoRepeat".}
  508. proc XkbGetDetectableAutoRepeat*(dpy: PDisplay, supported: ptr bool): bool{.
  509. libx11c, importc: "XkbGetDetectableAutoRepeat".}
  510. proc XkbSetAutoResetControls*(dpy: PDisplay, changes: int16,
  511. auto_ctrls, auto_values: PWord): bool{.libx11c, importc: "XkbSetAutoResetControls".}
  512. proc XkbGetAutoResetControls*(dpy: PDisplay, auto_ctrls, auto_ctrl_values: PWord): bool{.
  513. libx11c, importc: "XkbGetAutoResetControls".}
  514. proc XkbSetPerClientControls*(dpy: PDisplay, change: int16, values: PWord): bool{.
  515. libx11c, importc: "XkbSetPerClientControls".}
  516. proc XkbGetPerClientControls*(dpy: PDisplay, ctrls: PWord): bool{.libx11c, importc: "XkbGetPerClientControls".}
  517. proc XkbCopyKeyType*(`from`, into: PXkbKeyTypePtr): TStatus{.libx11c, importc: "XkbCopyKeyType".}
  518. proc XkbCopyKeyTypes*(`from`, into: PXkbKeyTypePtr, num_types: int16): TStatus{.
  519. libx11c, importc: "XkbCopyKeyTypes".}
  520. proc XkbResizeKeyType*(xkb: PXkbDescPtr, type_ndx, map_count: int16,
  521. want_preserve: bool, new_num_lvls: int16): TStatus{.
  522. libx11c, importc: "XkbResizeKeyType".}
  523. proc XkbResizeKeySyms*(desc: PXkbDescPtr, forKey, symsNeeded: int16): PKeySym{.
  524. libx11c, importc: "XkbResizeKeySyms".}
  525. proc XkbResizeKeyActions*(desc: PXkbDescPtr, forKey, actsNeeded: int16): PXkbAction{.
  526. libx11c, importc: "XkbResizeKeyActions".}
  527. proc XkbChangeTypesOfKey*(xkb: PXkbDescPtr, key, num_groups: int16,
  528. groups: int16, newTypes: ptr int16,
  529. pChanges: PXkbMapChangesPtr): TStatus{.libx11c, importc: "XkbChangeTypesOfKey".}
  530. proc XkbListComponents*(dpy: PDisplay, deviceSpec: int16,
  531. ptrns: PXkbComponentNamesPtr, max_inout: ptr int16): PXkbComponentListPtr{.
  532. libx11c, importc: "XkbListComponents".}
  533. proc XkbFreeComponentList*(list: PXkbComponentListPtr){.libx11c,
  534. importc: "XkbFreeComponentList".}
  535. proc XkbGetKeyboard*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.
  536. libx11c, importc: "XkbGetKeyboard".}
  537. proc XkbGetKeyboardByName*(dpy: PDisplay, deviceSpec: int16,
  538. names: PXkbComponentNamesPtr, want, need: int16,
  539. load: bool): PXkbDescPtr{.libx11c,
  540. importc: "XkbGetKeyboardByName".}
  541. proc XkbKeyTypesForCoreSymbols*(xkb: PXkbDescPtr,
  542. map_width: int16, # keyboard device
  543. core_syms: PKeySym, # always mapWidth symbols
  544. protected: int16, # explicit key types
  545. types_inout: ptr int16, # always four type indices
  546. xkb_syms_rtrn: PKeySym): int16{.libx11c, importc: "XkbKeyTypesForCoreSymbols".}
  547. # must have enough space
  548. proc XkbApplyCompatMapToKey*(xkb: PXkbDescPtr,
  549. key: TKeyCode, # key to be updated
  550. changes: PXkbChangesPtr): bool{.libx11c, importc: "XkbApplyCompatMapToKey".}
  551. # resulting changes to map
  552. proc XkbUpdateMapFromCore*(xkb: PXkbDescPtr,
  553. first_key: TKeyCode, # first changed key
  554. num_keys,
  555. map_width: int16,
  556. core_keysyms: PKeySym, # symbols `from` core keymap
  557. changes: PXkbChangesPtr): bool{.libx11c, importc: "XkbUpdateMapFromCore".}
  558. proc XkbAddDeviceLedInfo*(devi: PXkbDeviceInfoPtr, ledClass, ledId: int16): PXkbDeviceLedInfoPtr{.
  559. libx11c, importc: "XkbAddDeviceLedInfo".}
  560. proc XkbResizeDeviceButtonActions*(devi: PXkbDeviceInfoPtr, newTotal: int16): TStatus{.
  561. libx11c, importc: "XkbResizeDeviceButtonActions".}
  562. proc XkbAllocDeviceInfo*(deviceSpec, nButtons, szLeds: int16): PXkbDeviceInfoPtr{.
  563. libx11c, importc: "XkbAllocDeviceInfo".}
  564. proc XkbFreeDeviceInfo*(devi: PXkbDeviceInfoPtr, which: int16, freeDevI: bool){.
  565. libx11c, importc: "XkbFreeDeviceInfo".}
  566. proc XkbNoteDeviceChanges*(old: PXkbDeviceChangesPtr,
  567. new: PXkbExtensionDeviceNotifyEvent, wanted: int16){.
  568. libx11c, importc: "XkbNoteDeviceChanges".}
  569. proc XkbGetDeviceInfo*(dpy: PDisplay, which, deviceSpec, ledClass, ledID: int16): PXkbDeviceInfoPtr{.
  570. libx11c, importc: "XkbGetDeviceInfo".}
  571. proc XkbGetDeviceInfoChanges*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
  572. changes: PXkbDeviceChangesPtr): TStatus{.libx11c, importc: "XkbGetDeviceInfoChanges".}
  573. proc XkbGetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
  574. all: bool, first, nBtns: int16): TStatus{.libx11c, importc: "XkbGetDeviceButtonActions".}
  575. proc XkbGetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
  576. ledClass, ledId, which: int16): TStatus{.libx11c, importc: "XkbGetDeviceLedInfo".}
  577. proc XkbSetDeviceInfo*(dpy: PDisplay, which: int16, devi: PXkbDeviceInfoPtr): bool{.
  578. libx11c, importc: "XkbSetDeviceInfo".}
  579. proc XkbChangeDeviceInfo*(dpy: PDisplay, desc: PXkbDeviceInfoPtr,
  580. changes: PXkbDeviceChangesPtr): bool{.libx11c, importc: "XkbChangeDeviceInfo".}
  581. proc XkbSetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
  582. ledClass, ledID, which: int16): bool{.libx11c, importc: "XkbSetDeviceLedInfo".}
  583. proc XkbSetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
  584. first, nBtns: int16): bool{.libx11c, importc: "XkbSetDeviceButtonActions".}
  585. proc XkbToControl*(c: int8): int8{.libx11c,
  586. importc: "XkbToControl".}
  587. proc XkbSetDebuggingFlags*(dpy: PDisplay, mask, flags: int16, msg: cstring,
  588. ctrls_mask, ctrls, rtrn_flags, rtrn_ctrls: int16): bool{.
  589. libx11c, importc: "XkbSetDebuggingFlags".}
  590. proc XkbApplyVirtualModChanges*(xkb: PXkbDescPtr, changed: int16,
  591. changes: PXkbChangesPtr): bool{.libx11c, importc: "XkbApplyVirtualModChanges".}
  592. # implementation
  593. proc XkbNoteIndicatorMapChanges(o, n: PXkbIndicatorChangesPtr, w: int16) =
  594. ##define XkbNoteIndicatorMapChanges(o,n,w) ((o)->map_changes|=((n)->map_changes&(w)))
  595. o.map_changes = o.map_changes or (n.map_changes and w)
  596. proc XkbNoteIndicatorStateChanges(o, n: PXkbIndicatorChangesPtr, w: int16) =
  597. ##define XkbNoteIndicatorStateChanges(o,n,w) ((o)->state_changes|=((n)->state_changes&(w)))
  598. o.state_changes = o.state_changes or (n.state_changes and (w))
  599. proc XkbGetIndicatorMapChanges(d: PDisplay, x: PXkbDescPtr,
  600. c: PXkbIndicatorChangesPtr): TStatus =
  601. ##define XkbGetIndicatorMapChanges(d,x,c) (XkbGetIndicatorMap((d),(c)->map_changes,x)
  602. result = XkbGetIndicatorMap(d, c.map_changes, x)
  603. proc XkbChangeIndicatorMaps(d: PDisplay, x: PXkbDescPtr,
  604. c: PXkbIndicatorChangesPtr): bool =
  605. ##define XkbChangeIndicatorMaps(d,x,c) (XkbSetIndicatorMap((d),(c)->map_changes,x))
  606. result = XkbSetIndicatorMap(d, c.map_changes, x)
  607. proc XkbGetControlsChanges(d: PDisplay, x: PXkbDescPtr,
  608. c: PXkbControlsChangesPtr): TStatus =
  609. ##define XkbGetControlsChanges(d,x,c) XkbGetControls(d,(c)->changed_ctrls,x)
  610. result = XkbGetControls(d, c.changed_ctrls, x)
  611. proc XkbChangeControls(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool =
  612. ##define XkbChangeControls(d,x,c) XkbSetControls(d,(c)->changed_ctrls,x)
  613. result = XkbSetControls(d, c.changed_ctrls, x)