Commit 8b100fc0a981cdf01115dc85ab1984f604be5655

Dan Nicholson 2009-04-05T15:15:20

Add action datatypes as defined in the server Some of the XkbAction types are defined differently in the server, so we add those to XKBcommon.h and use them here like XkbcDescPtr. We'll have to deal with the impedance mismatch on the client side later.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
diff --git a/include/X11/extensions/XKBcommon.h b/include/X11/extensions/XKBcommon.h
index f7700f5..21f8908 100644
--- a/include/X11/extensions/XKBcommon.h
+++ b/include/X11/extensions/XKBcommon.h
@@ -36,6 +36,82 @@ authorization from the authors.
 #include <X11/extensions/XKBgeomcommon.h>
 #include <X11/extensions/XKBrulescommon.h>
 
+/* Action structures used in the server */
+typedef struct _XkbcModAction {
+    unsigned char   type;
+    unsigned char   flags;
+    unsigned char   mask;
+    unsigned char   real_mods;
+    unsigned int    vmods;
+} XkbcModAction;
+
+typedef struct _XkbcISOAction {
+    unsigned char   type;
+    unsigned char   flags;
+    unsigned char   mask;
+    unsigned char   real_mods;
+    /* FIXME: Make this an int. */
+    char            group_XXX;
+    unsigned char   affect;
+    unsigned int    vmods;
+} XkbcISOAction;
+
+typedef struct _XkbcPtrAction {
+    unsigned char   type;
+    unsigned char   flags;
+    int             x;
+    int             y;
+} XkbcPtrAction;
+
+typedef struct _XkbcCtrlsAction {
+    unsigned char   type;
+    unsigned char   flags;
+    unsigned long   ctrls;
+} XkbcCtrlsAction;
+
+typedef struct  _XkbcRedirectKeyAction {
+    unsigned char   type;
+    unsigned char   new_key;
+    unsigned char   mods_mask;
+    unsigned char   mods;
+    unsigned int    vmods_mask;
+    unsigned int    vmods;
+} XkbcRedirectKeyAction;
+
+typedef union _XkbcAction {
+    XkbAnyAction            any;
+    XkbcModAction           mods;
+    XkbGroupAction          group;
+    XkbcISOAction           iso;
+    XkbcPtrAction           ptr;
+    XkbPtrBtnAction         btn;
+    XkbPtrDfltAction        dflt;
+    XkbSwitchScreenAction   screen;
+    XkbcCtrlsAction         ctrls;
+    XkbMessageAction        msg;
+    XkbcRedirectKeyAction   redirect;
+    XkbDeviceBtnAction      devbtn;
+    XkbDeviceValuatorAction devval;
+    unsigned char           type;
+} XkbcAction;
+
+typedef struct _XkbcServerMapRec {
+    unsigned short      num_acts;
+    unsigned short      size_acts;
+    XkbcAction *        acts;
+
+    XkbBehavior *       behaviors;
+    unsigned short *    key_acts;
+#if defined(__cplusplus) || defined(c_plusplus)
+    /* explicit is a C++ reserved word */
+    unsigned char *     c_explicit;
+#else
+    unsigned char *     explicit;
+#endif
+    unsigned char       vmods[XkbNumVirtualMods];
+    unsigned short *    vmodmap;
+} XkbcServerMapRec, *XkbcServerMapPtr;
+
 /* Common keyboard description structure */
 typedef struct _XkbcDesc {
     unsigned int        defined;
@@ -45,7 +121,7 @@ typedef struct _XkbcDesc {
     KeyCode             max_key_code;
 
     XkbControlsPtr      ctrls;
-    XkbServerMapPtr     server;
+    XkbcServerMapPtr    server;
     XkbClientMapPtr     map;
     XkbIndicatorPtr     indicators;
     XkbNamesPtr         names;
@@ -130,7 +206,7 @@ extern int
 XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
                        XkbChangesPtr changes);
 
-extern XkbAction *
+extern XkbcAction *
 XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed);
 
 extern void
