xkb.nim 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388
  1. #
  2. # $Xorg: XKB.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
  3. #************************************************************
  4. # $Xorg: XKBstr.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
  5. #************************************************************
  6. # $Xorg: XKBgeom.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
  7. #************************************************************
  8. #
  9. #Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
  10. #
  11. #Permission to use, copy, modify, and distribute this
  12. #software and its documentation for any purpose and without
  13. #fee is hereby granted, provided that the above copyright
  14. #notice appear in all copies and that both that copyright
  15. #notice and this permission notice appear in supporting
  16. #documentation, and that the name of Silicon Graphics not be
  17. #used in advertising or publicity pertaining to distribution
  18. #of the software without specific prior written permission.
  19. #Silicon Graphics makes no representation about the suitability
  20. #of this software for any purpose. It is provided "as is"
  21. #without any express or implied warranty.
  22. #
  23. #SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  24. #SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  25. #AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
  26. #GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  27. #DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  28. #DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  29. #OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
  30. #THE USE OR PERFORMANCE OF THIS SOFTWARE.
  31. #
  32. #********************************************************
  33. # $XFree86: xc/include/extensions/XKB.h,v 1.5 2002/11/20 04:49:01 dawes Exp $
  34. # $XFree86: xc/include/extensions/XKBgeom.h,v 3.9 2002/09/18 17:11:40 tsi Exp $
  35. #
  36. # Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
  37. #
  38. #Thanks:
  39. # I want to thanks to oliebol for putting up with all of the problems that was found
  40. # while translating this code. ;)
  41. #
  42. # I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my
  43. # weird questions ;)
  44. #
  45. # Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to
  46. # understanding some of the problems I had converting this headers and pointing me to resources
  47. # that helped translating this headers.
  48. #
  49. # Ido
  50. #
  51. #History:
  52. # 2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and
  53. # chnaged it to "reocrd" only.
  54. # 2004/10/04 - 06 - Convertion from the c header of XKBgeom.h.
  55. # 2004/10/03 - Removed the XKBstr_UNIT compiler decleration. Afther the joined files,
  56. # There is no need for it anymore.
  57. # - There is a need to define (for now) XKBgeom (compiler define) in order
  58. # to use the code of it. At this moment, I did not yet converted it to Pascal.
  59. #
  60. # 2004/09/17 - 10/04 - Convertion from the c header of XKBstr.
  61. #
  62. # 2004/10/03 - Joined xkbstr.pas into xkb.pas because of the circular calls problems.
  63. # - Added the history of xkbstr.pas above this addition.
  64. #
  65. # 2004/09/17 - Fixed a wrong convertion number of XkbPerKeyBitArraySize, instead
  66. # of float, it's now converted into integer (as it should have been).
  67. #
  68. # 2004/09/15 - 16 - Convertion from the c header of XKB.h.
  69. #
  70. import
  71. X, Xlib
  72. include "x11pragma.nim"
  73. proc XkbcharToInt*(v: int8): int16
  74. proc XkbIntTo2chars*(i: int16, h, L: var int8)
  75. proc Xkb2charsToInt*(h, L: int8): int16
  76. #
  77. # Common data structures and access macros
  78. #
  79. type
  80. PWord* = ptr array[0..64_000, int16]
  81. PByte* = ptr byte
  82. PXkbStatePtr* = ptr TXkbStateRec
  83. TXkbStateRec*{.final.} = object
  84. group*: int8
  85. locked_group*: int8
  86. base_group*: int16
  87. latched_group*: int16
  88. mods*: int8
  89. base_mods*: int8
  90. latched_mods*: int8
  91. locked_mods*: int8
  92. compat_state*: int8
  93. grab_mods*: int8
  94. compat_grab_mods*: int8
  95. lookup_mods*: int8
  96. compat_lookup_mods*: int8
  97. ptr_buttons*: int16
  98. proc XkbModLocks*(s: PXkbStatePtr): int8
  99. proc XkbStateMods*(s: PXkbStatePtr): int16
  100. proc XkbGroupLock*(s: PXkbStatePtr): int8
  101. proc XkbStateGroup*(s: PXkbStatePtr): int16
  102. proc XkbStateFieldFromRec*(s: PXkbStatePtr): int
  103. proc XkbGrabStateFromRec*(s: PXkbStatePtr): int
  104. type
  105. PXkbModsPtr* = ptr TXkbModsRec
  106. TXkbModsRec*{.final.} = object
  107. mask*: int8 # effective mods
  108. real_mods*: int8
  109. vmods*: int16
  110. type
  111. PXkbKTMapEntryPtr* = ptr TXkbKTMapEntryRec
  112. TXkbKTMapEntryRec*{.final.} = object
  113. active*: bool
  114. level*: int8
  115. mods*: TXkbModsRec
  116. type
  117. PXkbKeyTypePtr* = ptr TXkbKeyTypeRec
  118. TXkbKeyTypeRec*{.final.} = object
  119. mods*: TXkbModsRec
  120. num_levels*: int8
  121. map_count*: int8
  122. map*: PXkbKTMapEntryPtr
  123. preserve*: PXkbModsPtr
  124. name*: TAtom
  125. level_names*: TAtom
  126. proc XkbNumGroups*(g: int16): int16
  127. proc XkbOutOfRangeGroupInfo*(g: int16): int16
  128. proc XkbOutOfRangeGroupAction*(g: int16): int16
  129. proc XkbOutOfRangeGroupNumber*(g: int16): int16
  130. proc XkbSetGroupInfo*(g, w, n: int16): int16
  131. proc XkbSetNumGroups*(g, n: int16): int16
  132. #
  133. # Structures and access macros used primarily by the server
  134. #
  135. type
  136. PXkbBehavior* = ptr TXkbBehavior
  137. TXkbBehavior*{.final.} = object
  138. theType*: int8
  139. data*: int8
  140. type
  141. PXkbModAction* = ptr TXkbModAction
  142. TXkbModAction*{.final.} = object
  143. theType*: int8
  144. flags*: int8
  145. mask*: int8
  146. real_mods*: int8
  147. vmods1*: int8
  148. vmods2*: int8
  149. proc XkbModActionVMods*(a: PXkbModAction): int16
  150. proc XkbSetModActionVMods*(a: PXkbModAction, v: int8)
  151. type
  152. PXkbGroupAction* = ptr TXkbGroupAction
  153. TXkbGroupAction*{.final.} = object
  154. theType*: int8
  155. flags*: int8
  156. group_XXX*: int8
  157. proc XkbSAGroup*(a: PXkbGroupAction): int8
  158. proc XkbSASetGroupProc*(a: PXkbGroupAction, g: int8)
  159. type
  160. PXkbISOAction* = ptr TXkbISOAction
  161. TXkbISOAction*{.final.} = object
  162. theType*: int8
  163. flags*: int8
  164. mask*: int8
  165. real_mods*: int8
  166. group_XXX*: int8
  167. affect*: int8
  168. vmods1*: int8
  169. vmods2*: int8
  170. type
  171. PXkbPtrAction* = ptr TXkbPtrAction
  172. TXkbPtrAction*{.final.} = object
  173. theType*: int8
  174. flags*: int8
  175. high_XXX*: int8
  176. low_XXX*: int8
  177. high_YYY*: int8
  178. low_YYY*: int8
  179. proc XkbPtrActionX*(a: PXkbPtrAction): int16
  180. proc XkbPtrActionY*(a: PXkbPtrAction): int16
  181. proc XkbSetPtrActionX*(a: PXkbPtrAction, x: int8)
  182. proc XkbSetPtrActionY*(a: PXkbPtrAction, y: int8)
  183. type
  184. PXkbPtrBtnAction* = ptr TXkbPtrBtnAction
  185. TXkbPtrBtnAction*{.final.} = object
  186. theType*: int8
  187. flags*: int8
  188. count*: int8
  189. button*: int8
  190. type
  191. PXkbPtrDfltAction* = ptr TXkbPtrDfltAction
  192. TXkbPtrDfltAction*{.final.} = object
  193. theType*: int8
  194. flags*: int8
  195. affect*: int8
  196. valueXXX*: int8
  197. proc XkbSAPtrDfltValue*(a: PXkbPtrDfltAction): int8
  198. proc XkbSASetPtrDfltValue*(a: PXkbPtrDfltAction, c: pointer)
  199. type
  200. PXkbSwitchScreenAction* = ptr TXkbSwitchScreenAction
  201. TXkbSwitchScreenAction*{.final.} = object
  202. theType*: int8
  203. flags*: int8
  204. screenXXX*: int8
  205. proc XkbSAScreen*(a: PXkbSwitchScreenAction): int8
  206. proc XkbSASetScreen*(a: PXkbSwitchScreenAction, s: pointer)
  207. type
  208. PXkbCtrlsAction* = ptr TXkbCtrlsAction
  209. TXkbCtrlsAction*{.final.} = object
  210. theType*: int8
  211. flags*: int8
  212. ctrls3*: int8
  213. ctrls2*: int8
  214. ctrls1*: int8
  215. ctrls0*: int8
  216. proc XkbActionSetCtrls*(a: PXkbCtrlsAction, c: int8)
  217. proc XkbActionCtrls*(a: PXkbCtrlsAction): int16
  218. type
  219. PXkbMessageAction* = ptr TXkbMessageAction
  220. TXkbMessageAction*{.final.} = object
  221. theType*: int8
  222. flags*: int8
  223. message*: array[0..5, char]
  224. type
  225. PXkbRedirectKeyAction* = ptr TXkbRedirectKeyAction
  226. TXkbRedirectKeyAction*{.final.} = object
  227. theType*: int8
  228. new_key*: int8
  229. mods_mask*: int8
  230. mods*: int8
  231. vmods_mask0*: int8
  232. vmods_mask1*: int8
  233. vmods0*: int8
  234. vmods1*: int8
  235. proc XkbSARedirectVMods*(a: PXkbRedirectKeyAction): int16
  236. proc XkbSARedirectSetVMods*(a: PXkbRedirectKeyAction, m: int8)
  237. proc XkbSARedirectVModsMask*(a: PXkbRedirectKeyAction): int16
  238. proc XkbSARedirectSetVModsMask*(a: PXkbRedirectKeyAction, m: int8)
  239. type
  240. PXkbDeviceBtnAction* = ptr TXkbDeviceBtnAction
  241. TXkbDeviceBtnAction*{.final.} = object
  242. theType*: int8
  243. flags*: int8
  244. count*: int8
  245. button*: int8
  246. device*: int8
  247. type
  248. PXkbDeviceValuatorAction* = ptr TXkbDeviceValuatorAction
  249. TXkbDeviceValuatorAction*{.final.} = object #
  250. # Macros to classify key actions
  251. #
  252. theType*: int8
  253. device*: int8
  254. v1_what*: int8
  255. v1_ndx*: int8
  256. v1_value*: int8
  257. v2_what*: int8
  258. v2_ndx*: int8
  259. v2_value*: int8
  260. const
  261. XkbAnyActionDataSize* = 7
  262. type
  263. PXkbAnyAction* = ptr TXkbAnyAction
  264. TXkbAnyAction*{.final.} = object
  265. theType*: int8
  266. data*: array[0..XkbAnyActionDataSize - 1, int8]
  267. proc XkbIsModAction*(a: PXkbAnyAction): bool
  268. proc XkbIsGroupAction*(a: PXkbAnyAction): bool
  269. proc XkbIsPtrAction*(a: PXkbAnyAction): bool
  270. type
  271. PXkbAction* = ptr TXkbAction
  272. TXkbAction*{.final.} = object #
  273. # XKB request codes, used in:
  274. # - xkbReqType field of all requests
  275. # - requestMinor field of some events
  276. #
  277. any*: TXkbAnyAction
  278. mods*: TXkbModAction
  279. group*: TXkbGroupAction
  280. iso*: TXkbISOAction
  281. thePtr*: TXkbPtrAction
  282. btn*: TXkbPtrBtnAction
  283. dflt*: TXkbPtrDfltAction
  284. screen*: TXkbSwitchScreenAction
  285. ctrls*: TXkbCtrlsAction
  286. msg*: TXkbMessageAction
  287. redirect*: TXkbRedirectKeyAction
  288. devbtn*: TXkbDeviceBtnAction
  289. devval*: TXkbDeviceValuatorAction
  290. theType*: int8
  291. const
  292. X_kbUseExtension* = 0
  293. X_kbSelectEvents* = 1
  294. X_kbBell* = 3
  295. X_kbGetState* = 4
  296. X_kbLatchLockState* = 5
  297. X_kbGetControls* = 6
  298. X_kbSetControls* = 7
  299. X_kbGetMap* = 8
  300. X_kbSetMap* = 9
  301. X_kbGetCompatMap* = 10
  302. X_kbSetCompatMap* = 11
  303. X_kbGetIndicatorState* = 12
  304. X_kbGetIndicatorMap* = 13
  305. X_kbSetIndicatorMap* = 14
  306. X_kbGetNamedIndicator* = 15
  307. X_kbSetNamedIndicator* = 16
  308. X_kbGetNames* = 17
  309. X_kbSetNames* = 18
  310. X_kbGetGeometry* = 19
  311. X_kbSetGeometry* = 20
  312. X_kbPerClientFlags* = 21
  313. X_kbListComponents* = 22
  314. X_kbGetKbdByName* = 23
  315. X_kbGetDeviceInfo* = 24
  316. X_kbSetDeviceInfo* = 25
  317. X_kbSetDebuggingFlags* = 101 #
  318. # In the X sense, XKB reports only one event.
  319. # The type field of all XKB events is XkbEventCode
  320. #
  321. const
  322. XkbEventCode* = 0
  323. XkbNumberEvents* = XkbEventCode + 1 #
  324. # XKB has a minor event code so it can use one X event code for
  325. # multiple purposes.
  326. # - reported in the xkbType field of all XKB events.
  327. # - XkbSelectEventDetails: Indicates the event for which event details
  328. # are being changed
  329. #
  330. const
  331. XkbNewKeyboardNotify* = 0
  332. XkbMapNotify* = 1
  333. XkbStateNotify* = 2
  334. XkbControlsNotify* = 3
  335. XkbIndicatorStateNotify* = 4
  336. XkbIndicatorMapNotify* = 5
  337. XkbNamesNotify* = 6
  338. XkbCompatMapNotify* = 7
  339. XkbBellNotify* = 8
  340. XkbActionMessage* = 9
  341. XkbAccessXNotify* = 10
  342. XkbExtensionDeviceNotify* = 11 #
  343. # Event Mask:
  344. # - XkbSelectEvents: Specifies event interest.
  345. #
  346. const
  347. XkbNewKeyboardNotifyMask* = int(1) shl 0
  348. XkbMapNotifyMask* = int(1) shl 1
  349. XkbStateNotifyMask* = int(1) shl 2
  350. XkbControlsNotifyMask* = int(1) shl 3
  351. XkbIndicatorStateNotifyMask* = int(1) shl 4
  352. XkbIndicatorMapNotifyMask* = int(1) shl 5
  353. XkbNamesNotifyMask* = int(1) shl 6
  354. XkbCompatMapNotifyMask* = int(1) shl 7
  355. XkbBellNotifyMask* = int(1) shl 8
  356. XkbActionMessageMask* = int(1) shl 9
  357. XkbAccessXNotifyMask* = int(1) shl 10
  358. XkbExtensionDeviceNotifyMask* = int(1) shl 11
  359. XkbAllEventsMask* = 0x00000FFF #
  360. # NewKeyboardNotify event details:
  361. #
  362. const
  363. XkbNKN_KeycodesMask* = int(1) shl 0
  364. XkbNKN_GeometryMask* = int(1) shl 1
  365. XkbNKN_DeviceIDMask* = int(1) shl 2
  366. XkbAllNewKeyboardEventsMask* = 0x00000007 #
  367. # AccessXNotify event types:
  368. # - The 'what' field of AccessXNotify events reports the
  369. # reason that the event was generated.
  370. #
  371. const
  372. XkbAXN_SKPress* = 0
  373. XkbAXN_SKAccept* = 1
  374. XkbAXN_SKReject* = 2
  375. XkbAXN_SKRelease* = 3
  376. XkbAXN_BKAccept* = 4
  377. XkbAXN_BKReject* = 5
  378. XkbAXN_AXKWarning* = 6 #
  379. # AccessXNotify details:
  380. # - Used as an event detail mask to limit the conditions under which
  381. # AccessXNotify events are reported
  382. #
  383. const
  384. XkbAXN_SKPressMask* = int(1) shl 0
  385. XkbAXN_SKAcceptMask* = int(1) shl 1
  386. XkbAXN_SKRejectMask* = int(1) shl 2
  387. XkbAXN_SKReleaseMask* = int(1) shl 3
  388. XkbAXN_BKAcceptMask* = int(1) shl 4
  389. XkbAXN_BKRejectMask* = int(1) shl 5
  390. XkbAXN_AXKWarningMask* = int(1) shl 6
  391. XkbAllAccessXEventsMask* = 0x0000000F #
  392. # State detail mask:
  393. # - The 'changed' field of StateNotify events reports which of
  394. # the keyboard state components have changed.
  395. # - Used as an event detail mask to limit the conditions under
  396. # which StateNotify events are reported.
  397. #
  398. const
  399. XkbModifierStateMask* = int(1) shl 0
  400. XkbModifierBaseMask* = int(1) shl 1
  401. XkbModifierLatchMask* = int(1) shl 2
  402. XkbModifierLockMask* = int(1) shl 3
  403. XkbGroupStateMask* = int(1) shl 4
  404. XkbGroupBaseMask* = int(1) shl 5
  405. XkbGroupLatchMask* = int(1) shl 6
  406. XkbGroupLockMask* = int(1) shl 7
  407. XkbCompatStateMask* = int(1) shl 8
  408. XkbGrabModsMask* = int(1) shl 9
  409. XkbCompatGrabModsMask* = int(1) shl 10
  410. XkbLookupModsMask* = int(1) shl 11
  411. XkbCompatLookupModsMask* = int(1) shl 12
  412. XkbPointerButtonMask* = int(1) shl 13
  413. XkbAllStateComponentsMask* = 0x00003FFF #
  414. # Controls detail masks:
  415. # The controls specified in XkbAllControlsMask:
  416. # - The 'changed' field of ControlsNotify events reports which of
  417. # the keyboard controls have changed.
  418. # - The 'changeControls' field of the SetControls request specifies
  419. # the controls for which values are to be changed.
  420. # - Used as an event detail mask to limit the conditions under
  421. # which ControlsNotify events are reported.
  422. #
  423. # The controls specified in the XkbAllBooleanCtrlsMask:
  424. # - The 'enabledControls' field of ControlsNotify events reports the
  425. # current status of the boolean controls.
  426. # - The 'enabledControlsChanges' field of ControlsNotify events reports
  427. # any boolean controls that have been turned on or off.
  428. # - The 'affectEnabledControls' and 'enabledControls' fields of the
  429. # kbSetControls request change the set of enabled controls.
  430. # - The 'accessXTimeoutMask' and 'accessXTimeoutValues' fields of
  431. # an XkbControlsRec specify the controls to be changed if the keyboard
  432. # times out and the values to which they should be changed.
  433. # - The 'autoCtrls' and 'autoCtrlsValues' fields of the PerClientFlags
  434. # request specifies the specify the controls to be reset when the
  435. # client exits and the values to which they should be reset.
  436. # - The 'ctrls' field of an indicator map specifies the controls
  437. # that drive the indicator.
  438. # - Specifies the boolean controls affected by the SetControls and
  439. # LockControls key actions.
  440. #
  441. const
  442. XkbRepeatKeysMask* = int(1) shl 0
  443. XkbSlowKeysMask* = int(1) shl 1
  444. XkbBounceKeysMask* = int(1) shl 2
  445. XkbStickyKeysMask* = int(1) shl 3
  446. XkbMouseKeysMask* = int(1) shl 4
  447. XkbMouseKeysAccelMask* = int(1) shl 5
  448. XkbAccessXKeysMask* = int(1) shl 6
  449. XkbAccessXTimeoutMask* = int(1) shl 7
  450. XkbAccessXFeedbackMask* = int(1) shl 8
  451. XkbAudibleBellMask* = int(1) shl 9
  452. XkbOverlay1Mask* = int(1) shl 10
  453. XkbOverlay2Mask* = int(1) shl 11
  454. XkbIgnoreGroupLockMask* = int(1) shl 12
  455. XkbGroupsWrapMask* = int(1) shl 27
  456. XkbInternalModsMask* = int(1) shl 28
  457. XkbIgnoreLockModsMask* = int(1) shl 29
  458. XkbPerKeyRepeatMask* = int(1) shl 30
  459. XkbControlsEnabledMask* = int(1) shl 31
  460. XkbAccessXOptionsMask* = XkbStickyKeysMask or XkbAccessXFeedbackMask
  461. XkbAllBooleanCtrlsMask* = 0x00001FFF
  462. XkbAllControlsMask* = 0xF8001FFF #
  463. # Compatibility Map Compontents:
  464. # - Specifies the components to be allocated in XkbAllocCompatMap.
  465. #
  466. const
  467. XkbSymInterpMask* = 1 shl 0
  468. XkbGroupCompatMask* = 1 shl 1
  469. XkbAllCompatMask* = 0x00000003 #
  470. # Assorted constants and limits.
  471. #
  472. const
  473. XkbAllIndicatorsMask* = 0xFFFFFFFF #
  474. # Map components masks:
  475. # Those in AllMapComponentsMask:
  476. # - Specifies the individual fields to be loaded or changed for the
  477. # GetMap and SetMap requests.
  478. # Those in ClientInfoMask:
  479. # - Specifies the components to be allocated by XkbAllocClientMap.
  480. # Those in ServerInfoMask:
  481. # - Specifies the components to be allocated by XkbAllocServerMap.
  482. #
  483. const
  484. XkbKeyTypesMask* = 1 shl 0
  485. XkbKeySymsMask* = 1 shl 1
  486. XkbModifierMapMask* = 1 shl 2
  487. XkbExplicitComponentsMask* = 1 shl 3
  488. XkbKeyActionsMask* = 1 shl 4
  489. XkbKeyBehaviorsMask* = 1 shl 5
  490. XkbVirtualModsMask* = 1 shl 6
  491. XkbVirtualModMapMask* = 1 shl 7
  492. XkbAllClientInfoMask* = XkbKeyTypesMask or XkbKeySymsMask or
  493. XkbModifierMapMask
  494. XkbAllServerInfoMask* = XkbExplicitComponentsMask or XkbKeyActionsMask or
  495. XkbKeyBehaviorsMask or XkbVirtualModsMask or XkbVirtualModMapMask
  496. XkbAllMapComponentsMask* = XkbAllClientInfoMask or XkbAllServerInfoMask #
  497. # Names component mask:
  498. # - Specifies the names to be loaded or changed for the GetNames and
  499. # SetNames requests.
  500. # - Specifies the names that have changed in a NamesNotify event.
  501. # - Specifies the names components to be allocated by XkbAllocNames.
  502. #
  503. const
  504. XkbKeycodesNameMask* = 1 shl 0
  505. XkbGeometryNameMask* = 1 shl 1
  506. XkbSymbolsNameMask* = 1 shl 2
  507. XkbPhysSymbolsNameMask* = 1 shl 3
  508. XkbTypesNameMask* = 1 shl 4
  509. XkbCompatNameMask* = 1 shl 5
  510. XkbKeyTypeNamesMask* = 1 shl 6
  511. XkbKTLevelNamesMask* = 1 shl 7
  512. XkbIndicatorNamesMask* = 1 shl 8
  513. XkbKeyNamesMask* = 1 shl 9
  514. XkbKeyAliasesMask* = 1 shl 10
  515. XkbVirtualModNamesMask* = 1 shl 11
  516. XkbGroupNamesMask* = 1 shl 12
  517. XkbRGNamesMask* = 1 shl 13
  518. XkbComponentNamesMask* = 0x0000003F
  519. XkbAllNamesMask* = 0x00003FFF #
  520. # Miscellaneous event details:
  521. # - event detail masks for assorted events that don't reall
  522. # have any details.
  523. #
  524. const
  525. XkbAllStateEventsMask* = XkbAllStateComponentsMask
  526. XkbAllMapEventsMask* = XkbAllMapComponentsMask
  527. XkbAllControlEventsMask* = XkbAllControlsMask
  528. XkbAllIndicatorEventsMask* = XkbAllIndicatorsMask
  529. XkbAllNameEventsMask* = XkbAllNamesMask
  530. XkbAllCompatMapEventsMask* = XkbAllCompatMask
  531. XkbAllBellEventsMask* = int(1) shl 0
  532. XkbAllActionMessagesMask* = int(1) shl 0 #
  533. # XKB reports one error: BadKeyboard
  534. # A further reason for the error is encoded into to most significant
  535. # byte of the resourceID for the error:
  536. # XkbErr_BadDevice - the device in question was not found
  537. # XkbErr_BadClass - the device was found but it doesn't belong to
  538. # the appropriate class.
  539. # XkbErr_BadId - the device was found and belongs to the right
  540. # class, but not feedback with a matching id was
  541. # found.
  542. # The low byte of the resourceID for this error contains the device
  543. # id, class specifier or feedback id that failed.
  544. #
  545. const
  546. XkbKeyboard* = 0
  547. XkbNumberErrors* = 1
  548. XkbErr_BadDevice* = 0x000000FF
  549. XkbErr_BadClass* = 0x000000FE
  550. XkbErr_BadId* = 0x000000FD #
  551. # Keyboard Components Mask:
  552. # - Specifies the components that follow a GetKeyboardByNameReply
  553. #
  554. const
  555. XkbClientMapMask* = int(1) shl 0
  556. XkbServerMapMask* = int(1) shl 1
  557. XkbCompatMapMask* = int(1) shl 2
  558. XkbIndicatorMapMask* = int(1) shl 3
  559. XkbNamesMask* = int(1) shl 4
  560. XkbGeometryMask* = int(1) shl 5
  561. XkbControlsMask* = int(1) shl 6
  562. XkbAllComponentsMask* = 0x0000007F #
  563. # AccessX Options Mask
  564. # - The 'accessXOptions' field of an XkbControlsRec specifies the
  565. # AccessX options that are currently in effect.
  566. # - The 'accessXTimeoutOptionsMask' and 'accessXTimeoutOptionsValues'
  567. # fields of an XkbControlsRec specify the Access X options to be
  568. # changed if the keyboard times out and the values to which they
  569. # should be changed.
  570. #
  571. const
  572. XkbAX_SKPressFBMask* = int(1) shl 0
  573. XkbAX_SKAcceptFBMask* = int(1) shl 1
  574. XkbAX_FeatureFBMask* = int(1) shl 2
  575. XkbAX_SlowWarnFBMask* = int(1) shl 3
  576. XkbAX_IndicatorFBMask* = int(1) shl 4
  577. XkbAX_StickyKeysFBMask* = int(1) shl 5
  578. XkbAX_TwoKeysMask* = int(1) shl 6
  579. XkbAX_LatchToLockMask* = int(1) shl 7
  580. XkbAX_SKReleaseFBMask* = int(1) shl 8
  581. XkbAX_SKRejectFBMask* = int(1) shl 9
  582. XkbAX_BKRejectFBMask* = int(1) shl 10
  583. XkbAX_DumbBellFBMask* = int(1) shl 11
  584. XkbAX_FBOptionsMask* = 0x00000F3F
  585. XkbAX_SKOptionsMask* = 0x000000C0
  586. XkbAX_AllOptionsMask* = 0x00000FFF #
  587. # XkbUseCoreKbd is used to specify the core keyboard without having
  588. # to look up its X input extension identifier.
  589. # XkbUseCorePtr is used to specify the core pointer without having
  590. # to look up its X input extension identifier.
  591. # XkbDfltXIClass is used to specify "don't care" any place that the
  592. # XKB protocol is looking for an X Input Extension
  593. # device class.
  594. # XkbDfltXIId is used to specify "don't care" any place that the
  595. # XKB protocol is looking for an X Input Extension
  596. # feedback identifier.
  597. # XkbAllXIClasses is used to get information about all device indicators,
  598. # whether they're part of the indicator feedback class
  599. # or the keyboard feedback class.
  600. # XkbAllXIIds is used to get information about all device indicator
  601. # feedbacks without having to list them.
  602. # XkbXINone is used to indicate that no class or id has been specified.
  603. # XkbLegalXILedClass(c) True if 'c' specifies a legal class with LEDs
  604. # XkbLegalXIBellClass(c) True if 'c' specifies a legal class with bells
  605. # XkbExplicitXIDevice(d) True if 'd' explicitly specifies a device
  606. # XkbExplicitXIClass(c) True if 'c' explicitly specifies a device class
  607. # XkbExplicitXIId(c) True if 'i' explicitly specifies a device id
  608. # XkbSingleXIClass(c) True if 'c' specifies exactly one device class,
  609. # including the default.
  610. # XkbSingleXIId(i) True if 'i' specifies exactly one device
  611. # identifier, including the default.
  612. #
  613. const
  614. XkbUseCoreKbd* = 0x00000100
  615. XkbUseCorePtr* = 0x00000200
  616. XkbDfltXIClass* = 0x00000300
  617. XkbDfltXIId* = 0x00000400
  618. XkbAllXIClasses* = 0x00000500
  619. XkbAllXIIds* = 0x00000600
  620. XkbXINone* = 0x0000FF00
  621. proc XkbLegalXILedClass*(c: int): bool
  622. proc XkbLegalXIBellClass*(c: int): bool
  623. proc XkbExplicitXIDevice*(c: int): bool
  624. proc XkbExplicitXIClass*(c: int): bool
  625. proc XkbExplicitXIId*(c: int): bool
  626. proc XkbSingleXIClass*(c: int): bool
  627. proc XkbSingleXIId*(c: int): bool
  628. const
  629. XkbNoModifier* = 0x000000FF
  630. XkbNoShiftLevel* = 0x000000FF
  631. XkbNoShape* = 0x000000FF
  632. XkbNoIndicator* = 0x000000FF
  633. XkbNoModifierMask* = 0
  634. XkbAllModifiersMask* = 0x000000FF
  635. XkbAllVirtualModsMask* = 0x0000FFFF
  636. XkbNumKbdGroups* = 4
  637. XkbMaxKbdGroup* = XkbNumKbdGroups - 1
  638. XkbMaxMouseKeysBtn* = 4 #
  639. # Group Index and Mask:
  640. # - Indices into the kt_index array of a key type.
  641. # - Mask specifies types to be changed for XkbChangeTypesOfKey
  642. #
  643. const
  644. XkbGroup1Index* = 0
  645. XkbGroup2Index* = 1
  646. XkbGroup3Index* = 2
  647. XkbGroup4Index* = 3
  648. XkbAnyGroup* = 254
  649. XkbAllGroups* = 255
  650. XkbGroup1Mask* = 1 shl 0
  651. XkbGroup2Mask* = 1 shl 1
  652. XkbGroup3Mask* = 1 shl 2
  653. XkbGroup4Mask* = 1 shl 3
  654. XkbAnyGroupMask* = 1 shl 7
  655. XkbAllGroupsMask* = 0x0000000F #
  656. # BuildCoreState: Given a keyboard group and a modifier state,
  657. # construct the value to be reported an event.
  658. # GroupForCoreState: Given the state reported in an event,
  659. # determine the keyboard group.
  660. # IsLegalGroup: Returns TRUE if 'g' is a valid group index.
  661. #
  662. proc XkbBuildCoreState*(m, g: int): int
  663. proc XkbGroupForCoreState*(s: int): int
  664. proc XkbIsLegalGroup*(g: int): bool
  665. #
  666. # GroupsWrap values:
  667. # - The 'groupsWrap' field of an XkbControlsRec specifies the
  668. # treatment of out of range groups.
  669. # - Bits 6 and 7 of the group info field of a key symbol map
  670. # specify the interpretation of out of range groups for the
  671. # corresponding key.
  672. #
  673. const
  674. XkbWrapIntoRange* = 0x00000000
  675. XkbClampIntoRange* = 0x00000040
  676. XkbRedirectIntoRange* = 0x00000080 #
  677. # Action flags: Reported in the 'flags' field of most key actions.
  678. # Interpretation depends on the type of the action; not all actions
  679. # accept all flags.
  680. #
  681. # Option Used for Actions
  682. # ------ ----------------
  683. # ClearLocks SetMods, LatchMods, SetGroup, LatchGroup
  684. # LatchToLock SetMods, LatchMods, SetGroup, LatchGroup
  685. # LockNoLock LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
  686. # LockNoUnlock LockMods, ISOLock, LockPtrBtn, LockDeviceBtn
  687. # UseModMapMods SetMods, LatchMods, LockMods, ISOLock
  688. # GroupAbsolute SetGroup, LatchGroup, LockGroup, ISOLock
  689. # UseDfltButton PtrBtn, LockPtrBtn
  690. # NoAcceleration MovePtr
  691. # MoveAbsoluteX MovePtr
  692. # MoveAbsoluteY MovePtr
  693. # ISODfltIsGroup ISOLock
  694. # ISONoAffectMods ISOLock
  695. # ISONoAffectGroup ISOLock
  696. # ISONoAffectPtr ISOLock
  697. # ISONoAffectCtrls ISOLock
  698. # MessageOnPress ActionMessage
  699. # MessageOnRelease ActionMessage
  700. # MessageGenKeyEvent ActionMessage
  701. # AffectDfltBtn SetPtrDflt
  702. # DfltBtnAbsolute SetPtrDflt
  703. # SwitchApplication SwitchScreen
  704. # SwitchAbsolute SwitchScreen
  705. #
  706. const
  707. XkbSA_ClearLocks* = int(1) shl 0
  708. XkbSA_LatchToLock* = int(1) shl 1
  709. XkbSA_LockNoLock* = int(1) shl 0
  710. XkbSA_LockNoUnlock* = int(1) shl 1
  711. XkbSA_UseModMapMods* = int(1) shl 2
  712. XkbSA_GroupAbsolute* = int(1) shl 2
  713. XkbSA_UseDfltButton* = 0
  714. XkbSA_NoAcceleration* = int(1) shl 0
  715. XkbSA_MoveAbsoluteX* = int(1) shl 1
  716. XkbSA_MoveAbsoluteY* = int(1) shl 2
  717. XkbSA_ISODfltIsGroup* = int(1) shl 7
  718. XkbSA_ISONoAffectMods* = int(1) shl 6
  719. XkbSA_ISONoAffectGroup* = int(1) shl 5
  720. XkbSA_ISONoAffectPtr* = int(1) shl 4
  721. XkbSA_ISONoAffectCtrls* = int(1) shl 3
  722. XkbSA_ISOAffectMask* = 0x00000078
  723. XkbSA_MessageOnPress* = int(1) shl 0
  724. XkbSA_MessageOnRelease* = int(1) shl 1
  725. XkbSA_MessageGenKeyEvent* = int(1) shl 2
  726. XkbSA_AffectDfltBtn* = 1
  727. XkbSA_DfltBtnAbsolute* = int(1) shl 2
  728. XkbSA_SwitchApplication* = int(1) shl 0
  729. XkbSA_SwitchAbsolute* = int(1) shl 2 #
  730. # The following values apply to the SA_DeviceValuator
  731. # action only. Valuator operations specify the action
  732. # to be taken. Values specified in the action are
  733. # multiplied by 2^scale before they are applied.
  734. #
  735. const
  736. XkbSA_IgnoreVal* = 0x00000000
  737. XkbSA_SetValMin* = 0x00000010
  738. XkbSA_SetValCenter* = 0x00000020
  739. XkbSA_SetValMax* = 0x00000030
  740. XkbSA_SetValRelative* = 0x00000040
  741. XkbSA_SetValAbsolute* = 0x00000050
  742. XkbSA_ValOpMask* = 0x00000070
  743. XkbSA_ValScaleMask* = 0x00000007
  744. proc XkbSA_ValOp*(a: int): int
  745. proc XkbSA_ValScale*(a: int): int
  746. #
  747. # Action types: specifies the type of a key action. Reported in the
  748. # type field of all key actions.
  749. #
  750. const
  751. XkbSA_NoAction* = 0x00000000
  752. XkbSA_SetMods* = 0x00000001
  753. XkbSA_LatchMods* = 0x00000002
  754. XkbSA_LockMods* = 0x00000003
  755. XkbSA_SetGroup* = 0x00000004
  756. XkbSA_LatchGroup* = 0x00000005
  757. XkbSA_LockGroup* = 0x00000006
  758. XkbSA_MovePtr* = 0x00000007
  759. XkbSA_PtrBtn* = 0x00000008
  760. XkbSA_LockPtrBtn* = 0x00000009
  761. XkbSA_SetPtrDflt* = 0x0000000A
  762. XkbSA_ISOLock* = 0x0000000B
  763. XkbSA_Terminate* = 0x0000000C
  764. XkbSA_SwitchScreen* = 0x0000000D
  765. XkbSA_SetControls* = 0x0000000E
  766. XkbSA_LockControls* = 0x0000000F
  767. XkbSA_ActionMessage* = 0x00000010
  768. XkbSA_RedirectKey* = 0x00000011
  769. XkbSA_DeviceBtn* = 0x00000012
  770. XkbSA_LockDeviceBtn* = 0x00000013
  771. XkbSA_DeviceValuator* = 0x00000014
  772. XkbSA_LastAction* = XkbSA_DeviceValuator
  773. XkbSA_NumActions* = XkbSA_LastAction + 1
  774. const
  775. XkbSA_XFree86Private* = 0x00000086
  776. #
  777. # Specifies the key actions that clear latched groups or modifiers.
  778. #
  779. const ##define XkbSA_BreakLatch \
  780. # ((1<<XkbSA_NoAction)|(1<<XkbSA_PtrBtn)|(1<<XkbSA_LockPtrBtn)|\
  781. # (1<<XkbSA_Terminate)|(1<<XkbSA_SwitchScreen)|(1<<XkbSA_SetControls)|\
  782. # (1<<XkbSA_LockControls)|(1<<XkbSA_ActionMessage)|\
  783. # (1<<XkbSA_RedirectKey)|(1<<XkbSA_DeviceBtn)|(1<<XkbSA_LockDeviceBtn))
  784. #
  785. XkbSA_BreakLatch* = (1 shl XkbSA_PtrBtn) or (1 shl XkbSA_LockPtrBtn) or
  786. (1 shl XkbSA_Terminate) or (1 shl XkbSA_SwitchScreen) or
  787. (1 shl XkbSA_SetControls) or (1 shl XkbSA_LockControls) or
  788. (1 shl XkbSA_ActionMessage) or (1 shl XkbSA_RedirectKey) or
  789. (1 shl XkbSA_DeviceBtn) or (1 shl XkbSA_LockDeviceBtn) #
  790. # Key Behavior Qualifier:
  791. # KB_Permanent indicates that the behavior describes an unalterable
  792. # characteristic of the keyboard, not an XKB software-simulation of
  793. # the listed behavior.
  794. # Key Behavior Types:
  795. # Specifies the behavior of the underlying key.
  796. #
  797. const
  798. XkbKB_Permanent* = 0x00000080
  799. XkbKB_OpMask* = 0x0000007F
  800. XkbKB_Default* = 0x00000000
  801. XkbKB_Lock* = 0x00000001
  802. XkbKB_RadioGroup* = 0x00000002
  803. XkbKB_Overlay1* = 0x00000003
  804. XkbKB_Overlay2* = 0x00000004
  805. XkbKB_RGAllowNone* = 0x00000080 #
  806. # Various macros which describe the range of legal keycodes.
  807. #
  808. const
  809. XkbMinLegalKeyCode* = 8
  810. XkbMaxLegalKeyCode* = 255
  811. XkbMaxKeyCount* = XkbMaxLegalKeyCode - XkbMinLegalKeyCode + 1
  812. XkbPerKeyBitArraySize* = (XkbMaxLegalKeyCode + 1) div 8
  813. proc XkbIsLegalKeycode*(k: int): bool
  814. type
  815. PXkbControlsPtr* = ptr TXkbControlsRec
  816. TXkbControlsRec*{.final.} = object
  817. mk_dflt_btn*: int8
  818. num_groups*: int8
  819. groups_wrap*: int8
  820. internal*: TXkbModsRec
  821. ignore_lock*: TXkbModsRec
  822. enabled_ctrls*: int16
  823. repeat_delay*: int16
  824. repeat_interval*: int16
  825. slow_keys_delay*: int16
  826. debounce_delay*: int16
  827. mk_delay*: int16
  828. mk_interval*: int16
  829. mk_time_to_max*: int16
  830. mk_max_speed*: int16
  831. mk_curve*: int16
  832. ax_options*: int16
  833. ax_timeout*: int16
  834. axt_opts_mask*: int16
  835. axt_opts_values*: int16
  836. axt_ctrls_mask*: int16
  837. axt_ctrls_values*: int16
  838. per_key_repeat*: array[0..XkbPerKeyBitArraySize - 1, int8]
  839. proc XkbAX_AnyFeedback*(c: PXkbControlsPtr): int16
  840. proc XkbAX_NeedOption*(c: PXkbControlsPtr, w: int16): int16
  841. proc XkbAX_NeedFeedback*(c: PXkbControlsPtr, w: int16): bool
  842. #
  843. # Assorted constants and limits.
  844. #
  845. const
  846. XkbNumModifiers* = 8
  847. XkbNumVirtualMods* = 16
  848. XkbNumIndicators* = 32
  849. XkbMaxRadioGroups* = 32
  850. XkbAllRadioGroupsMask* = 0xFFFFFFFF
  851. XkbMaxShiftLevel* = 63
  852. XkbMaxSymsPerKey* = XkbMaxShiftLevel * XkbNumKbdGroups
  853. XkbRGMaxMembers* = 12
  854. XkbActionMessageLength* = 6
  855. XkbKeyNameLength* = 4
  856. XkbMaxRedirectCount* = 8
  857. XkbGeomPtsPerMM* = 10
  858. XkbGeomMaxColors* = 32
  859. XkbGeomMaxLabelColors* = 3
  860. XkbGeomMaxPriority* = 255
  861. type
  862. PXkbServerMapPtr* = ptr TXkbServerMapRec
  863. TXkbServerMapRec*{.final.} = object
  864. num_acts*: int16
  865. size_acts*: int16
  866. acts*: ptr array[0..0xfff, TXkbAction]
  867. behaviors*: PXkbBehavior
  868. key_acts*: PWord
  869. explicit*: PByte
  870. vmods*: array[0..XkbNumVirtualMods - 1, int8]
  871. vmodmap*: PWord
  872. proc XkbSMKeyActionsPtr*(m: PXkbServerMapPtr, k: int16): PXkbAction
  873. #
  874. # Structures and access macros used primarily by clients
  875. #
  876. type
  877. PXkbSymMapPtr* = ptr TXkbSymMapRec
  878. TXkbSymMapRec*{.final.} = object
  879. kt_index*: array[0..XkbNumKbdGroups - 1, int8]
  880. group_info*: int8
  881. width*: int8
  882. offset*: int8
  883. type
  884. PXkbClientMapPtr* = ptr TXkbClientMapRec
  885. TXkbClientMapRec*{.final.} = object
  886. size_types*: int8
  887. num_types*: int8
  888. types*: ptr array[0..0xffff, TXkbKeyTypeRec]
  889. size_syms*: int16
  890. num_syms*: int16
  891. syms*: ptr array[0..0xffff, TKeySym]
  892. key_sym_map*: ptr array[0..0xffff, TXkbSymMapRec]
  893. modmap*: PByte
  894. proc XkbCMKeyGroupInfo*(m: PXkbClientMapPtr, k: int16): int8
  895. proc XkbCMKeyNumGroups*(m: PXkbClientMapPtr, k: int16): int8
  896. proc XkbCMKeyGroupWidth*(m: PXkbClientMapPtr, k: int16, g: int8): int8
  897. proc XkbCMKeyGroupsWidth*(m: PXkbClientMapPtr, k: int16): int8
  898. proc XkbCMKeyTypeIndex*(m: PXkbClientMapPtr, k: int16, g: int8): int8
  899. proc XkbCMKeyType*(m: PXkbClientMapPtr, k: int16, g: int8): PXkbKeyTypePtr
  900. proc XkbCMKeyNumSyms*(m: PXkbClientMapPtr, k: int16): int16
  901. proc XkbCMKeySymsOffset*(m: PXkbClientMapPtr, k: int16): int8
  902. #
  903. # Compatibility structures and access macros
  904. #
  905. type
  906. PXkbSymInterpretPtr* = ptr TXkbSymInterpretRec
  907. TXkbSymInterpretRec*{.final.} = object
  908. sym*: TKeySym
  909. flags*: int8
  910. match*: int8
  911. mods*: int8
  912. virtual_mod*: int8
  913. act*: TXkbAnyAction
  914. type
  915. PXkbCompatMapPtr* = ptr TXkbCompatMapRec
  916. TXkbCompatMapRec*{.final.} = object
  917. sym_interpret*: PXkbSymInterpretPtr
  918. groups*: array[0..XkbNumKbdGroups - 1, TXkbModsRec]
  919. num_si*: int16
  920. size_si*: int16
  921. type
  922. PXkbIndicatorMapPtr* = ptr TXkbIndicatorMapRec
  923. TXkbIndicatorMapRec*{.final.} = object
  924. flags*: int8
  925. which_groups*: int8
  926. groups*: int8
  927. which_mods*: int8
  928. mods*: TXkbModsRec
  929. ctrls*: int16
  930. proc XkbIM_IsAuto*(i: PXkbIndicatorMapPtr): bool
  931. proc XkbIM_InUse*(i: PXkbIndicatorMapPtr): bool
  932. type
  933. PXkbIndicatorPtr* = ptr TXkbIndicatorRec
  934. TXkbIndicatorRec*{.final.} = object
  935. phys_indicators*: int32
  936. maps*: array[0..XkbNumIndicators - 1, TXkbIndicatorMapRec]
  937. type
  938. PXkbKeyNamePtr* = ptr TXkbKeyNameRec
  939. TXkbKeyNameRec*{.final.} = object
  940. name*: array[0..XkbKeyNameLength - 1, char]
  941. type
  942. PXkbKeyAliasPtr* = ptr TXkbKeyAliasRec
  943. TXkbKeyAliasRec*{.final.} = object #
  944. # Names for everything
  945. #
  946. float*: array[0..XkbKeyNameLength - 1, char]
  947. alias*: array[0..XkbKeyNameLength - 1, char]
  948. type
  949. PXkbNamesPtr* = ptr TXkbNamesRec
  950. TXkbNamesRec*{.final.} = object #
  951. # Key Type index and mask for the four standard key types.
  952. #
  953. keycodes*: TAtom
  954. geometry*: TAtom
  955. symbols*: TAtom
  956. types*: TAtom
  957. compat*: TAtom
  958. vmods*: array[0..XkbNumVirtualMods - 1, TAtom]
  959. indicators*: array[0..XkbNumIndicators - 1, TAtom]
  960. groups*: array[0..XkbNumKbdGroups - 1, TAtom]
  961. keys*: PXkbKeyNamePtr
  962. key_aliases*: PXkbKeyAliasPtr
  963. radio_groups*: PAtom
  964. phys_symbols*: TAtom
  965. num_keys*: int8
  966. num_key_aliases*: int8
  967. num_rg*: int16
  968. const
  969. XkbOneLevelIndex* = 0
  970. XkbTwoLevelIndex* = 1
  971. XkbAlphabeticIndex* = 2
  972. XkbKeypadIndex* = 3
  973. XkbLastRequiredType* = XkbKeypadIndex
  974. XkbNumRequiredTypes* = XkbLastRequiredType + 1
  975. XkbMaxKeyTypes* = 255
  976. XkbOneLevelMask* = 1 shl 0
  977. XkbTwoLevelMask* = 1 shl 1
  978. XkbAlphabeticMask* = 1 shl 2
  979. XkbKeypadMask* = 1 shl 3
  980. XkbAllRequiredTypes* = 0x0000000F
  981. proc XkbShiftLevel*(n: int8): int8
  982. proc XkbShiftLevelMask*(n: int8): int8
  983. #
  984. # Extension name and version information
  985. #
  986. const
  987. XkbName* = "XKEYBOARD"
  988. XkbMajorVersion* = 1
  989. XkbMinorVersion* = 0 #
  990. # Explicit map components:
  991. # - Used in the 'explicit' field of an XkbServerMap. Specifies
  992. # the keyboard components that should _not_ be updated automatically
  993. # in response to core protocol keyboard mapping requests.
  994. #
  995. const
  996. XkbExplicitKeyTypesMask* = 0x0000000F
  997. XkbExplicitKeyType1Mask* = 1 shl 0
  998. XkbExplicitKeyType2Mask* = 1 shl 1
  999. XkbExplicitKeyType3Mask* = 1 shl 2
  1000. XkbExplicitKeyType4Mask* = 1 shl 3
  1001. XkbExplicitInterpretMask* = 1 shl 4
  1002. XkbExplicitAutoRepeatMask* = 1 shl 5
  1003. XkbExplicitBehaviorMask* = 1 shl 6
  1004. XkbExplicitVModMapMask* = 1 shl 7
  1005. XkbAllExplicitMask* = 0x000000FF #
  1006. # Symbol interpretations flags:
  1007. # - Used in the flags field of a symbol interpretation
  1008. #
  1009. const
  1010. XkbSI_AutoRepeat* = 1 shl 0
  1011. XkbSI_LockingKey* = 1 shl 1 #
  1012. # Symbol interpretations match specification:
  1013. # - Used in the match field of a symbol interpretation to specify
  1014. # the conditions under which an interpretation is used.
  1015. #
  1016. const
  1017. XkbSI_LevelOneOnly* = 0x00000080
  1018. XkbSI_OpMask* = 0x0000007F
  1019. XkbSI_NoneOf* = 0
  1020. XkbSI_AnyOfOrNone* = 1
  1021. XkbSI_AnyOf* = 2
  1022. XkbSI_AllOf* = 3
  1023. XkbSI_Exactly* = 4 #
  1024. # Indicator map flags:
  1025. # - Used in the flags field of an indicator map to indicate the
  1026. # conditions under which and indicator can be changed and the
  1027. # effects of changing the indicator.
  1028. #
  1029. const
  1030. XkbIM_NoExplicit* = int(1) shl 7
  1031. XkbIM_NoAutomatic* = int(1) shl 6
  1032. XkbIM_LEDDrivesKB* = int(1) shl 5 #
  1033. # Indicator map component specifications:
  1034. # - Used by the 'which_groups' and 'which_mods' fields of an indicator
  1035. # map to specify which keyboard components should be used to drive
  1036. # the indicator.
  1037. #
  1038. const
  1039. XkbIM_UseBase* = int(1) shl 0
  1040. XkbIM_UseLatched* = int(1) shl 1
  1041. XkbIM_UseLocked* = int(1) shl 2
  1042. XkbIM_UseEffective* = int(1) shl 3
  1043. XkbIM_UseCompat* = int(1) shl 4
  1044. XkbIM_UseNone* = 0
  1045. XkbIM_UseAnyGroup* = XkbIM_UseBase or XkbIM_UseLatched or XkbIM_UseLocked or
  1046. XkbIM_UseEffective
  1047. XkbIM_UseAnyMods* = XkbIM_UseAnyGroup or XkbIM_UseCompat #
  1048. # GetByName components:
  1049. # - Specifies desired or necessary components to GetKbdByName request.
  1050. # - Reports the components that were found in a GetKbdByNameReply
  1051. #
  1052. const
  1053. XkbGBN_TypesMask* = int(1) shl 0
  1054. XkbGBN_CompatMapMask* = int(1) shl 1
  1055. XkbGBN_ClientSymbolsMask* = int(1) shl 2
  1056. XkbGBN_ServerSymbolsMask* = int(1) shl 3
  1057. XkbGBN_SymbolsMask* = XkbGBN_ClientSymbolsMask or XkbGBN_ServerSymbolsMask
  1058. XkbGBN_IndicatorMapMask* = int(1) shl 4
  1059. XkbGBN_KeyNamesMask* = int(1) shl 5
  1060. XkbGBN_GeometryMask* = int(1) shl 6
  1061. XkbGBN_OtherNamesMask* = int(1) shl 7
  1062. XkbGBN_AllComponentsMask* = 0x000000FF #
  1063. # ListComponents flags
  1064. #
  1065. const
  1066. XkbLC_Hidden* = int(1) shl 0
  1067. XkbLC_Default* = int(1) shl 1
  1068. XkbLC_Partial* = int(1) shl 2
  1069. XkbLC_AlphanumericKeys* = int(1) shl 8
  1070. XkbLC_ModifierKeys* = int(1) shl 9
  1071. XkbLC_KeypadKeys* = int(1) shl 10
  1072. XkbLC_FunctionKeys* = int(1) shl 11
  1073. XkbLC_AlternateGroup* = int(1) shl 12 #
  1074. # X Input Extension Interactions
  1075. # - Specifies the possible interactions between XKB and the X input
  1076. # extension
  1077. # - Used to request (XkbGetDeviceInfo) or change (XKbSetDeviceInfo)
  1078. # XKB information about an extension device.
  1079. # - Reports the list of supported optional features in the reply to
  1080. # XkbGetDeviceInfo or in an XkbExtensionDeviceNotify event.
  1081. # XkbXI_UnsupportedFeature is reported in XkbExtensionDeviceNotify
  1082. # events to indicate an attempt to use an unsupported feature.
  1083. #
  1084. const
  1085. XkbXI_KeyboardsMask* = int(1) shl 0
  1086. XkbXI_ButtonActionsMask* = int(1) shl 1
  1087. XkbXI_IndicatorNamesMask* = int(1) shl 2
  1088. XkbXI_IndicatorMapsMask* = int(1) shl 3
  1089. XkbXI_IndicatorStateMask* = int(1) shl 4
  1090. XkbXI_UnsupportedFeatureMask* = int(1) shl 15
  1091. XkbXI_AllFeaturesMask* = 0x0000001F
  1092. XkbXI_AllDeviceFeaturesMask* = 0x0000001E
  1093. XkbXI_IndicatorsMask* = 0x0000001C
  1094. XkbAllExtensionDeviceEventsMask* = 0x0000801F #
  1095. # Per-Client Flags:
  1096. # - Specifies flags to be changed by the PerClientFlags request.
  1097. #
  1098. const
  1099. XkbPCF_DetectableAutoRepeatMask* = int(1) shl 0
  1100. XkbPCF_GrabsUseXKBStateMask* = int(1) shl 1
  1101. XkbPCF_AutoResetControlsMask* = int(1) shl 2
  1102. XkbPCF_LookupStateWhenGrabbed* = int(1) shl 3
  1103. XkbPCF_SendEventUsesXKBState* = int(1) shl 4
  1104. XkbPCF_AllFlagsMask* = 0x0000001F #
  1105. # Debugging flags and controls
  1106. #
  1107. const
  1108. XkbDF_DisableLocks* = 1 shl 0
  1109. type
  1110. PXkbPropertyPtr* = ptr TXkbPropertyRec
  1111. TXkbPropertyRec*{.final.} = object
  1112. name*: cstring
  1113. value*: cstring
  1114. type
  1115. PXkbColorPtr* = ptr TXkbColorRec
  1116. TXkbColorRec*{.final.} = object
  1117. pixel*: int16
  1118. spec*: cstring
  1119. type
  1120. PXkbPointPtr* = ptr TXkbPointRec
  1121. TXkbPointRec*{.final.} = object
  1122. x*: int16
  1123. y*: int16
  1124. type
  1125. PXkbBoundsPtr* = ptr TXkbBoundsRec
  1126. TXkbBoundsRec*{.final.} = object
  1127. x1*: int16
  1128. y1*: int16
  1129. x2*: int16
  1130. y2*: int16
  1131. proc XkbBoundsWidth*(b: PXkbBoundsPtr): int16
  1132. proc XkbBoundsHeight*(b: PXkbBoundsPtr): int16
  1133. type
  1134. PXkbOutlinePtr* = ptr TXkbOutlineRec
  1135. TXkbOutlineRec*{.final.} = object
  1136. num_points*: int16
  1137. sz_points*: int16
  1138. corner_radius*: int16
  1139. points*: PXkbPointPtr
  1140. type
  1141. PXkbShapePtr* = ptr TXkbShapeRec
  1142. TXkbShapeRec*{.final.} = object
  1143. name*: TAtom
  1144. num_outlines*: int16
  1145. sz_outlines*: int16
  1146. outlines*: ptr array [0..0xffff, TXkbOutlineRec]
  1147. approx*: ptr array[0..0xffff, TXkbOutlineRec]
  1148. primary*: ptr array[0..0xffff, TXkbOutlineRec]
  1149. bounds*: TXkbBoundsRec
  1150. proc XkbOutlineIndex*(s: PXkbShapePtr, o: PXkbOutlinePtr): int32
  1151. type
  1152. PXkbShapeDoodadPtr* = ptr TXkbShapeDoodadRec
  1153. TXkbShapeDoodadRec*{.final.} = object
  1154. name*: TAtom
  1155. theType*: int8
  1156. priority*: int8
  1157. top*: int16
  1158. left*: int16
  1159. angle*: int16
  1160. color_ndx*: int16
  1161. shape_ndx*: int16
  1162. type
  1163. PXkbTextDoodadPtr* = ptr TXkbTextDoodadRec
  1164. TXkbTextDoodadRec*{.final.} = object
  1165. name*: TAtom
  1166. theType*: int8
  1167. priority*: int8
  1168. top*: int16
  1169. left*: int16
  1170. angle*: int16
  1171. width*: int16
  1172. height*: int16
  1173. color_ndx*: int16
  1174. text*: cstring
  1175. font*: cstring
  1176. type
  1177. PXkbIndicatorDoodadPtr* = ptr TXkbIndicatorDoodadRec
  1178. TXkbIndicatorDoodadRec*{.final.} = object
  1179. name*: TAtom
  1180. theType*: int8
  1181. priority*: int8
  1182. top*: int16
  1183. left*: int16
  1184. angle*: int16
  1185. shape_ndx*: int16
  1186. on_color_ndx*: int16
  1187. off_color_ndx*: int16
  1188. type
  1189. PXkbLogoDoodadPtr* = ptr TXkbLogoDoodadRec
  1190. TXkbLogoDoodadRec*{.final.} = object
  1191. name*: TAtom
  1192. theType*: int8
  1193. priority*: int8
  1194. top*: int16
  1195. left*: int16
  1196. angle*: int16
  1197. color_ndx*: int16
  1198. shape_ndx*: int16
  1199. logo_name*: cstring
  1200. type
  1201. PXkbAnyDoodadPtr* = ptr TXkbAnyDoodadRec
  1202. TXkbAnyDoodadRec*{.final.} = object
  1203. name*: TAtom
  1204. theType*: int8
  1205. priority*: int8
  1206. top*: int16
  1207. left*: int16
  1208. angle*: int16
  1209. type
  1210. PXkbDoodadPtr* = ptr TXkbDoodadRec
  1211. TXkbDoodadRec*{.final.} = object
  1212. any*: TXkbAnyDoodadRec
  1213. shape*: TXkbShapeDoodadRec
  1214. text*: TXkbTextDoodadRec
  1215. indicator*: TXkbIndicatorDoodadRec
  1216. logo*: TXkbLogoDoodadRec
  1217. const
  1218. XkbUnknownDoodad* = 0
  1219. XkbOutlineDoodad* = 1
  1220. XkbSolidDoodad* = 2
  1221. XkbTextDoodad* = 3
  1222. XkbIndicatorDoodad* = 4
  1223. XkbLogoDoodad* = 5
  1224. type
  1225. PXkbKeyPtr* = ptr TXkbKeyRec
  1226. TXkbKeyRec*{.final.} = object
  1227. name*: TXkbKeyNameRec
  1228. gap*: int16
  1229. shape_ndx*: int8
  1230. color_ndx*: int8
  1231. type
  1232. PXkbRowPtr* = ptr TXkbRowRec
  1233. TXkbRowRec*{.final.} = object
  1234. top*: int16
  1235. left*: int16
  1236. num_keys*: int16
  1237. sz_keys*: int16
  1238. vertical*: int16
  1239. Keys*: PXkbKeyPtr
  1240. bounds*: TXkbBoundsRec
  1241. type
  1242. PXkbOverlayPtr* = ptr TXkbOverlayRec #forward for TXkbSectionRec use.
  1243. #Do not add more "type"
  1244. PXkbSectionPtr* = ptr TXkbSectionRec
  1245. TXkbSectionRec*{.final.} = object #Do not add more "type"
  1246. name*: TAtom
  1247. priority*: int8
  1248. top*: int16
  1249. left*: int16
  1250. width*: int16
  1251. height*: int16
  1252. angle*: int16
  1253. num_rows*: int16
  1254. num_doodads*: int16
  1255. num_overlays*: int16
  1256. rows*: PXkbRowPtr
  1257. doodads*: PXkbDoodadPtr
  1258. bounds*: TXkbBoundsRec
  1259. overlays*: PXkbOverlayPtr
  1260. PXkbOverlayKeyPtr* = ptr TXkbOverlayKeyRec
  1261. TXkbOverlayKeyRec*{.final.} = object #Do not add more "type"
  1262. over*: TXkbKeyNameRec
  1263. under*: TXkbKeyNameRec
  1264. PXkbOverlayRowPtr* = ptr TXkbOverlayRowRec
  1265. TXkbOverlayRowRec*{.final.} = object #Do not add more "type"
  1266. row_under*: int16
  1267. num_keys*: int16
  1268. sz_keys*: int16
  1269. keys*: PXkbOverlayKeyPtr
  1270. TXkbOverlayRec*{.final.} = object
  1271. name*: TAtom
  1272. section_under*: PXkbSectionPtr
  1273. num_rows*: int16
  1274. sz_rows*: int16
  1275. rows*: PXkbOverlayRowPtr
  1276. bounds*: PXkbBoundsPtr
  1277. type
  1278. PXkbGeometryRec* = ptr TXkbGeometryRec
  1279. PXkbGeometryPtr* = PXkbGeometryRec
  1280. TXkbGeometryRec*{.final.} = object
  1281. name*: TAtom
  1282. width_mm*: int16
  1283. height_mm*: int16
  1284. label_font*: cstring
  1285. label_color*: PXkbColorPtr
  1286. base_color*: PXkbColorPtr
  1287. sz_properties*: int16
  1288. sz_colors*: int16
  1289. sz_shapes*: int16
  1290. sz_sections*: int16
  1291. sz_doodads*: int16
  1292. sz_key_aliases*: int16
  1293. num_properties*: int16
  1294. num_colors*: int16
  1295. num_shapes*: int16
  1296. num_sections*: int16
  1297. num_doodads*: int16
  1298. num_key_aliases*: int16
  1299. properties*: ptr array[0..0xffff, TXkbPropertyRec]
  1300. colors*: ptr array[0..0xffff, TXkbColorRec]
  1301. shapes*: ptr array[0..0xffff, TXkbShapeRec]
  1302. sections*: ptr array[0..0xffff, TXkbSectionRec]
  1303. key_aliases*: ptr array[0..0xffff, TXkbKeyAliasRec]
  1304. const
  1305. XkbGeomPropertiesMask* = 1 shl 0
  1306. XkbGeomColorsMask* = 1 shl 1
  1307. XkbGeomShapesMask* = 1 shl 2
  1308. XkbGeomSectionsMask* = 1 shl 3
  1309. XkbGeomDoodadsMask* = 1 shl 4
  1310. XkbGeomKeyAliasesMask* = 1 shl 5
  1311. XkbGeomAllMask* = 0x0000003F
  1312. type
  1313. PXkbGeometrySizesPtr* = ptr TXkbGeometrySizesRec
  1314. TXkbGeometrySizesRec*{.final.} = object #
  1315. # Tie it all together into one big keyboard description
  1316. #
  1317. which*: int16
  1318. num_properties*: int16
  1319. num_colors*: int16
  1320. num_shapes*: int16
  1321. num_sections*: int16
  1322. num_doodads*: int16
  1323. num_key_aliases*: int16
  1324. type
  1325. PXkbDescPtr* = ptr TXkbDescRec
  1326. TXkbDescRec*{.final.} = object
  1327. dpy*: PDisplay
  1328. flags*: int16
  1329. device_spec*: int16
  1330. min_key_code*: TKeyCode
  1331. max_key_code*: TKeyCode
  1332. ctrls*: PXkbControlsPtr
  1333. server*: PXkbServerMapPtr
  1334. map*: PXkbClientMapPtr
  1335. indicators*: PXkbIndicatorPtr
  1336. names*: PXkbNamesPtr
  1337. compat*: PXkbCompatMapPtr
  1338. geom*: PXkbGeometryPtr
  1339. proc XkbKeyKeyTypeIndex*(d: PXkbDescPtr, k: int16, g: int8): int8
  1340. proc XkbKeyKeyType*(d: PXkbDescPtr, k: int16, g: int8): PXkbKeyTypePtr
  1341. proc XkbKeyGroupWidth*(d: PXkbDescPtr, k: int16, g: int8): int8
  1342. proc XkbKeyGroupsWidth*(d: PXkbDescPtr, k: int16): int8
  1343. proc XkbKeyGroupInfo*(d: PXkbDescPtr, k: int16): int8
  1344. proc XkbKeyNumGroups*(d: PXkbDescPtr, k: int16): int8
  1345. proc XkbKeyNumSyms*(d: PXkbDescPtr, k: int16): int16
  1346. proc XkbKeySym*(d: PXkbDescPtr, k: int16, n: int16): TKeySym
  1347. proc XkbKeySymEntry*(d: PXkbDescPtr, k: int16, sl: int16, g: int8): TKeySym
  1348. proc XkbKeyAction*(d: PXkbDescPtr, k: int16, n: int16): PXkbAction
  1349. proc XkbKeyActionEntry*(d: PXkbDescPtr, k: int16, sl: int16, g: int8): int8
  1350. proc XkbKeyHasActions*(d: PXkbDescPtr, k: int16): bool
  1351. proc XkbKeyNumActions*(d: PXkbDescPtr, k: int16): int16
  1352. proc XkbKeyActionsPtr*(d: PXkbDescPtr, k: int16): PXkbAction
  1353. proc XkbKeycodeInRange*(d: PXkbDescPtr, k: int16): bool
  1354. proc XkbNumKeys*(d: PXkbDescPtr): int8
  1355. #
  1356. # The following structures can be used to track changes
  1357. # to a keyboard device
  1358. #
  1359. type
  1360. PXkbMapChangesPtr* = ptr TXkbMapChangesRec
  1361. TXkbMapChangesRec*{.final.} = object
  1362. changed*: int16
  1363. min_key_code*: TKeyCode
  1364. max_key_code*: TKeyCode
  1365. first_type*: int8
  1366. num_types*: int8
  1367. first_key_sym*: TKeyCode
  1368. num_key_syms*: int8
  1369. first_key_act*: TKeyCode
  1370. num_key_acts*: int8
  1371. first_key_behavior*: TKeyCode
  1372. num_key_behaviors*: int8
  1373. first_key_explicit*: TKeyCode
  1374. num_key_explicit*: int8
  1375. first_modmap_key*: TKeyCode
  1376. num_modmap_keys*: int8
  1377. first_vmodmap_key*: TKeyCode
  1378. num_vmodmap_keys*: int8
  1379. pad*: int8
  1380. vmods*: int16
  1381. type
  1382. PXkbControlsChangesPtr* = ptr TXkbControlsChangesRec
  1383. TXkbControlsChangesRec*{.final.} = object
  1384. changed_ctrls*: int16
  1385. enabled_ctrls_changes*: int16
  1386. num_groups_changed*: bool
  1387. type
  1388. PXkbIndicatorChangesPtr* = ptr TXkbIndicatorChangesRec
  1389. TXkbIndicatorChangesRec*{.final.} = object
  1390. state_changes*: int16
  1391. map_changes*: int16
  1392. type
  1393. PXkbNameChangesPtr* = ptr TXkbNameChangesRec
  1394. TXkbNameChangesRec*{.final.} = object
  1395. changed*: int16
  1396. first_type*: int8
  1397. num_types*: int8
  1398. first_lvl*: int8
  1399. num_lvls*: int8
  1400. num_aliases*: int8
  1401. num_rg*: int8
  1402. first_key*: int8
  1403. num_keys*: int8
  1404. changed_vmods*: int16
  1405. changed_indicators*: int32
  1406. changed_groups*: int8
  1407. type
  1408. PXkbCompatChangesPtr* = ptr TXkbCompatChangesRec
  1409. TXkbCompatChangesRec*{.final.} = object
  1410. changed_groups*: int8
  1411. first_si*: int16
  1412. num_si*: int16
  1413. type
  1414. PXkbChangesPtr* = ptr TXkbChangesRec
  1415. TXkbChangesRec*{.final.} = object #
  1416. # These data structures are used to construct a keymap from
  1417. # a set of components or to list components in the server
  1418. # database.
  1419. #
  1420. device_spec*: int16
  1421. state_changes*: int16
  1422. map*: TXkbMapChangesRec
  1423. ctrls*: TXkbControlsChangesRec
  1424. indicators*: TXkbIndicatorChangesRec
  1425. names*: TXkbNameChangesRec
  1426. compat*: TXkbCompatChangesRec
  1427. type
  1428. PXkbComponentNamesPtr* = ptr TXkbComponentNamesRec
  1429. TXkbComponentNamesRec*{.final.} = object
  1430. keymap*: ptr int16
  1431. keycodes*: ptr int16
  1432. types*: ptr int16
  1433. compat*: ptr int16
  1434. symbols*: ptr int16
  1435. geometry*: ptr int16
  1436. type
  1437. PXkbComponentNamePtr* = ptr TXkbComponentNameRec
  1438. TXkbComponentNameRec*{.final.} = object
  1439. flags*: int16
  1440. name*: cstring
  1441. type
  1442. PXkbComponentListPtr* = ptr TXkbComponentListRec
  1443. TXkbComponentListRec*{.final.} = object #
  1444. # The following data structures describe and track changes to a
  1445. # non-keyboard extension device
  1446. #
  1447. num_keymaps*: int16
  1448. num_keycodes*: int16
  1449. num_types*: int16
  1450. num_compat*: int16
  1451. num_symbols*: int16
  1452. num_geometry*: int16
  1453. keymaps*: PXkbComponentNamePtr
  1454. keycodes*: PXkbComponentNamePtr
  1455. types*: PXkbComponentNamePtr
  1456. compat*: PXkbComponentNamePtr
  1457. symbols*: PXkbComponentNamePtr
  1458. geometry*: PXkbComponentNamePtr
  1459. type
  1460. PXkbDeviceLedInfoPtr* = ptr TXkbDeviceLedInfoRec
  1461. TXkbDeviceLedInfoRec*{.final.} = object
  1462. led_class*: int16
  1463. led_id*: int16
  1464. phys_indicators*: int16
  1465. maps_present*: int16
  1466. names_present*: int16
  1467. state*: int16
  1468. names*: array[0..XkbNumIndicators - 1, TAtom]
  1469. maps*: array[0..XkbNumIndicators - 1, TXkbIndicatorMapRec]
  1470. type
  1471. PXkbDeviceInfoPtr* = ptr TXkbDeviceInfoRec
  1472. TXkbDeviceInfoRec*{.final.} = object
  1473. name*: cstring
  1474. theType*: TAtom
  1475. device_spec*: int16
  1476. has_own_state*: bool
  1477. supported*: int16
  1478. unsupported*: int16
  1479. num_btns*: int16
  1480. btn_acts*: PXkbAction
  1481. sz_leds*: int16
  1482. num_leds*: int16
  1483. dflt_kbd_fb*: int16
  1484. dflt_led_fb*: int16
  1485. leds*: PXkbDeviceLedInfoPtr
  1486. proc XkbXI_DevHasBtnActs*(d: PXkbDeviceInfoPtr): bool
  1487. proc XkbXI_LegalDevBtn*(d: PXkbDeviceInfoPtr, b: int16): bool
  1488. proc XkbXI_DevHasLeds*(d: PXkbDeviceInfoPtr): bool
  1489. type
  1490. PXkbDeviceLedChangesPtr* = ptr TXkbDeviceLedChangesRec
  1491. TXkbDeviceLedChangesRec*{.final.} = object
  1492. led_class*: int16
  1493. led_id*: int16
  1494. defined*: int16 #names or maps changed
  1495. next*: PXkbDeviceLedChangesPtr
  1496. type
  1497. PXkbDeviceChangesPtr* = ptr TXkbDeviceChangesRec
  1498. TXkbDeviceChangesRec*{.final.} = object
  1499. changed*: int16
  1500. first_btn*: int16
  1501. num_btns*: int16
  1502. leds*: TXkbDeviceLedChangesRec
  1503. proc XkbShapeDoodadColor*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbColorPtr
  1504. proc XkbShapeDoodadShape*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbShapePtr
  1505. proc XkbSetShapeDoodadColor*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr,
  1506. c: PXkbColorPtr)
  1507. proc XkbSetShapeDoodadShape*(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr,
  1508. s: PXkbShapePtr)
  1509. proc XkbTextDoodadColor*(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr): PXkbColorPtr
  1510. proc XkbSetTextDoodadColor*(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr,
  1511. c: PXkbColorPtr)
  1512. proc XkbIndicatorDoodadShape*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbShapeDoodadPtr
  1513. proc XkbIndicatorDoodadOnColor*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr
  1514. proc XkbIndicatorDoodadOffColor*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr
  1515. proc XkbSetIndicatorDoodadOnColor*(g: PXkbGeometryPtr,
  1516. d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr)
  1517. proc XkbSetIndicatorDoodadOffColor*(g: PXkbGeometryPtr,
  1518. d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr)
  1519. proc XkbSetIndicatorDoodadShape*(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr,
  1520. s: PXkbShapeDoodadPtr)
  1521. proc XkbLogoDoodadColor*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbColorPtr
  1522. proc XkbLogoDoodadShape*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbShapeDoodadPtr
  1523. proc XkbSetLogoDoodadColor*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr,
  1524. c: PXkbColorPtr)
  1525. proc XkbSetLogoDoodadShape*(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr,
  1526. s: PXkbShapeDoodadPtr)
  1527. proc XkbKeyShape*(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbShapeDoodadPtr
  1528. proc XkbKeyColor*(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbColorPtr
  1529. proc XkbSetKeyShape*(g: PXkbGeometryPtr, k: PXkbKeyPtr, s: PXkbShapeDoodadPtr)
  1530. proc XkbSetKeyColor*(g: PXkbGeometryPtr, k: PXkbKeyPtr, c: PXkbColorPtr)
  1531. proc XkbGeomColorIndex*(g: PXkbGeometryPtr, c: PXkbColorPtr): int32
  1532. proc XkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring, value: cstring): PXkbPropertyPtr{.
  1533. libx11c, importc: "XkbAddGeomProperty".}
  1534. proc XkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{.
  1535. libx11c, importc: "XkbAddGeomKeyAlias".}
  1536. proc XkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{.
  1537. libx11c, importc: "XkbAddGeomColor".}
  1538. proc XkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{.
  1539. libx11c, importc: "XkbAddGeomOutline".}
  1540. proc XkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom, sz_outlines: int16): PXkbShapePtr{.
  1541. libx11c, importc: "XkbAddGeomShape".}
  1542. proc XkbAddGeomKey*(row: PXkbRowPtr): PXkbKeyPtr{.libx11c,
  1543. importc: "XkbAddGeomKey".}
  1544. proc XkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.libx11c, importc: "XkbAddGeomRow".}
  1545. proc XkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16,
  1546. sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{.
  1547. libx11c, importc: "XkbAddGeomSection".}
  1548. proc XkbAddGeomOverlay*(section: PXkbSectionPtr, name: TAtom, sz_rows: int16): PXkbOverlayPtr{.
  1549. libx11c, importc: "XkbAddGeomOverlay".}
  1550. proc XkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16,
  1551. sz_keys: int16): PXkbOverlayRowPtr{.libx11c, importc: "XkbAddGeomOverlayRow".}
  1552. proc XkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr,
  1553. over: cstring, under: cstring): PXkbOverlayKeyPtr{.
  1554. libx11c, importc: "XkbAddGeomOverlayKey".}
  1555. proc XkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr,
  1556. name: TAtom): PXkbDoodadPtr{.libx11c,
  1557. importc: "XkbAddGeomDoodad".}
  1558. proc XkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16, count: int16,
  1559. freeAll: bool){.libx11c,
  1560. importc: "XkbFreeGeomKeyAliases".}
  1561. proc XkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16,
  1562. freeAll: bool){.libx11c,
  1563. importc: "XkbFreeGeomColors".}
  1564. proc XkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16, freeAll: bool){.
  1565. libx11c, importc: "XkbFreeGeomDoodads".}
  1566. proc XkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16, count: int16,
  1567. freeAll: bool){.libx11c,
  1568. importc: "XkbFreeGeomProperties".}
  1569. proc XkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16, count: int16,
  1570. freeAll: bool){.libx11c,
  1571. importc: "XkbFreeGeomOverlayKeys".}
  1572. proc XkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16,
  1573. count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomOverlayRows".}
  1574. proc XkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16, count: int16,
  1575. freeAll: bool){.libx11c,
  1576. importc: "XkbFreeGeomOverlays".}
  1577. proc XkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16, freeAll: bool){.
  1578. libx11c, importc: "XkbFreeGeomKeys".}
  1579. proc XkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16,
  1580. freeAll: bool){.libx11c,
  1581. importc: "XkbFreeGeomRows".}
  1582. proc XkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16, count: int16,
  1583. freeAll: bool){.libx11c,
  1584. importc: "XkbFreeGeomSections".}
  1585. proc XkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16, count: int16,
  1586. freeAll: bool){.libx11c,
  1587. importc: "XkbFreeGeomPoints".}
  1588. proc XkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16,
  1589. freeAll: bool){.libx11c,
  1590. importc: "XkbFreeGeomOutlines".}
  1591. proc XkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16,
  1592. freeAll: bool){.libx11c,
  1593. importc: "XkbFreeGeomShapes".}
  1594. proc XkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){.
  1595. libx11c, importc: "XkbFreeGeometry".}
  1596. proc XkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.libx11c, importc: "XkbAllocGeomProps".}
  1597. proc XkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{.
  1598. libx11c, importc: "XkbAllocGeomKeyAliases".}
  1599. proc XkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.libx11c, importc: "XkbAllocGeomColors".}
  1600. proc XkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.libx11c, importc: "XkbAllocGeomShapes".}
  1601. proc XkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{.
  1602. libx11c, importc: "XkbAllocGeomSections".}
  1603. proc XkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{.
  1604. libx11c, importc: "XkbAllocGeomOverlays".}
  1605. proc XkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{.
  1606. libx11c, importc: "XkbAllocGeomOverlayRows".}
  1607. proc XkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{.
  1608. libx11c, importc: "XkbAllocGeomOverlayKeys".}
  1609. proc XkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{.
  1610. libx11c, importc: "XkbAllocGeomDoodads".}
  1611. proc XkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{.
  1612. libx11c, importc: "XkbAllocGeomSectionDoodads".}
  1613. proc XkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.libx11c, importc: "XkbAllocGeomOutlines".}
  1614. proc XkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.libx11c, importc: "XkbAllocGeomRows".}
  1615. proc XkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.libx11c, importc: "XkbAllocGeomPoints".}
  1616. proc XkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.libx11c, importc: "XkbAllocGeomKeys".}
  1617. proc XkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{.
  1618. libx11c, importc: "XkbAllocGeometry".}
  1619. proc XkbSetGeometryProc*(dpy: PDisplay, deviceSpec: int16, geom: PXkbGeometryPtr): TStatus{.
  1620. libx11c, importc: "XkbSetGeometry".}
  1621. proc XkbComputeShapeTop*(shape: PXkbShapePtr, bounds: PXkbBoundsPtr): bool{.
  1622. libx11c, importc: "XkbComputeShapeTop".}
  1623. proc XkbComputeShapeBounds*(shape: PXkbShapePtr): bool{.libx11c,
  1624. importc: "XkbComputeShapeBounds".}
  1625. proc XkbComputeRowBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr,
  1626. row: PXkbRowPtr): bool{.libx11c,
  1627. importc: "XkbComputeRowBounds".}
  1628. proc XkbComputeSectionBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr): bool{.
  1629. libx11c, importc: "XkbComputeSectionBounds".}
  1630. proc XkbFindOverlayForKey*(geom: PXkbGeometryPtr, wanted: PXkbSectionPtr,
  1631. under: cstring): cstring{.libx11c,
  1632. importc: "XkbFindOverlayForKey".}
  1633. proc XkbGetGeometryProc*(dpy: PDisplay, xkb: PXkbDescPtr): TStatus{.libx11c, importc: "XkbGetGeometry".}
  1634. proc XkbGetNamedGeometry*(dpy: PDisplay, xkb: PXkbDescPtr, name: TAtom): TStatus{.
  1635. libx11c, importc: "XkbGetNamedGeometry".}
  1636. when defined(XKB_IN_SERVER):
  1637. proc SrvXkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring,
  1638. float: cstring): PXkbKeyAliasPtr{.libx11c, importc: "XkbAddGeomKeyAlias".}
  1639. proc SrvXkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{.
  1640. libx11c, importc: "XkbAddGeomColor".}
  1641. proc SrvXkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr,
  1642. name: TAtom): PXkbDoodadPtr{.libx11c,
  1643. importc: "XkbAddGeomDoodad".}
  1644. proc SrvXkbAddGeomKey*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{.
  1645. libx11c, importc: "XkbAddGeomKeyAlias".}
  1646. proc SrvXkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{.
  1647. libx11c, importc: "XkbAddGeomOutline".}
  1648. proc SrvXkbAddGeomOverlay*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr,
  1649. over: cstring, under: cstring): PXkbOverlayKeyPtr{.
  1650. libx11c, importc: "XkbAddGeomOverlayKey".}
  1651. proc SrvXkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16,
  1652. sz_keys: int16): PXkbOverlayRowPtr{.libx11c, importc: "XkbAddGeomOverlayRow".}
  1653. proc SrvXkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr,
  1654. over: cstring, under: cstring): PXkbOverlayKeyPtr{.
  1655. libx11c, importc: "XkbAddGeomOverlayKey".}
  1656. proc SrvXkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring,
  1657. value: cstring): PXkbPropertyPtr{.libx11c, importc: "XkbAddGeomProperty".}
  1658. proc SrvXkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.
  1659. libx11c, importc: "XkbAddGeomRow".}
  1660. proc SrvXkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16,
  1661. sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{.
  1662. libx11c, importc: "XkbAddGeomSection".}
  1663. proc SrvXkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom,
  1664. sz_outlines: int16): PXkbShapePtr{.libx11c, importc: "XkbAddGeomShape".}
  1665. proc SrvXkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{.
  1666. libx11c, importc: "XkbAllocGeomKeyAliases".}
  1667. proc SrvXkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.
  1668. libx11c, importc: "XkbAllocGeomColors".}
  1669. proc SrvXkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{.
  1670. libx11c, importc: "XkbAllocGeomDoodads".}
  1671. proc SrvXkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.libx11c, importc: "XkbAllocGeomKeys".}
  1672. proc SrvXkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.
  1673. libx11c, importc: "XkbAllocGeomOutlines".}
  1674. proc SrvXkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.libx11c, importc: "XkbAllocGeomPoints".}
  1675. proc SrvXkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.
  1676. libx11c, importc: "XkbAllocGeomProps".}
  1677. proc SrvXkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.
  1678. libx11c, importc: "XkbAllocGeomRows".}
  1679. proc SrvXkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{.
  1680. libx11c, importc: "XkbAllocGeomSectionDoodads".}
  1681. proc SrvXkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{.
  1682. libx11c, importc: "XkbAllocGeomSections".}
  1683. proc SrvXkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{.
  1684. libx11c, importc: "XkbAllocGeomOverlays".}
  1685. proc SrvXkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{.
  1686. libx11c, importc: "XkbAllocGeomOverlayRows".}
  1687. proc SrvXkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{.
  1688. libx11c, importc: "XkbAllocGeomOverlayKeys".}
  1689. proc SrvXkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.
  1690. libx11c, importc: "XkbAllocGeomShapes".}
  1691. proc SrvXkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{.
  1692. libx11c, importc: "XkbAllocGeometry".}
  1693. proc SrvXkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16,
  1694. count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomKeyAliases".}
  1695. proc SrvXkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16,
  1696. freeAll: bool){.libx11c,
  1697. importc: "XkbFreeGeomColors".}
  1698. proc SrvXkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16,
  1699. freeAll: bool){.libx11c,
  1700. importc: "XkbFreeGeomDoodads".}
  1701. proc SrvXkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16,
  1702. count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomProperties".}
  1703. proc SrvXkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16,
  1704. count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomOverlayKeys".}
  1705. proc SrvXkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16,
  1706. count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomOverlayRows".}
  1707. proc SrvXkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16,
  1708. count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomOverlays".}
  1709. proc SrvXkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16,
  1710. freeAll: bool){.libx11c,
  1711. importc: "XkbFreeGeomKeys".}
  1712. proc SrvXkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16,
  1713. freeAll: bool){.libx11c,
  1714. importc: "XkbFreeGeomRows".}
  1715. proc SrvXkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16,
  1716. count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomSections".}
  1717. proc SrvXkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16,
  1718. count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomPoints".}
  1719. proc SrvXkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16,
  1720. freeAll: bool){.libx11c,
  1721. importc: "XkbFreeGeomOutlines".}
  1722. proc SrvXkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16,
  1723. freeAll: bool){.libx11c,
  1724. importc: "XkbFreeGeomShapes".}
  1725. proc SrvXkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){.
  1726. libx11c, importc: "XkbFreeGeometry".}
  1727. # implementation
  1728. import #************************************ xkb ************************************
  1729. xi
  1730. proc XkbLegalXILedClass(c: int): bool =
  1731. ##define XkbLegalXILedClass(c) (((c)==KbdFeedbackClass)||((c)==LedFeedbackClass)||
  1732. # ((c)==XkbDfltXIClass)||((c)==XkbAllXIClasses))
  1733. result = (c == KbdFeedbackClass) or (c == LedFeedbackClass) or
  1734. (c == XkbDfltXIClass) or (c == XkbAllXIClasses)
  1735. proc XkbLegalXIBellClass(c: int): bool =
  1736. ##define XkbLegalXIBellClass(c) (((c)==KbdFeedbackClass)||((c)==BellFeedbackClass)||
  1737. # ((c)==XkbDfltXIClass)||((c)==XkbAllXIClasses))
  1738. result = (c == KbdFeedbackClass) or (c == BellFeedbackClass) or
  1739. (c == XkbDfltXIClass) or (c == XkbAllXIClasses)
  1740. proc XkbExplicitXIDevice(c: int): bool =
  1741. ##define XkbExplicitXIDevice(c) (((c)&(~0xff))==0)
  1742. result = (c and (not 0x000000FF)) == 0
  1743. proc XkbExplicitXIClass(c: int): bool =
  1744. ##define XkbExplicitXIClass(c) (((c)&(~0xff))==0)
  1745. result = (c and (not 0x000000FF)) == 0
  1746. proc XkbExplicitXIId(c: int): bool =
  1747. ##define XkbExplicitXIId(c) (((c)&(~0xff))==0)
  1748. result = (c and (not 0x000000FF)) == 0
  1749. proc XkbSingleXIClass(c: int): bool =
  1750. ##define XkbSingleXIClass(c) ((((c)&(~0xff))==0)||((c)==XkbDfltXIClass))
  1751. result = ((c and (not 0x000000FF)) == 0) or (c == XkbDfltXIClass)
  1752. proc XkbSingleXIId(c: int): bool =
  1753. ##define XkbSingleXIId(c) ((((c)&(~0xff))==0)||((c)==XkbDfltXIId))
  1754. result = ((c and (not 0x000000FF)) == 0) or (c == XkbDfltXIId)
  1755. proc XkbBuildCoreState(m, g: int): int =
  1756. ##define XkbBuildCoreState(m,g) ((((g)&0x3)<<13)|((m)&0xff))
  1757. result = ((g and 0x00000003) shl 13) or (m and 0x000000FF)
  1758. proc XkbGroupForCoreState(s: int): int =
  1759. ##define XkbGroupForCoreState(s) (((s)>>13)&0x3)
  1760. result = (s shr 13) and 0x00000003
  1761. proc XkbIsLegalGroup(g: int): bool =
  1762. ##define XkbIsLegalGroup(g) (((g)>=0)&&((g)<XkbNumKbdGroups))
  1763. result = (g >= 0) and (g < XkbNumKbdGroups)
  1764. proc XkbSA_ValOp(a: int): int =
  1765. ##define XkbSA_ValOp(a) ((a)&XkbSA_ValOpMask)
  1766. result = a and XkbSA_ValOpMask
  1767. proc XkbSA_ValScale(a: int): int =
  1768. ##define XkbSA_ValScale(a) ((a)&XkbSA_ValScaleMask)
  1769. result = a and XkbSA_ValScaleMask
  1770. proc XkbIsModAction(a: PXkbAnyAction): bool =
  1771. ##define XkbIsModAction(a) (((a)->type>=Xkb_SASetMods)&&((a)->type<=XkbSA_LockMods))
  1772. result = (ze(a.theType) >= XkbSA_SetMods) and (ze(a.theType) <= XkbSA_LockMods)
  1773. proc XkbIsGroupAction(a: PXkbAnyAction): bool =
  1774. ##define XkbIsGroupAction(a) (((a)->type>=XkbSA_SetGroup)&&((a)->type<=XkbSA_LockGroup))
  1775. result = (ze(a.theType) >= XkbSA_SetGroup) or (ze(a.theType) <= XkbSA_LockGroup)
  1776. proc XkbIsPtrAction(a: PXkbAnyAction): bool =
  1777. ##define XkbIsPtrAction(a) (((a)->type>=XkbSA_MovePtr)&&((a)->type<=XkbSA_SetPtrDflt))
  1778. result = (ze(a.theType) >= XkbSA_MovePtr) and
  1779. (ze(a.theType) <= XkbSA_SetPtrDflt)
  1780. proc XkbIsLegalKeycode(k: int): bool =
  1781. ##define XkbIsLegalKeycode(k) (((k)>=XkbMinLegalKeyCode)&&((k)<=XkbMaxLegalKeyCode))
  1782. result = (k >= XkbMinLegalKeyCode) and (k <= XkbMaxLegalKeyCode)
  1783. proc XkbShiftLevel(n: int8): int8 =
  1784. ##define XkbShiftLevel(n) ((n)-1)
  1785. result = n - 1'i8
  1786. proc XkbShiftLevelMask(n: int8): int8 =
  1787. ##define XkbShiftLevelMask(n) (1<<((n)-1))
  1788. result = 1'i8 shl (n - 1'i8)
  1789. proc XkbcharToInt(v: int8): int16 =
  1790. ##define XkbcharToInt(v) ((v)&0x80?(int)((v)|(~0xff)):(int)((v)&0x7f))
  1791. if ((v and 0x80'i8) != 0'i8): result = v or (not 0xFF'i16)
  1792. else: result = int16(v and 0x7F'i8)
  1793. proc XkbIntTo2chars(i: int16, h, L: var int8) =
  1794. ##define XkbIntTo2chars(i,h,l) (((h)=((i>>8)&0xff)),((l)=((i)&0xff)))
  1795. h = toU8((i shr 8'i16) and 0x00FF'i16)
  1796. L = toU8(i and 0xFF'i16)
  1797. proc Xkb2charsToInt(h, L: int8): int16 =
  1798. when defined(cpu64):
  1799. ##define Xkb2charsToInt(h,l) ((h)&0x80?(int)(((h)<<8)|(l)|(~0xffff)): (int)(((h)<<8)|(l)&0x7fff))
  1800. if (h and 0x80'i8) != 0'i8:
  1801. result = toU16((ze(h) shl 8) or ze(L) or not 0x0000FFFF)
  1802. else:
  1803. result = toU16((ze(h) shl 8) or ze(L) and 0x00007FFF)
  1804. else:
  1805. ##define Xkb2charsToInt(h,l) ((short)(((h)<<8)|(l)))
  1806. result = toU16(ze(h) shl 8 or ze(L))
  1807. proc XkbModLocks(s: PXkbStatePtr): int8 =
  1808. ##define XkbModLocks(s) ((s)->locked_mods)
  1809. result = s.locked_mods
  1810. proc XkbStateMods(s: PXkbStatePtr): int16 =
  1811. ##define XkbStateMods(s) ((s)->base_mods|(s)->latched_mods|XkbModLocks(s))
  1812. result = s.base_mods or s.latched_mods or XkbModLocks(s)
  1813. proc XkbGroupLock(s: PXkbStatePtr): int8 =
  1814. ##define XkbGroupLock(s) ((s)->locked_group)
  1815. result = s.locked_group
  1816. proc XkbStateGroup(s: PXkbStatePtr): int16 =
  1817. ##define XkbStateGroup(s) ((s)->base_group+(s)->latched_group+XkbGroupLock(s))
  1818. result = s.base_group + (s.latched_group) + XkbGroupLock(s)
  1819. proc XkbStateFieldFromRec(s: PXkbStatePtr): int =
  1820. ##define XkbStateFieldFromRec(s) XkbBuildCoreState((s)->lookup_mods,(s)->group)
  1821. result = XkbBuildCoreState(s.lookup_mods, s.group)
  1822. proc XkbGrabStateFromRec(s: PXkbStatePtr): int =
  1823. ##define XkbGrabStateFromRec(s) XkbBuildCoreState((s)->grab_mods,(s)->group)
  1824. result = XkbBuildCoreState(s.grab_mods, s.group)
  1825. proc XkbNumGroups(g: int16): int16 =
  1826. ##define XkbNumGroups(g) ((g)&0x0f)
  1827. result = g and 0x0000000F'i16
  1828. proc XkbOutOfRangeGroupInfo(g: int16): int16 =
  1829. ##define XkbOutOfRangeGroupInfo(g) ((g)&0xf0)
  1830. result = g and 0x000000F0'i16
  1831. proc XkbOutOfRangeGroupAction(g: int16): int16 =
  1832. ##define XkbOutOfRangeGroupAction(g) ((g)&0xc0)
  1833. result = g and 0x000000C0'i16
  1834. proc XkbOutOfRangeGroupNumber(g: int16): int16 =
  1835. ##define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4)
  1836. result = (g and 0x00000030'i16) shr 4'i16
  1837. proc XkbSetGroupInfo(g, w, n: int16): int16 =
  1838. ##define XkbSetGroupInfo(g,w,n) (((w)&0xc0)|(((n)&3)<<4)|((g)&0x0f))
  1839. result = (w and 0x000000C0'i16) or
  1840. ((n and 3'i16) shl 4'i16) or (g and 0x0000000F'i16)
  1841. proc XkbSetNumGroups(g, n: int16): int16 =
  1842. ##define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f))
  1843. result = (g and 0x000000F0'i16) or (n and 0x0000000F'i16)
  1844. proc XkbModActionVMods(a: PXkbModAction): int16 =
  1845. ##define XkbModActionVMods(a) ((short)(((a)->vmods1<<8)|((a)->vmods2)))
  1846. result = toU16((ze(a.vmods1) shl 8) or ze(a.vmods2))
  1847. proc XkbSetModActionVMods(a: PXkbModAction, v: int8) =
  1848. ##define XkbSetModActionVMods(a,v) (((a)->vmods1=(((v)>>8)&0xff)),(a)->vmods2=((v)&0xff))
  1849. a.vmods1 = toU8((ze(v) shr 8) and 0x000000FF)
  1850. a.vmods2 = toU8(ze(v) and 0x000000FF)
  1851. proc XkbSAGroup(a: PXkbGroupAction): int8 =
  1852. ##define XkbSAGroup(a) (XkbcharToInt((a)->group_XXX))
  1853. result = int8(XkbcharToInt(a.group_XXX))
  1854. proc XkbSASetGroupProc(a: PXkbGroupAction, g: int8) =
  1855. ##define XkbSASetGroup(a,g) ((a)->group_XXX=(g))
  1856. a.group_XXX = g
  1857. proc XkbPtrActionX(a: PXkbPtrAction): int16 =
  1858. ##define XkbPtrActionX(a) (Xkb2charsToInt((a)->high_XXX,(a)->low_XXX))
  1859. result = int16(Xkb2charsToInt(a.high_XXX, a.low_XXX))
  1860. proc XkbPtrActionY(a: PXkbPtrAction): int16 =
  1861. ##define XkbPtrActionY(a) (Xkb2charsToInt((a)->high_YYY,(a)->low_YYY))
  1862. result = int16(Xkb2charsToInt(a.high_YYY, a.low_YYY))
  1863. proc XkbSetPtrActionX(a: PXkbPtrAction, x: int8) =
  1864. ##define XkbSetPtrActionX(a,x) (XkbIntTo2chars(x,(a)->high_XXX,(a)->low_XXX))
  1865. XkbIntTo2chars(x, a.high_XXX, a.low_XXX)
  1866. proc XkbSetPtrActionY(a: PXkbPtrAction, y: int8) =
  1867. ##define XkbSetPtrActionY(a,y) (XkbIntTo2chars(y,(a)->high_YYY,(a)->low_YYY))
  1868. XkbIntTo2chars(y, a.high_YYY, a.low_YYY)
  1869. proc XkbSAPtrDfltValue(a: PXkbPtrDfltAction): int8 =
  1870. ##define XkbSAPtrDfltValue(a) (XkbcharToInt((a)->valueXXX))
  1871. result = int8(XkbcharToInt(a.valueXXX))
  1872. proc XkbSASetPtrDfltValue(a: PXkbPtrDfltAction, c: pointer) =
  1873. ##define XkbSASetPtrDfltValue(a,c) ((a)->valueXXX= ((c)&0xff))
  1874. a.valueXXX = toU8(cast[int](c))
  1875. proc XkbSAScreen(a: PXkbSwitchScreenAction): int8 =
  1876. ##define XkbSAScreen(a) (XkbcharToInt((a)->screenXXX))
  1877. result = toU8(XkbcharToInt(a.screenXXX))
  1878. proc XkbSASetScreen(a: PXkbSwitchScreenAction, s: pointer) =
  1879. ##define XkbSASetScreen(a,s) ((a)->screenXXX= ((s)&0xff))
  1880. a.screenXXX = toU8(cast[int](s))
  1881. proc XkbActionSetCtrls(a: PXkbCtrlsAction, c: int8) =
  1882. ##define XkbActionSetCtrls(a,c) (((a)->ctrls3=(((c)>>24)&0xff)),((a)->ctrls2=(((c)>>16)&0xff)),
  1883. # ((a)->ctrls1=(((c)>>8)&0xff)),((a)->ctrls0=((c)&0xff)))
  1884. a.ctrls3 = toU8((ze(c) shr 24) and 0x000000FF)
  1885. a.ctrls2 = toU8((ze(c) shr 16) and 0x000000FF)
  1886. a.ctrls1 = toU8((ze(c) shr 8) and 0x000000FF)
  1887. a.ctrls0 = toU8(ze(c) and 0x000000FF)
  1888. proc XkbActionCtrls(a: PXkbCtrlsAction): int16 =
  1889. ##define XkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|(((unsigned int)(a)->ctrls2)<<16)|
  1890. # (((unsigned int)(a)->ctrls1)<<8)|((unsigned int)((a)->ctrls0)))
  1891. result = toU16((ze(a.ctrls3) shl 24) or (ze(a.ctrls2) shl 16) or
  1892. (ze(a.ctrls1) shl 8) or ze(a.ctrls0))
  1893. proc XkbSARedirectVMods(a: PXkbRedirectKeyAction): int16 =
  1894. ##define XkbSARedirectVMods(a) ((((unsigned int)(a)->vmods1)<<8)|((unsigned int)(a)->vmods0))
  1895. result = toU16((ze(a.vmods1) shl 8) or ze(a.vmods0))
  1896. proc XkbSARedirectSetVMods(a: PXkbRedirectKeyAction, m: int8) =
  1897. ##define XkbSARedirectSetVMods(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),((a)->vmods_mask0=((m)&0xff)))
  1898. a.vmods_mask1 = toU8((ze(m) shr 8) and 0x000000FF)
  1899. a.vmods_mask0 = toU8(ze(m) or 0x000000FF)
  1900. proc XkbSARedirectVModsMask(a: PXkbRedirectKeyAction): int16 =
  1901. ##define XkbSARedirectVModsMask(a) ((((unsigned int)(a)->vmods_mask1)<<8)|
  1902. # ((unsigned int)(a)->vmods_mask0))
  1903. result = toU16((ze(a.vmods_mask1) shl 8) or ze(a.vmods_mask0))
  1904. proc XkbSARedirectSetVModsMask(a: PXkbRedirectKeyAction, m: int8) =
  1905. ##define XkbSARedirectSetVModsMask(a,m) (((a)->vmods_mask1=(((m)>>8)&0xff)),((a)->vmods_mask0=((m)&0xff)))
  1906. a.vmods_mask1 = toU8(ze(m) shr 8 and 0x000000FF)
  1907. a.vmods_mask0 = toU8(ze(m) and 0x000000FF)
  1908. proc XkbAX_AnyFeedback(c: PXkbControlsPtr): int16 =
  1909. ##define XkbAX_AnyFeedback(c) ((c)->enabled_ctrls&XkbAccessXFeedbackMask)
  1910. result = toU16(ze(c.enabled_ctrls) and XkbAccessXFeedbackMask)
  1911. proc XkbAX_NeedOption(c: PXkbControlsPtr, w: int16): int16 =
  1912. ##define XkbAX_NeedOption(c,w) ((c)->ax_options&(w))
  1913. result = toU16(ze(c.ax_options) and ze(w))
  1914. proc XkbAX_NeedFeedback(c: PXkbControlsPtr, w: int16): bool =
  1915. ##define XkbAX_NeedFeedback(c,w) (XkbAX_AnyFeedback(c)&&XkbAX_NeedOption(c,w))
  1916. result = (XkbAX_AnyFeedback(c) > 0'i16) and (XkbAX_NeedOption(c, w) > 0'i16)
  1917. proc XkbSMKeyActionsPtr(m: PXkbServerMapPtr, k: int16): PXkbAction =
  1918. ##define XkbSMKeyActionsPtr(m,k) (&(m)->acts[(m)->key_acts[k]])
  1919. result = addr(m.acts[ze(m.key_acts[ze(k)])])
  1920. proc XkbCMKeyGroupInfo(m: PXkbClientMapPtr, k: int16): int8 =
  1921. ##define XkbCMKeyGroupInfo(m,k) ((m)->key_sym_map[k].group_info)
  1922. result = m.key_sym_map[ze(k)].group_info
  1923. proc XkbCMKeyNumGroups(m: PXkbClientMapPtr, k: int16): int8 =
  1924. ##define XkbCMKeyNumGroups(m,k) (XkbNumGroups((m)->key_sym_map[k].group_info))
  1925. result = toU8(XkbNumGroups(m.key_sym_map[ze(k)].group_info))
  1926. proc XkbCMKeyGroupWidth(m: PXkbClientMapPtr, k: int16, g: int8): int8 =
  1927. ##define XkbCMKeyGroupWidth(m,k,g) (XkbCMKeyType(m,k,g)->num_levels)
  1928. result = XkbCMKeyType(m, k, g).num_levels
  1929. proc XkbCMKeyGroupsWidth(m: PXkbClientMapPtr, k: int16): int8 =
  1930. ##define XkbCMKeyGroupsWidth(m,k) ((m)->key_sym_map[k].width)
  1931. result = m.key_sym_map[ze(k)].width
  1932. proc XkbCMKeyTypeIndex(m: PXkbClientMapPtr, k: int16, g: int8): int8 =
  1933. ##define XkbCMKeyTypeIndex(m,k,g) ((m)->key_sym_map[k].kt_index[g&0x3])
  1934. result = m.key_sym_map[ze(k)].kt_index[ze(g) and 0x00000003]
  1935. proc XkbCMKeyType(m: PXkbClientMapPtr, k: int16, g: int8): PXkbKeyTypePtr =
  1936. ##define XkbCMKeyType(m,k,g) (&(m)->types[XkbCMKeyTypeIndex(m,k,g)])
  1937. result = addr(m.types[ze(XkbCMKeyTypeIndex(m, k, g))])
  1938. proc XkbCMKeyNumSyms(m: PXkbClientMapPtr, k: int16): int16 =
  1939. ##define XkbCMKeyNumSyms(m,k) (XkbCMKeyGroupsWidth(m,k)*XkbCMKeyNumGroups(m,k))
  1940. result = toU16(ze(XkbCMKeyGroupsWidth(m, k)) or ze(XkbCMKeyNumGroups(m, k)))
  1941. proc XkbCMKeySymsOffset(m: PXkbClientMapPtr, k: int16): int8 =
  1942. ##define XkbCMKeySymsOffset(m,k) ((m)->key_sym_map[k].offset)
  1943. result = m.key_sym_map[ze(k)].offset
  1944. proc XkbCMKeySymsPtr*(m: PXkbClientMapPtr, k: int16): PKeySym =
  1945. ##define XkbCMKeySymsPtr(m,k) (&(m)->syms[XkbCMKeySymsOffset(m,k)])
  1946. result = addr(m.syms[ze(XkbCMKeySymsOffset(m, k))])
  1947. proc XkbIM_IsAuto(i: PXkbIndicatorMapPtr): bool =
  1948. ##define XkbIM_IsAuto(i) ((((i)->flags&XkbIM_NoAutomatic)==0)&&(((i)->which_groups&&(i)->groups)||
  1949. # ((i)->which_mods&&(i)->mods.mask)|| ((i)->ctrls)))
  1950. result = ((ze(i.flags) and XkbIM_NoAutomatic) == 0) and
  1951. (((i.which_groups > 0'i8) and (i.groups > 0'i8)) or
  1952. ((i.which_mods > 0'i8) and (i.mods.mask > 0'i8)) or (i.ctrls > 0'i8))
  1953. proc XkbIM_InUse(i: PXkbIndicatorMapPtr): bool =
  1954. ##define XkbIM_InUse(i) (((i)->flags)||((i)->which_groups)||((i)->which_mods)||((i)->ctrls))
  1955. result = (i.flags > 0'i8) or (i.which_groups > 0'i8) or (i.which_mods > 0'i8) or
  1956. (i.ctrls > 0'i8)
  1957. proc XkbKeyKeyTypeIndex(d: PXkbDescPtr, k: int16, g: int8): int8 =
  1958. ##define XkbKeyKeyTypeIndex(d,k,g) (XkbCMKeyTypeIndex((d)->map,k,g))
  1959. result = XkbCMKeyTypeIndex(d.map, k, g)
  1960. proc XkbKeyKeyType(d: PXkbDescPtr, k: int16, g: int8): PXkbKeyTypePtr =
  1961. ##define XkbKeyKeyType(d,k,g) (XkbCMKeyType((d)->map,k,g))
  1962. result = XkbCMKeyType(d.map, k, g)
  1963. proc XkbKeyGroupWidth(d: PXkbDescPtr, k: int16, g: int8): int8 =
  1964. ##define XkbKeyGroupWidth(d,k,g) (XkbCMKeyGroupWidth((d)->map,k,g))
  1965. result = XkbCMKeyGroupWidth(d.map, k, g)
  1966. proc XkbKeyGroupsWidth(d: PXkbDescPtr, k: int16): int8 =
  1967. ##define XkbKeyGroupsWidth(d,k) (XkbCMKeyGroupsWidth((d)->map,k))
  1968. result = XkbCMKeyGroupsWidth(d.map, k)
  1969. proc XkbKeyGroupInfo(d: PXkbDescPtr, k: int16): int8 =
  1970. ##define XkbKeyGroupInfo(d,k) (XkbCMKeyGroupInfo((d)->map,(k)))
  1971. result = XkbCMKeyGroupInfo(d.map, k)
  1972. proc XkbKeyNumGroups(d: PXkbDescPtr, k: int16): int8 =
  1973. ##define XkbKeyNumGroups(d,k) (XkbCMKeyNumGroups((d)->map,(k)))
  1974. result = XkbCMKeyNumGroups(d.map, k)
  1975. proc XkbKeyNumSyms(d: PXkbDescPtr, k: int16): int16 =
  1976. ##define XkbKeyNumSyms(d,k) (XkbCMKeyNumSyms((d)->map,(k)))
  1977. result = XkbCMKeyNumSyms(d.map, k)
  1978. proc XkbKeySymsPtr*(d: PXkbDescPtr, k: int16): PKeySym =
  1979. ##define XkbKeySymsPtr(d,k) (XkbCMKeySymsPtr((d)->map,(k)))
  1980. result = XkbCMKeySymsPtr(d.map, k)
  1981. proc XkbKeySym(d: PXkbDescPtr, k: int16, n: int16): TKeySym =
  1982. ##define XkbKeySym(d,k,n) (XkbKeySymsPtr(d,k)[n])
  1983. result = cast[ptr array[0..0xffff, TKeySym]](XkbKeySymsPtr(d, k))[ze(n)] # XXX: this seems strange!
  1984. proc XkbKeySymEntry(d: PXkbDescPtr, k: int16, sl: int16, g: int8): TKeySym =
  1985. ##define XkbKeySymEntry(d,k,sl,g) (XkbKeySym(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))))
  1986. result = XkbKeySym(d, k, toU16(ze(XkbKeyGroupsWidth(d, k)) * ze(g) + ze(sl)))
  1987. proc XkbKeyAction(d: PXkbDescPtr, k: int16, n: int16): PXkbAction =
  1988. ##define XkbKeyAction(d,k,n) (XkbKeyHasActions(d,k)?&XkbKeyActionsPtr(d,k)[n]:NULL)
  1989. #if (XkbKeyHasActions(d, k)):
  1990. # result = XkbKeyActionsPtr(d, k)[ze(n)] #Buggy !!!
  1991. assert(false)
  1992. result = nil
  1993. proc XkbKeyActionEntry(d: PXkbDescPtr, k: int16, sl: int16, g: int8): int8 =
  1994. ##define XkbKeyActionEntry(d,k,sl,g) (XkbKeyHasActions(d,k) ?
  1995. # XkbKeyAction(d, k, ((XkbKeyGroupsWidth(d, k) * (g))+(sl))):NULL)
  1996. if XkbKeyHasActions(d, k):
  1997. result = XkbKeyGroupsWidth(d, k) *% g +% toU8(sl)
  1998. else:
  1999. result = 0'i8
  2000. proc XkbKeyHasActions(d: PXkbDescPtr, k: int16): bool =
  2001. ##define XkbKeyHasActions(d,k) ((d)->server->key_acts[k]!=0)
  2002. result = d.server.key_acts[ze(k)] != 0'i16
  2003. proc XkbKeyNumActions(d: PXkbDescPtr, k: int16): int16 =
  2004. ##define XkbKeyNumActions(d,k) (XkbKeyHasActions(d,k)?XkbKeyNumSyms(d,k):1)
  2005. if (XkbKeyHasActions(d, k)): result = XkbKeyNumSyms(d, k)
  2006. else: result = 1'i16
  2007. proc XkbKeyActionsPtr(d: PXkbDescPtr, k: int16): PXkbAction =
  2008. ##define XkbKeyActionsPtr(d,k) (XkbSMKeyActionsPtr((d)->server,k))
  2009. result = XkbSMKeyActionsPtr(d.server, k)
  2010. proc XkbKeycodeInRange(d: PXkbDescPtr, k: int16): bool =
  2011. ##define XkbKeycodeInRange(d,k) (((k)>=(d)->min_key_code)&& ((k)<=(d)->max_key_code))
  2012. result = (char(toU8(k)) >= d.min_key_code) and (char(toU8(k)) <= d.max_key_code)
  2013. proc XkbNumKeys(d: PXkbDescPtr): int8 =
  2014. ##define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1)
  2015. result = toU8(ord(d.max_key_code) - ord(d.min_key_code) + 1)
  2016. proc XkbXI_DevHasBtnActs(d: PXkbDeviceInfoPtr): bool =
  2017. ##define XkbXI_DevHasBtnActs(d) (((d)->num_btns>0)&&((d)->btn_acts!=NULL))
  2018. result = (d.num_btns > 0'i16) and (not (d.btn_acts == nil))
  2019. proc XkbXI_LegalDevBtn(d: PXkbDeviceInfoPtr, b: int16): bool =
  2020. ##define XkbXI_LegalDevBtn(d,b) (XkbXI_DevHasBtnActs(d)&&((b)<(d)->num_btns))
  2021. result = XkbXI_DevHasBtnActs(d) and (b <% d.num_btns)
  2022. proc XkbXI_DevHasLeds(d: PXkbDeviceInfoPtr): bool =
  2023. ##define XkbXI_DevHasLeds(d) (((d)->num_leds>0)&&((d)->leds!=NULL))
  2024. result = (d.num_leds > 0'i16) and (not (d.leds == nil))
  2025. proc XkbBoundsWidth(b: PXkbBoundsPtr): int16 =
  2026. ##define XkbBoundsWidth(b) (((b)->x2)-((b)->x1))
  2027. result = (b.x2) - b.x1
  2028. proc XkbBoundsHeight(b: PXkbBoundsPtr): int16 =
  2029. ##define XkbBoundsHeight(b) (((b)->y2)-((b)->y1))
  2030. result = (b.y2) - b.y1
  2031. proc XkbOutlineIndex(s: PXkbShapePtr, o: PXkbOutlinePtr): int32 =
  2032. ##define XkbOutlineIndex(s,o) ((int)((o)-&(s)->outlines[0]))
  2033. result = int32((cast[TAddress](o) - cast[TAddress](addr(s.outlines[0]))) div sizeof(PXkbOutlinePtr))
  2034. proc XkbShapeDoodadColor(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbColorPtr =
  2035. ##define XkbShapeDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
  2036. result = addr((g.colors[ze(d.color_ndx)]))
  2037. proc XkbShapeDoodadShape(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr): PXkbShapePtr =
  2038. ##define XkbShapeDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
  2039. result = addr(g.shapes[ze(d.shape_ndx)])
  2040. proc XkbSetShapeDoodadColor(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr,
  2041. c: PXkbColorPtr) =
  2042. ##define XkbSetShapeDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
  2043. d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
  2044. proc XkbSetShapeDoodadShape(g: PXkbGeometryPtr, d: PXkbShapeDoodadPtr,
  2045. s: PXkbShapePtr) =
  2046. ##define XkbSetShapeDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
  2047. d.shape_ndx = toU16((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec))
  2048. proc XkbTextDoodadColor(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr): PXkbColorPtr =
  2049. ##define XkbTextDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
  2050. result = addr(g.colors[ze(d.color_ndx)])
  2051. proc XkbSetTextDoodadColor(g: PXkbGeometryPtr, d: PXkbTextDoodadPtr,
  2052. c: PXkbColorPtr) =
  2053. ##define XkbSetTextDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
  2054. d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
  2055. proc XkbIndicatorDoodadShape(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbShapeDoodadPtr =
  2056. ##define XkbIndicatorDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
  2057. result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(d.shape_ndx)]))
  2058. proc XkbIndicatorDoodadOnColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr =
  2059. ##define XkbIndicatorDoodadOnColor(g,d) (&(g)->colors[(d)->on_color_ndx])
  2060. result = addr(g.colors[ze(d.on_color_ndx)])
  2061. proc XkbIndicatorDoodadOffColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr): PXkbColorPtr =
  2062. ##define XkbIndicatorDoodadOffColor(g,d) (&(g)->colors[(d)->off_color_ndx])
  2063. result = addr(g.colors[ze(d.off_color_ndx)])
  2064. proc XkbSetIndicatorDoodadOnColor(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr,
  2065. c: PXkbColorPtr) =
  2066. ##define XkbSetIndicatorDoodadOnColor(g,d,c) ((d)->on_color_ndx= (c)-&(g)->colors[0])
  2067. d.on_color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
  2068. proc XkbSetIndicatorDoodadOffColor(g: PXkbGeometryPtr,
  2069. d: PXkbIndicatorDoodadPtr, c: PXkbColorPtr) =
  2070. ##define XkbSetIndicatorDoodadOffColor(g,d,c) ((d)->off_color_ndx= (c)-&(g)->colors[0])
  2071. d.off_color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TxkbColorRec))
  2072. proc XkbSetIndicatorDoodadShape(g: PXkbGeometryPtr, d: PXkbIndicatorDoodadPtr,
  2073. s: PXkbShapeDoodadPtr) =
  2074. ##define XkbSetIndicatorDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
  2075. d.shape_ndx = toU16((cast[TAddress](s) - (cast[TAddress](addr(g.shapes[0])))) div sizeof(TXkbShapeRec))
  2076. proc XkbLogoDoodadColor(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbColorPtr =
  2077. ##define XkbLogoDoodadColor(g,d) (&(g)->colors[(d)->color_ndx])
  2078. result = addr(g.colors[ze(d.color_ndx)])
  2079. proc XkbLogoDoodadShape(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr): PXkbShapeDoodadPtr =
  2080. ##define XkbLogoDoodadShape(g,d) (&(g)->shapes[(d)->shape_ndx])
  2081. result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(d.shape_ndx)]))
  2082. proc XkbSetLogoDoodadColor(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr,
  2083. c: PXkbColorPtr) =
  2084. ##define XkbSetLogoDoodadColor(g,d,c) ((d)->color_ndx= (c)-&(g)->colors[0])
  2085. d.color_ndx = toU16((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TXkbColorRec))
  2086. proc XkbSetLogoDoodadShape(g: PXkbGeometryPtr, d: PXkbLogoDoodadPtr,
  2087. s: PXkbShapeDoodadPtr) =
  2088. ##define XkbSetLogoDoodadShape(g,d,s) ((d)->shape_ndx= (s)-&(g)->shapes[0])
  2089. d.shape_ndx = toU16((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec))
  2090. proc XkbKeyShape(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbShapeDoodadPtr =
  2091. ##define XkbKeyShape(g,k) (&(g)->shapes[(k)->shape_ndx])
  2092. result = cast[PXkbShapeDoodadPtr](addr(g.shapes[ze(k.shape_ndx)]))
  2093. proc XkbKeyColor(g: PXkbGeometryPtr, k: PXkbKeyPtr): PXkbColorPtr =
  2094. ##define XkbKeyColor(g,k) (&(g)->colors[(k)->color_ndx])
  2095. result = addr(g.colors[ze(k.color_ndx)])
  2096. proc XkbSetKeyShape(g: PXkbGeometryPtr, k: PXkbKeyPtr, s: PXkbShapeDoodadPtr) =
  2097. ##define XkbSetKeyShape(g,k,s) ((k)->shape_ndx= (s)-&(g)->shapes[0])
  2098. k.shape_ndx = toU8((cast[TAddress](s) - cast[TAddress](addr(g.shapes[0]))) div sizeof(TXkbShapeRec))
  2099. proc XkbSetKeyColor(g: PXkbGeometryPtr, k: PXkbKeyPtr, c: PXkbColorPtr) =
  2100. ##define XkbSetKeyColor(g,k,c) ((k)->color_ndx= (c)-&(g)->colors[0])
  2101. k.color_ndx = toU8((cast[TAddress](c) - cast[TAddress](addr(g.colors[0]))) div sizeof(TxkbColorRec))
  2102. proc XkbGeomColorIndex(g: PXkbGeometryPtr, c: PXkbColorPtr): int32 =
  2103. ##define XkbGeomColorIndex(g,c) ((int)((c)-&(g)->colors[0]))
  2104. result = toU16((cast[TAddress](c) - (cast[TAddress](addr(g.colors[0])))) div sizeof(TxkbColorRec))