Commit 0b2506db12b6d12cec0c516d7eb9698aaa5960fa

Daniel Stone 2012-09-10T19:23:16

kbproto unentanglement: action types Signed-off-by: Daniel Stone <daniel@fooishbar.org>

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
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 73dced7..9217877 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -384,45 +384,45 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
     type = ActionTypeText(action->type);
 
     switch (action->type) {
-    case XkbSA_SetMods:
-    case XkbSA_LatchMods:
-    case XkbSA_LockMods:
+    case ACTION_TYPE_MOD_SET:
+    case ACTION_TYPE_MOD_LATCH:
+    case ACTION_TYPE_MOD_LOCK:
         if (action->mods.flags & XkbSA_UseModMapMods)
             args = "modMapMods";
         else
             args = VModMaskText(keymap, action->mods.mods.mods);
         write_buf(buf, "%s%s(modifiers=%s%s%s)%s", prefix, type, args,
-                  (action->type != XkbSA_LockGroup &&
+                  (action->type != ACTION_TYPE_MOD_LOCK &&
                    (action->mods.flags & XkbSA_ClearLocks)) ?
                    ",clearLocks" : "",
-                  (action->type != XkbSA_LockGroup &&
+                  (action->type != ACTION_TYPE_MOD_LOCK &&
                    (action->mods.flags & XkbSA_LatchToLock)) ?
                    ",latchToLock" : "",
                   suffix);
         break;
 
-    case XkbSA_SetGroup:
-    case XkbSA_LatchGroup:
-    case XkbSA_LockGroup:
+    case ACTION_TYPE_GROUP_SET:
+    case ACTION_TYPE_GROUP_LATCH:
+    case ACTION_TYPE_GROUP_LOCK:
         write_buf(buf, "%s%s(group=%s%d%s%s)%s", prefix, type,
                   (!(action->group.flags & XkbSA_GroupAbsolute) &&
                    action->group.group > 0) ? "+" : "",
                   (action->group.flags & XkbSA_GroupAbsolute) ?
                   action->group.group + 1 : action->group.group,
-                  (action->type != XkbSA_LockGroup &&
+                  (action->type != ACTION_TYPE_GROUP_LOCK &&
                    (action->group.flags & XkbSA_ClearLocks)) ?
                   ",clearLocks" : "",
-                  (action->type != XkbSA_LockGroup &&
+                  (action->type != ACTION_TYPE_GROUP_LOCK &&
                    (action->group.flags & XkbSA_LatchToLock)) ?
                   ",latchToLock" : "",
                   suffix);
         break;
 
-    case XkbSA_Terminate:
+    case ACTION_TYPE_TERMINATE:
         write_buf(buf, "%s%s()%s", prefix, type, suffix);
         break;
 
-    case XkbSA_MovePtr:
+    case ACTION_TYPE_PTR_MOVE:
         write_buf(buf, "%s%s(x=%s%d,y=%s%d%s)%s", prefix, type,
                   (!(action->ptr.flags & XkbSA_MoveAbsoluteX) &&
                    action->ptr.x >= 0) ? "+" : "",
@@ -434,7 +434,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
                   suffix);
         break;
 
-    case XkbSA_LockPtrBtn:
+    case ACTION_TYPE_PTR_LOCK:
         switch (action->btn.flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
         case XkbSA_LockNoUnlock:
             args = ",affect=lock";
@@ -452,7 +452,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
             args = ",affect=both";
             break;
         }
-    case XkbSA_PtrBtn:
+    case ACTION_TYPE_PTR_BUTTON:
         write_buf(buf, "%s%s(button=", prefix, type);
         if (action->btn.button > 0 && action->btn.button <= 5)
             write_buf(buf, "%d", action->btn.button);
@@ -465,7 +465,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
         write_buf(buf, ")%s", suffix);
         break;
 
-    case XkbSA_SetPtrDflt:
+    case ACTION_TYPE_PTR_DEFAULT:
         write_buf(buf, "%s%s(", prefix, type);
         if (action->dflt.affect == XkbSA_AffectDfltBtn)
             write_buf(buf, "affect=button,button=%s%d",
@@ -475,7 +475,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
         write_buf(buf, ")%s", suffix);
         break;
 
-    case XkbSA_SwitchScreen:
+    case ACTION_TYPE_SWITCH_VT:
         write_buf(buf, "%s%s(screen=%s%d,%ssame)%s", prefix, type,
                   (!(action->screen.flags & XkbSA_SwitchAbsolute) &&
                    action->screen.screen >= 0) ? "+" : "",
@@ -484,15 +484,13 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
                   suffix);
         break;
 
-    /* Deprecated actions below here */
-    case XkbSA_SetControls:
-    case XkbSA_LockControls:
+    case ACTION_TYPE_CTRL_SET:
+    case ACTION_TYPE_CTRL_LOCK:
         write_buf(buf, "%s%s(controls=%s)%s", prefix, type,
                   get_control_mask_text(action->ctrls.ctrls), suffix);
         break;
 
-    case XkbSA_NoAction:
-        /* XXX TODO */
+    case ACTION_TYPE_NONE:
         write_buf(buf, "%sNoAction()%s", prefix, suffix);
         break;
 
diff --git a/src/state.c b/src/state.c
index bc77a9c..99ad6dc 100644
--- a/src/state.c
+++ b/src/state.c
@@ -106,7 +106,7 @@ struct xkb_state {
     struct xkb_keymap *keymap;
 };
 
-static const union xkb_action fake = { .type = XkbSA_NoAction };
+static const union xkb_action fake = { .type = ACTION_TYPE_NONE };
 
 static const union xkb_action *
 xkb_key_get_action(struct xkb_state *state, xkb_keycode_t kc)
@@ -333,6 +333,24 @@ enum xkb_key_latch_state {
     LATCH_PENDING,
 };
 
+static bool
+xkb_action_breaks_latch(const union xkb_action *action)
+{
+    switch (action->type) {
+    case ACTION_TYPE_NONE:
+    case ACTION_TYPE_PTR_BUTTON:
+    case ACTION_TYPE_PTR_LOCK:
+    case ACTION_TYPE_CTRL_SET:
+    case ACTION_TYPE_CTRL_LOCK:
+    case ACTION_TYPE_KEY_REDIRECT:
+    case ACTION_TYPE_SWITCH_VT:
+    case ACTION_TYPE_TERMINATE:
+        return true;
+    default:
+        return false;
+    }
+}
+
 static int
 xkb_filter_mod_latch_func(struct xkb_filter *filter, xkb_keycode_t kc,
                           enum xkb_key_direction direction)
@@ -345,17 +363,17 @@ xkb_filter_mod_latch_func(struct xkb_filter *filter, xkb_keycode_t kc,
          * or promote it to a lock or plain base set if it's the same
          * modifier. */
         const union xkb_action *action = xkb_key_get_action(filter->state, kc);
-        if (action->type == XkbSA_LatchMods &&
+        if (action->type == ACTION_TYPE_MOD_LATCH &&
             action->mods.flags == filter->action.mods.flags &&
             action->mods.mods.mask == filter->action.mods.mods.mask) {
             filter->action = *action;
             if (filter->action.mods.flags & XkbSA_LatchToLock) {
-                filter->action.type = XkbSA_LockMods;
+                filter->action.type = ACTION_TYPE_MOD_LOCK;
                 filter->func = xkb_filter_mod_lock_func;
                 filter->state->locked_mods |= filter->action.mods.mods.mask;
             }
             else {
-                filter->action.type = XkbSA_SetMods;
+                filter->action.type = ACTION_TYPE_MOD_SET;
                 filter->func = xkb_filter_mod_set_func;
                 filter->state->set_mods = filter->action.mods.mods.mask;
             }
@@ -364,7 +382,7 @@ xkb_filter_mod_latch_func(struct xkb_filter *filter, xkb_keycode_t kc,
             /* XXX beep beep! */
             return 0;
         }
-        else if (((1 << action->type) & XkbSA_BreakLatch)) {
+        else if (xkb_action_breaks_latch(action)) {
             /* XXX: This may be totally broken, we might need to break the
              *      latch in the next run after this press? */
             filter->state->latched_mods &= ~filter->action.mods.mods.mask;
@@ -456,26 +474,28 @@ xkb_filter_apply_all(struct xkb_state *state, xkb_keycode_t kc,
 
     act = xkb_key_get_action(state, kc);
     switch (act->type) {
-    case XkbSA_SetMods:
+    case ACTION_TYPE_MOD_SET:
         send = xkb_filter_mod_set_new(state, kc, act);
         break;
-    case XkbSA_LatchMods:
+    case ACTION_TYPE_MOD_LATCH:
         send = xkb_filter_mod_latch_new(state, kc, act);
         break;
-    case XkbSA_LockMods:
+    case ACTION_TYPE_MOD_LOCK:
         send = xkb_filter_mod_lock_new(state, kc, act);
         break;
-    case XkbSA_SetGroup:
+    case ACTION_TYPE_GROUP_SET:
         send = xkb_filter_group_set_new(state, kc, act);
         break;
 #if 0
-    case XkbSA_LatchGroup:
+    case ACTION_TYPE_GROUP_LATCH:
         send = xkb_filter_mod_latch_new(state, key, act);
         break;
 #endif
-    case XkbSA_LockGroup:
+    case ACTION_TYPE_GROUP_LOCK:
         send = xkb_filter_group_lock_new(state, kc, act);
         break;
+    default:
+        break;
     }
 
     return;
diff --git a/src/text.c b/src/text.c
index 3c10794..dca89e3 100644
--- a/src/text.c
+++ b/src/text.c
@@ -156,48 +156,48 @@ const LookupEntry useModMapValueNames[] = {
 };
 
 const LookupEntry actionTypeNames[] = {
-    { "NoAction", XkbSA_NoAction },
-    { "SetMods", XkbSA_SetMods },
-    { "LatchMods", XkbSA_LatchMods },
-    { "LockMods", XkbSA_LockMods },
-    { "SetGroup", XkbSA_SetGroup },
-    { "LatchGroup", XkbSA_LatchGroup },
-    { "LockGroup", XkbSA_LockGroup },
-    { "MovePtr", XkbSA_MovePtr },
-    { "MovePointer", XkbSA_MovePtr },
-    { "PtrBtn", XkbSA_PtrBtn },
-    { "PointerButton", XkbSA_PtrBtn },
-    { "LockPtrBtn", XkbSA_LockPtrBtn },
-    { "LockPtrButton", XkbSA_LockPtrBtn },
-    { "LockPointerButton", XkbSA_LockPtrBtn },
-    { "LockPointerBtn", XkbSA_LockPtrBtn },
-    { "SetPtrDflt", XkbSA_SetPtrDflt },
-    { "SetPointerDefault", XkbSA_SetPtrDflt },
-    { "Terminate", XkbSA_Terminate },
-    { "TerminateServer", XkbSA_Terminate },
-    { "SwitchScreen", XkbSA_SwitchScreen },
-    { "SetControls", XkbSA_SetControls },
-    { "LockControls", XkbSA_LockControls },
-    { "RedirectKey", XkbSA_RedirectKey },
-    { "Redirect", XkbSA_RedirectKey },
-    { "Private", PrivateAction },
+    { "NoAction", ACTION_TYPE_NONE },
+    { "SetMods", ACTION_TYPE_MOD_SET },
+    { "LatchMods", ACTION_TYPE_MOD_LATCH },
+    { "LockMods", ACTION_TYPE_MOD_LOCK },
+    { "SetGroup", ACTION_TYPE_GROUP_SET },
+    { "LatchGroup", ACTION_TYPE_GROUP_LATCH },
+    { "LockGroup", ACTION_TYPE_GROUP_LOCK },
+    { "MovePtr", ACTION_TYPE_PTR_MOVE },
+    { "MovePointer", ACTION_TYPE_PTR_MOVE },
+    { "PtrBtn", ACTION_TYPE_PTR_BUTTON },
+    { "PointerButton", ACTION_TYPE_PTR_BUTTON },
+    { "LockPtrBtn", ACTION_TYPE_PTR_LOCK },
+    { "LockPtrButton", ACTION_TYPE_PTR_LOCK },
+    { "LockPointerButton", ACTION_TYPE_PTR_LOCK },
+    { "LockPointerBtn", ACTION_TYPE_PTR_LOCK },
+    { "SetPtrDflt", ACTION_TYPE_PTR_DEFAULT },
+    { "SetPointerDefault", ACTION_TYPE_PTR_DEFAULT },
+    { "Terminate", ACTION_TYPE_TERMINATE },
+    { "TerminateServer", ACTION_TYPE_TERMINATE },
+    { "SwitchScreen", ACTION_TYPE_SWITCH_VT },
+    { "SetControls", ACTION_TYPE_CTRL_SET },
+    { "LockControls", ACTION_TYPE_CTRL_LOCK },
+    { "RedirectKey", ACTION_TYPE_KEY_REDIRECT },
+    { "Redirect", ACTION_TYPE_KEY_REDIRECT },
+    { "Private", ACTION_TYPE_PRIVATE },
     /* deprecated actions below here - unused */
-    { "ISOLock", XkbSA_NoAction },
-    { "ActionMessage", XkbSA_NoAction },
-    { "MessageAction", XkbSA_NoAction },
-    { "Message", XkbSA_NoAction },
-    { "DeviceBtn", XkbSA_NoAction },
-    { "DevBtn", XkbSA_NoAction },
-    { "DevButton", XkbSA_NoAction },
-    { "DeviceButton", XkbSA_NoAction },
-    { "LockDeviceBtn", XkbSA_NoAction },
-    { "LockDevBtn", XkbSA_NoAction },
-    { "LockDevButton", XkbSA_NoAction },
-    { "LockDeviceButton", XkbSA_NoAction },
-    { "DeviceValuator", XkbSA_NoAction },
-    { "DevVal", XkbSA_NoAction },
-    { "DeviceVal", XkbSA_NoAction },
-    { "DevValuator", XkbSA_NoAction },
+    { "ISOLock", ACTION_TYPE_NONE },
+    { "ActionMessage", ACTION_TYPE_NONE },
+    { "MessageAction", ACTION_TYPE_NONE },
+    { "Message", ACTION_TYPE_NONE },
+    { "DeviceBtn", ACTION_TYPE_NONE },
+    { "DevBtn", ACTION_TYPE_NONE },
+    { "DevButton", ACTION_TYPE_NONE },
+    { "DeviceButton", ACTION_TYPE_NONE },
+    { "LockDeviceBtn", ACTION_TYPE_NONE },
+    { "LockDevBtn", ACTION_TYPE_NONE },
+    { "LockDevButton", ACTION_TYPE_NONE },
+    { "LockDeviceButton", ACTION_TYPE_NONE },
+    { "DeviceValuator", ACTION_TYPE_NONE },
+    { "DevVal", ACTION_TYPE_NONE },
+    { "DeviceVal", ACTION_TYPE_NONE },
+    { "DevValuator", ACTION_TYPE_NONE },
     { NULL, 0 },
 };
 
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 36554bb..c79e64a 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -132,44 +132,65 @@ struct xkb_component_names {
     char *symbols;
 };
 
+enum xkb_action_type {
+    ACTION_TYPE_NONE = 0,
+    ACTION_TYPE_MOD_SET,
+    ACTION_TYPE_MOD_LATCH,
+    ACTION_TYPE_MOD_LOCK,
+    ACTION_TYPE_GROUP_SET,
+    ACTION_TYPE_GROUP_LATCH,
+    ACTION_TYPE_GROUP_LOCK,
+    ACTION_TYPE_PTR_MOVE,
+    ACTION_TYPE_PTR_BUTTON,
+    ACTION_TYPE_PTR_LOCK,
+    ACTION_TYPE_PTR_DEFAULT,
+    ACTION_TYPE_TERMINATE,
+    ACTION_TYPE_SWITCH_VT,
+    ACTION_TYPE_CTRL_SET,
+    ACTION_TYPE_CTRL_LOCK,
+    ACTION_TYPE_KEY_REDIRECT,
+    ACTION_TYPE_PRIVATE,
+    ACTION_TYPE_LAST
+};
+
 struct xkb_mods {
     xkb_mod_mask_t mods;       /* original real+virtual mods in definition */
     xkb_mod_mask_t mask;       /* computed effective mask */
 };
 
 struct xkb_mod_action {
-    uint8_t type;
+    enum xkb_action_type type;
     uint8_t flags;
     struct xkb_mods mods;
 };
 
 struct xkb_group_action {
-    uint8_t type;
+    enum xkb_action_type type;
     uint8_t flags;
     int32_t group;
 };
 
 struct xkb_controls_action {
-    uint8_t type;
+    enum xkb_action_type type;
     uint8_t flags;
     uint32_t ctrls;
 };
 
 struct xkb_pointer_default_action {
-    uint8_t type;
+    enum xkb_action_type type;
     uint8_t flags;
     uint8_t affect;
     int8_t value;
 };
 
 struct xkb_switch_screen_action {
-    uint8_t type;
+    enum xkb_action_type type;
     uint8_t flags;
     int8_t screen;
 };
 
 struct xkb_redirect_key_action {
-    uint8_t type;
+    enum xkb_action_type type;
     xkb_keycode_t new_kc;
     uint8_t mods_mask;
     uint8_t mods;
@@ -178,28 +199,26 @@ struct xkb_redirect_key_action {
 };
 
 struct xkb_pointer_action {
-    uint8_t type;
+    enum xkb_action_type type;
     uint8_t flags;
     int16_t x;
     int16_t y;
 };
 
 struct xkb_pointer_button_action {
-    uint8_t type;
+    enum xkb_action_type type;
     uint8_t flags;
     uint8_t count;
     int8_t button;
 };
 
-/* Instead of non-sequential XkbSA_XFree86Private. */
-#define PrivateAction (XkbSA_LastAction + 1)
-
 struct xkb_private_action {
-    uint8_t type;
+    enum xkb_action_type type;
     uint8_t data[7];
 };
 
 union xkb_action {
+    enum xkb_action_type type;
     struct xkb_mod_action mods;
     struct xkb_group_action group;
     struct xkb_controls_action ctrls;
@@ -209,7 +228,6 @@ union xkb_action {
     struct xkb_pointer_action ptr;
     struct xkb_pointer_button_action btn;
     struct xkb_private_action priv;
-    unsigned char type;
 };
 
 struct xkb_kt_map_entry {
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 617ad3b..1ef9498 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -81,15 +81,15 @@ NewActionsInfo(void)
         return NULL;
 
     /* This includes PrivateAction. */
-    for (type = 0; type < XkbSA_NumActions + 1; type++)
+    for (type = 0; type < ACTION_TYPE_LAST; type++)
         info->actions[type].type = type;
 
     /* Apply some "factory defaults". */
 
     /* Increment default button. */
-    info->actions[XkbSA_SetPtrDflt].dflt.affect = XkbSA_AffectDfltBtn;
-    info->actions[XkbSA_SetPtrDflt].dflt.flags = 0;
-    info->actions[XkbSA_SetPtrDflt].dflt.value = 1;
+    info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.affect = XkbSA_AffectDfltBtn;
+    info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.flags = 0;
+    info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.value = 1;
 
     return info;
 }
@@ -158,7 +158,7 @@ fieldText(enum action_field field)
 /***====================================================================***/
 
 static inline bool
-ReportMismatch(struct xkb_keymap *keymap, unsigned action,
+ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action,
                enum action_field field, const char *type)
 {
     log_err(keymap->ctx,
@@ -169,7 +169,7 @@ ReportMismatch(struct xkb_keymap *keymap, unsigned action,
 }
 
 static inline bool
-ReportIllegal(struct xkb_keymap *keymap, unsigned action,
+ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action,
               enum action_field field)
 {
     log_err(keymap->ctx,
@@ -180,7 +180,7 @@ ReportIllegal(struct xkb_keymap *keymap, unsigned action,
 }
 
 static inline bool
-ReportActionNotArray(struct xkb_keymap *keymap, unsigned action,
+ReportActionNotArray(struct xkb_keymap *keymap, enum xkb_action_type action,
                      enum action_field field)
 {
     log_err(keymap->ctx,
@@ -191,7 +191,7 @@ ReportActionNotArray(struct xkb_keymap *keymap, unsigned action,
 }
 
 static inline bool
-ReportNotFound(struct xkb_keymap *keymap, unsigned action,
+ReportNotFound(struct xkb_keymap *keymap, enum xkb_action_type action,
                enum action_field field, const char *what, const char *bad)
 {
     log_err(keymap->ctx,
@@ -211,7 +211,7 @@ HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
 }
 
 static bool
-CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action,
+CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action,
                     enum action_field field, const ExprDef * value,
                     unsigned *flags_inout)
 {
@@ -237,7 +237,7 @@ CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action,
 }
 
 static bool
-CheckModifierField(struct xkb_keymap *keymap, unsigned action,
+CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
                    const ExprDef *value, unsigned *flags_inout,
                    xkb_mod_mask_t *mods_rtrn)
 {
@@ -521,7 +521,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
         act->button = btn;
         return true;
     }
-    else if (action->type == XkbSA_LockPtrBtn &&
+    else if (action->type == ACTION_TYPE_PTR_LOCK &&
              field == ACTION_FIELD_AFFECT) {
         unsigned int val;
 
@@ -717,7 +717,7 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
         int type;
 
         if (!ExprResolveInteger(keymap->ctx, value, &type))
-            return ReportMismatch(keymap, PrivateAction, field, "integer");
+            return ReportMismatch(keymap, ACTION_TYPE_PRIVATE, field, "integer");
 
         if (type < 0 || type > 255) {
             log_err(keymap->ctx,
@@ -783,7 +783,7 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
         }
     }
 
-    return ReportIllegal(keymap, PrivateAction, field);
+    return ReportIllegal(keymap, ACTION_TYPE_NONE, field);
 }
 
 typedef bool (*actionHandler)(struct xkb_keymap *keymap,
@@ -792,23 +792,23 @@ typedef bool (*actionHandler)(struct xkb_keymap *keymap,
                               const ExprDef *array_ndx,
                               const ExprDef *value);
 
-static const actionHandler handleAction[XkbSA_NumActions + 1] = {
-    [XkbSA_NoAction] = HandleNoAction,
-    [XkbSA_SetMods] = HandleSetLatchMods,
-    [XkbSA_LatchMods] = HandleSetLatchMods,
-    [XkbSA_LockMods] = HandleLockMods,
-    [XkbSA_SetGroup] = HandleSetLatchGroup,
-    [XkbSA_LatchGroup] = HandleSetLatchGroup,
-    [XkbSA_LockGroup] = HandleLockGroup,
-    [XkbSA_MovePtr] = HandleMovePtr,
-    [XkbSA_PtrBtn] = HandlePtrBtn,
-    [XkbSA_LockPtrBtn] = HandlePtrBtn,
-    [XkbSA_SetPtrDflt] = HandleSetPtrDflt,
-    [XkbSA_Terminate] = HandleNoAction,
-    [XkbSA_SwitchScreen] = HandleSwitchScreen,
-    [XkbSA_SetControls] = HandleSetLockControls,
-    [XkbSA_LockControls] = HandleSetLockControls,
-    [PrivateAction] = HandlePrivate,
+static const actionHandler handleAction[ACTION_TYPE_LAST] = {
+    [ACTION_TYPE_NONE] = HandleNoAction,
+    [ACTION_TYPE_MOD_SET] = HandleSetLatchMods,
+    [ACTION_TYPE_MOD_LATCH] = HandleSetLatchMods,
+    [ACTION_TYPE_MOD_LOCK] = HandleLockMods,
+    [ACTION_TYPE_GROUP_SET] = HandleSetLatchGroup,
+    [ACTION_TYPE_GROUP_LATCH] = HandleSetLatchGroup,
+    [ACTION_TYPE_GROUP_LOCK] = HandleLockGroup,
+    [ACTION_TYPE_PTR_MOVE] = HandleMovePtr,
+    [ACTION_TYPE_PTR_BUTTON] = HandlePtrBtn,
+    [ACTION_TYPE_PTR_LOCK] = HandlePtrBtn,
+    [ACTION_TYPE_PTR_DEFAULT] = HandleSetPtrDflt,
+    [ACTION_TYPE_TERMINATE] = HandleNoAction,
+    [ACTION_TYPE_SWITCH_VT] = HandleSwitchScreen,
+    [ACTION_TYPE_CTRL_SET] = HandleSetLockControls,
+    [ACTION_TYPE_CTRL_LOCK] = HandleSetLockControls,
+    [ACTION_TYPE_PRIVATE] = HandlePrivate,
 };
 
 /***====================================================================***/
diff --git a/src/xkbcomp/action.h b/src/xkbcomp/action.h
index cbfb261..74194a1 100644
--- a/src/xkbcomp/action.h
+++ b/src/xkbcomp/action.h
@@ -33,7 +33,7 @@
  * modified within the files (see calls to SetActionField).
  */
 typedef struct {
-    union xkb_action actions[XkbSA_NumActions + 1];
+    union xkb_action actions[ACTION_TYPE_LAST];
 } ActionsInfo;
 
 ActionsInfo *
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 6bfc635..5ae80ab 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -240,7 +240,7 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id,
     info->dflt.interp.flags = 0;
     info->dflt.interp.virtual_mod = XKB_MOD_INVALID;
     memset(&info->dflt.interp.act, 0, sizeof(info->dflt.interp.act));
-    info->dflt.interp.act.type = XkbSA_NoAction;
+    info->dflt.interp.act.type = ACTION_TYPE_NONE;
     memset(&info->ledDflt, 0, sizeof(info->ledDflt));
     info->ledDflt.file_id = file_id;
     info->ledDflt.merge = MERGE_OVERRIDE;
@@ -258,7 +258,7 @@ ClearCompatInfo(CompatInfo *info)
     info->dflt.interp.flags = 0;
     info->dflt.interp.virtual_mod = XKB_MOD_INVALID;
     memset(&info->dflt.interp.act, 0, sizeof(info->dflt.interp.act));
-    info->dflt.interp.act.type = XkbSA_NoAction;
+    info->dflt.interp.act.type = ACTION_TYPE_NONE;
     memset(&info->ledDflt, 0, sizeof(info->ledDflt));
     darray_free(info->interps);
     darray_free(info->leds);
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
index 5875ca7..aa113fd 100644
--- a/src/xkbcomp/keymap.c
+++ b/src/xkbcomp/keymap.c
@@ -50,9 +50,9 @@ UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act,
     struct xkb_mods *mods;
 
     switch (act->type) {
-    case XkbSA_SetMods:
-    case XkbSA_LatchMods:
-    case XkbSA_LockMods:
+    case ACTION_TYPE_MOD_SET:
+    case ACTION_TYPE_MOD_LATCH:
+    case ACTION_TYPE_MOD_LOCK:
         flags = act->mods.flags;
         mods = &act->mods.mods;
         break;
@@ -167,7 +167,7 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key)
                     vmodmask |= (1 << interp->virtual_mod);
             }
 
-            if (interp->act.type != XkbSA_NoAction) {
+            if (interp->act.type != ACTION_TYPE_NONE) {
                 if (!key->actions) {
                     key->actions = calloc(key->num_groups * key->width,
                                           sizeof(*key->actions));
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index c5edbab..f9cbe92 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -320,11 +320,11 @@ MergeKeyGroups(SymbolsInfo * info,
             if (!darray_empty(into->acts[group]))
                 toAct = &darray_item(into->acts[group], i);
 
-            if (((fromAct == NULL) || (fromAct->type == XkbSA_NoAction))
+            if (((fromAct == NULL) || (fromAct->type == ACTION_TYPE_NONE))
                 && (toAct != NULL)) {
                 darray_item(resultActs, i) = *toAct;
             }
-            else if (((toAct == NULL) || (toAct->type == XkbSA_NoAction))
+            else if (((toAct == NULL) || (toAct->type == ACTION_TYPE_NONE))
                      && (fromAct != NULL)) {
                 darray_item(resultActs, i) = *fromAct;
             }
@@ -1843,7 +1843,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
                     if (tmp < keyi->numLevels[i])
                         key->actions[tmp] = darray_item(keyi->acts[i], tmp);
                     else
-                        key->actions[tmp].type = XkbSA_NoAction;
+                        key->actions[tmp].type = ACTION_TYPE_NONE;
                 }
             }
         }