~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/x11/xkb.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

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