xkb.pp 118 KB

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