xkb.pp 118 KB

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