diff --git a/src/malloc.c b/src/malloc.c
index df601f6..cf5103f 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -125,13 +125,13 @@ int
 XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions)
 {
     int i;
-    XkbServerMapPtr map;
+    XkbcServerMapPtr map;
 
     if (!xkb)
         return BadMatch;
 
     if (!xkb->server) {
-        map = _XkbTypedCalloc(1, XkbServerMapRec);
+        map = _XkbTypedCalloc(1, XkbcServerMapRec);
         if (!map)
             return BadAlloc;
 
@@ -167,7 +167,7 @@ XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions)
             nNewActions = 1;
 
         if (!map->acts) {
-            map->acts = _XkbTypedCalloc(nNewActions + 1, XkbAction);
+            map->acts = _XkbTypedCalloc(nNewActions + 1, XkbcAction);
             if (!map->acts)
                 return BadAlloc;
             map->num_acts = 1;
@@ -175,10 +175,10 @@ XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions)
         }
         else if ((map->size_acts - map->num_acts) < nNewActions) {
             unsigned need;
-            XkbAction *prev_acts = map->acts;
+            XkbcAction *prev_acts = map->acts;
 
             need = map->num_acts + nNewActions;
-            map->acts = _XkbTypedRealloc(map->acts, need, XkbAction);
+            map->acts = _XkbTypedRealloc(map->acts, need, XkbcAction);
             if (!map->acts) {
                 _XkbFree(prev_acts);
                 map->num_acts = map->size_acts = 0;
@@ -187,7 +187,7 @@ XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions)
 
             map->size_acts = need;
             bzero(&map->acts[map->num_acts],
-                  (map->size_acts - map->num_acts) * sizeof(XkbAction));
+                  (map->size_acts - map->num_acts) * sizeof(XkbcAction));
         }
 
         if (!map->key_acts) {
@@ -814,11 +814,11 @@ XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
     return Success;
 }
 
-XkbAction *
+XkbcAction *
 XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed)
 {
     int i, nActs;
-    XkbAction *newActs;
+    XkbcAction *newActs;
 
     if (needed == 0) {
         xkb->server->key_acts[key] = 0;
@@ -829,7 +829,7 @@ XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed)
         (XkbKeyNumSyms(xkb, key) >= (unsigned)needed))
         return XkbKeyActionsPtr(xkb, key);
 
-    if (xkb->server->size_acts-xkb->server->num_acts >= (unsigned)needed) {
+    if (xkb->server->size_acts - xkb->server->num_acts >= (unsigned)needed) {
         xkb->server->key_acts[key] = xkb->server->num_acts;
         xkb->server->num_acts += needed;
 
@@ -837,7 +837,7 @@ XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed)
     }
 
     xkb->server->size_acts = xkb->server->num_acts + needed + 8;
-    newActs = _XkbTypedCalloc(xkb->server->size_acts, XkbAction);
+    newActs = _XkbTypedCalloc(xkb->server->size_acts, XkbcAction);
     if (!newActs)
         return NULL;
     newActs[0].type = XkbSA_NoAction;
@@ -858,10 +858,10 @@ XkbcResizeKeyActions(XkbcDescPtr xkb, int key, int needed)
 
         if (nCopy > 0)
             memcpy(&newActs[nActs], XkbKeyActionsPtr(xkb, i),
-                   nCopy * sizeof(XkbAction));
+                   nCopy * sizeof(XkbcAction));
         if (nCopy < nKeyActs)
-            bzero(&newActs[nActs+nCopy],
-                  (nKeyActs - nCopy) * sizeof(XkbAction));
+            bzero(&newActs[nActs + nCopy],
+                  (nKeyActs - nCopy) * sizeof(XkbcAction));
 
         xkb->server->key_acts[i] = nActs;
         nActs += nKeyActs;
@@ -940,7 +940,7 @@ XkbcFreeClientMap(XkbcDescPtr xkb, unsigned what, Bool freeMap)
 void
 XkbcFreeServerMap(XkbcDescPtr xkb, unsigned what, Bool freeMap)
 {
-    XkbServerMapPtr map;
+    XkbcServerMapPtr map;
 
     if (!xkb || !xkb->server)
         return;
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index f44e5b8..ca9c44e 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -394,11 +394,11 @@ HandleSetLatchMods(XkbcDescPtr xkb,
                    XkbAnyAction * action,
                    unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
-    XkbModAction *act;
+    XkbcModAction *act;
     unsigned rtrn;
     unsigned t1, t2;
 
-    act = (XkbModAction *) action;
+    act = (XkbcModAction *) action;
     if (array_ndx != NULL)
     {
         switch (field)
@@ -426,8 +426,7 @@ HandleSetLatchMods(XkbcDescPtr xkb,
         {
             act->flags = t1;
             act->real_mods = act->mask = (t2 & 0xff);
-            t2 = (t2 >> 8) & 0xffff;
-            XkbSetModActionVMods(act, t2);
+            act->vmods = (t2 >> 8) & 0xffff;
             return True;
         }
         return False;
@@ -440,10 +439,10 @@ HandleLockMods(XkbcDescPtr xkb,
                XkbAnyAction * action,
                unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
-    XkbModAction *act;
+    XkbcModAction *act;
     unsigned t1, t2;
 
-    act = (XkbModAction *) action;
+    act = (XkbcModAction *) action;
     if ((array_ndx != NULL) && (field == F_Modifiers))
         return ReportActionNotArray(action->type, field);
     switch (field)
@@ -454,8 +453,7 @@ HandleLockMods(XkbcDescPtr xkb,
         {
             act->flags = t1;
             act->real_mods = act->mask = (t2 & 0xff);
-            t2 = (t2 >> 8) & 0xffff;
-            XkbSetModActionVMods(act, t2);
+            act->vmods = (t2 >> 8) & 0xffff;
             return True;
         }
         return False;
@@ -588,10 +586,10 @@ HandleMovePtr(XkbcDescPtr xkb,
               unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbPtrAction *act;
+    XkbcPtrAction *act;
     Bool absolute;
 
-    act = (XkbPtrAction *) action;
+    act = (XkbcPtrAction *) action;
     if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
         return ReportActionNotArray(action->type, field);
 
@@ -607,13 +605,13 @@ HandleMovePtr(XkbcDescPtr xkb,
         {
             if (absolute)
                 act->flags |= XkbSA_MoveAbsoluteX;
-            XkbSetPtrActionX(act, rtrn.ival);
+            act->x = rtrn.ival;
         }
         else
         {
             if (absolute)
                 act->flags |= XkbSA_MoveAbsoluteY;
-            XkbSetPtrActionY(act, rtrn.ival);
+            act->y = rtrn.ival;
         }
         return True;
     }
@@ -788,11 +786,11 @@ HandleISOLock(XkbcDescPtr xkb,
               unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbISOAction *act;
+    XkbcISOAction *act;
     unsigned flags, mods;
     int group;
 
-    act = (XkbISOAction *) action;
+    act = (XkbcISOAction *) action;
     switch (field)
     {
     case F_Modifiers:
@@ -803,8 +801,7 @@ HandleISOLock(XkbcDescPtr xkb,
         {
             act->flags = flags & (~XkbSA_ISODfltIsGroup);
             act->real_mods = mods & 0xff;
-            mods = (mods >> 8) & 0xff;
-            XkbSetModActionVMods(act, mods);
+            act->vmods = (mods >> 8) & 0xff;
             return True;
         }
         return False;
@@ -928,9 +925,9 @@ HandleSetLockControls(XkbcDescPtr xkb,
                       unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbCtrlsAction *act;
+    XkbcCtrlsAction *act;
 
-    act = (XkbCtrlsAction *) action;
+    act = (XkbcCtrlsAction *) action;
     if (field == F_Controls)
     {
         if (array_ndx != NULL)
@@ -938,7 +935,7 @@ HandleSetLockControls(XkbcDescPtr xkb,
         if (!ExprResolveMask
             (value, &rtrn, SimpleLookup, (char *) ctrlNames))
             return ReportMismatch(action->type, field, "controls mask");
-        XkbActionSetCtrls(act, rtrn.uval);
+        act->ctrls = rtrn.uval;
         return True;
     }
     return ReportIllegal(action->type, field);
@@ -1038,14 +1035,14 @@ HandleRedirectKey(XkbcDescPtr xkb,
                   unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbRedirectKeyAction *act;
-    unsigned t1, t2, vmods, vmask;
+    XkbcRedirectKeyAction *act;
+    unsigned t1, t2;
     unsigned long tmp;
 
     if (array_ndx != NULL)
         return ReportActionNotArray(action->type, field);
 
-    act = (XkbRedirectKeyAction *) action;
+    act = (XkbcRedirectKeyAction *) action;
     switch (field)
     {
     case F_Keycode:
@@ -1071,15 +1068,11 @@ HandleRedirectKey(XkbcDescPtr xkb,
                 act->mods &= ~(t2 & 0xff);
 
             t2 = (t2 >> 8) & 0xffff;
-            vmods = XkbSARedirectVMods(act);
-            vmask = XkbSARedirectVModsMask(act);
-            vmask |= t2;
+            act->vmods_mask |= t2;
             if (field == F_Modifiers)
-                vmods |= t2;
+                act->vmods |= t2;
             else
-                vmods &= ~t2;
-            XkbSARedirectSetVMods(act, vmods);
-            XkbSARedirectSetVModsMask(act, vmask);
+                act->vmods &= ~t2;
             return True;
         }
         return True;
@@ -1276,7 +1269,7 @@ static actionHandler handleAction[XkbSA_NumActions + 1] = {
 /***====================================================================***/
 
 static void
-ApplyActionFactoryDefaults(XkbAction * action)
+ApplyActionFactoryDefaults(XkbcAction * action)
 {
     if (action->type == XkbSA_SetPtrDflt)
     {                           /* increment default button */
@@ -1324,7 +1317,7 @@ HandleActionDef(ExprDef * def,
     action->type = hndlrType = tmp;
     if (action->type != XkbSA_NoAction)
     {
-        ApplyActionFactoryDefaults((XkbAction *) action);
+        ApplyActionFactoryDefaults((XkbcAction *) action);
         while (info)
         {
             if ((info->action == XkbSA_NoAction)
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index b067764..49d912a 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -67,7 +67,7 @@ typedef struct _KeyInfo
     unsigned char actsDefined;
     short numLevels[XkbNumKbdGroups];
     KeySym *syms[XkbNumKbdGroups];
-    XkbAction *acts[XkbNumKbdGroups];
+    XkbcAction *acts[XkbNumKbdGroups];
     Atom types[XkbNumKbdGroups];
     unsigned repeat;
     XkbBehavior behavior;
@@ -186,14 +186,14 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
             }
             if (old->acts[i] != NULL)
             {
-                new->acts[i] = uTypedCalloc(width, XkbAction);
+                new->acts[i] = uTypedCalloc(width, XkbcAction);
                 if (!new->acts[i])
                 {
                     new->acts[i] = NULL;
                     return False;
                 }
                 memcpy((char *) new->acts[i], (char *) old->acts[i],
-                       width * sizeof(XkbAction));
+                       width * sizeof(XkbcAction));
             }
         }
     }
@@ -320,7 +320,7 @@ ResizeKeyGroup(KeyInfo * key,
     {
         key->acts[group] = uTypedRecalloc(key->acts[group],
                                           key->numLevels[group], newWidth,
-                                          XkbAction);
+                                          XkbcAction);
         if (!key->acts[group])
             return False;
     }
@@ -333,7 +333,7 @@ MergeKeyGroups(SymbolsInfo * info,
                KeyInfo * into, KeyInfo * from, unsigned group)
 {
     KeySym *resultSyms;
-    XkbAction *resultActs;
+    XkbcAction *resultActs;
     int resultWidth;
     register int i;
     Bool report, clobber;
@@ -366,7 +366,7 @@ MergeKeyGroups(SymbolsInfo * info,
     }
     if ((resultActs == NULL) && (into->acts[group] || from->acts[group]))
     {
-        resultActs = uTypedCalloc(resultWidth, XkbAction);
+        resultActs = uTypedCalloc(resultWidth, XkbcAction);
         if (!resultActs)
         {
             WSGO("Could not allocate actions for group merge\n");
@@ -415,7 +415,7 @@ MergeKeyGroups(SymbolsInfo * info,
         }
         if (resultActs != NULL)
         {
-            XkbAction *fromAct, *toAct;
+            XkbcAction *fromAct, *toAct;
             fromAct = (from->acts[group] ? &from->acts[group][i] : NULL);
             toAct = (into->acts[group] ? &into->acts[group][i] : NULL);
             if (((fromAct == NULL) || (fromAct->type == XkbSA_NoAction))
@@ -430,7 +430,7 @@ MergeKeyGroups(SymbolsInfo * info,
             }
             else
             {
-                XkbAction *use, *ignore;
+                XkbcAction *use, *ignore;
                 if (clobber)
                 {
                     use = fromAct;
@@ -1541,7 +1541,7 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
             key->syms[i] = (KeySym *) NULL;
             if (key->acts[i] != NULL)
                 uFree(key->acts[i]);
-            key->acts[i] = (XkbAction *) NULL;
+            key->acts[i] = (XkbcAction *) NULL;
             key->types[i] = (Atom) 0;
         }
     }
@@ -1552,7 +1552,7 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
     key->syms[group] = key->syms[0];
     key->syms[0] = (KeySym *) NULL;
     key->acts[group] = key->acts[0];
-    key->acts[0] = (XkbAction *) NULL;
+    key->acts[0] = (XkbcAction *) NULL;
     key->types[group] = key->types[0];
     key->types[0] = (Atom) 0;
     return True;
@@ -1849,11 +1849,11 @@ PrepareKeyDef(KeyInfo * key)
         }
         if ((key->actsDefined & 1) && key->acts[0])
         {
-            key->acts[i] = uTypedCalloc(width, XkbAction);
+            key->acts[i] = uTypedCalloc(width, XkbcAction);
             if (key->acts[i] == NULL)
                 continue;
             memcpy((void *) key->acts[i], (void *) key->acts[0],
-                   width * sizeof(XkbAction));
+                   width * sizeof(XkbcAction));
             key->actsDefined |= 1 << i;
         }
         if ((key->symsDefined & 1) && key->syms[0])
@@ -1892,7 +1892,7 @@ PrepareKeyDef(KeyInfo * key)
         if ((key->acts[i] != key->acts[0]) &&
             (key->acts[i] == NULL || key->acts[0] == NULL ||
              memcmp((void *) key->acts[i], (void *) key->acts[0],
-                    sizeof(XkbAction) * key->numLevels[0])))
+                    sizeof(XkbcAction) * key->numLevels[0])))
         {
             identical = False;
             break;
@@ -1908,7 +1908,7 @@ PrepareKeyDef(KeyInfo * key)
             key->syms[i] = (KeySym *) NULL;
             if (key->acts[i] != NULL)
                 uFree(key->acts[i]);
-            key->acts[i] = (XkbAction *) NULL;
+            key->acts[i] = (XkbcAction *) NULL;
             key->types[i] = (Atom) 0;
         }
         key->symsDefined &= 1;
@@ -1931,7 +1931,7 @@ CopySymbolsDef(XkbcDescPtr xkb, KeyInfo *key, int start_from)
     XkbKeyTypePtr type;
     Bool haveActions, autoType, useAlias;
     KeySym *outSyms;
-    XkbAction *outActs;
+    XkbcAction *outActs;
     unsigned types[XkbNumKbdGroups];
 
     useAlias = (start_from == 0);
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index bbcad35..3faa46a 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -82,7 +82,7 @@ HandleVModDef(VModDef * stmt, unsigned mergeMode, VModInfo * info)
 {
     register int i, bit, nextFree;
     ExprResult mod;
-    XkbServerMapPtr srv;
+    XkbcServerMapPtr srv;
     XkbNamesPtr names;
     Atom stmtName;