action: s/hndlrType/handler_type
[platform/upstream/libxkbcommon.git] / src / xkbcomp / action.c
index 4a8d20d..22762c6 100644 (file)
  *
  ********************************************************/
 
+/*
+ * Copyright © 2012 Intel Corporation
+ * Copyright © 2012 Ran Benita <ran234@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Daniel Stone <daniel@fooishbar.org>
+ *         Ran Benita <ran234@gmail.com>
+ */
+
 #include "xkbcomp-priv.h"
 #include "text.h"
 #include "expr.h"
 #include "action.h"
 #include "keycodes.h"
 
-#define PrivateAction (XkbSA_LastAction + 1)
-
 static const ExprDef constTrue = {
     .common = { .type = STMT_EXPR, .next = NULL },
     .op = EXPR_VALUE,
@@ -72,70 +97,34 @@ enum action_field {
     ACTION_FIELD_MODS_TO_CLEAR,
 };
 
-struct _ActionInfo {
-    unsigned action;
-    enum action_field field;
-    ExprDef *array_ndx;
-    ExprDef *value;
-    struct _ActionInfo *next;
-};
+ActionsInfo *
+NewActionsInfo(void)
+{
+    unsigned type;
+    ActionsInfo *info;
+
+    info = calloc(1, sizeof(*info));
+    if (!info)
+        return NULL;
+
+    for (type = 0; type < _ACTION_TYPE_NUM_ENTRIES; type++)
+        info->actions[type].type = type;
+
+    /* Apply some "factory defaults". */
+
+    /* Increment default button. */
+    info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.flags = 0;
+    info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.value = 1;
+
+    return info;
+}
 
 void
-FreeActionInfo(ActionInfo *info)
+FreeActionsInfo(ActionsInfo *info)
 {
-    ActionInfo *next;
-    while (info) {
-        next = info->next;
-        free(info);
-        info = next;
-    }
+    free(info);
 }
 
-static const LookupEntry actionStrings[] = {
-    { "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     },
-    { "lockpointerbutton", XkbSA_LockPtrBtn     },
-    { "lockptrbutton",     XkbSA_LockPtrBtn     },
-    { "lockpointerbtn",    XkbSA_LockPtrBtn     },
-    { "setptrdflt",        XkbSA_SetPtrDflt     },
-    { "setpointerdefault", XkbSA_SetPtrDflt     },
-    { "isolock",           XkbSA_ISOLock        },
-    { "terminate",         XkbSA_Terminate      },
-    { "terminateserver",   XkbSA_Terminate      },
-    { "switchscreen",      XkbSA_SwitchScreen   },
-    { "setcontrols",       XkbSA_SetControls    },
-    { "lockcontrols",      XkbSA_LockControls   },
-    { "actionmessage",     XkbSA_ActionMessage  },
-    { "messageaction",     XkbSA_ActionMessage  },
-    { "message",           XkbSA_ActionMessage  },
-    { "redirect",          XkbSA_RedirectKey    },
-    { "redirectkey",       XkbSA_RedirectKey    },
-    { "devbtn",            XkbSA_DeviceBtn      },
-    { "devicebtn",         XkbSA_DeviceBtn      },
-    { "devbutton",         XkbSA_DeviceBtn      },
-    { "devicebutton",      XkbSA_DeviceBtn      },
-    { "lockdevbtn",        XkbSA_DeviceBtn      },
-    { "lockdevicebtn",     XkbSA_LockDeviceBtn  },
-    { "lockdevbutton",     XkbSA_LockDeviceBtn  },
-    { "lockdevicebutton",  XkbSA_LockDeviceBtn  },
-    { "devval",            XkbSA_DeviceValuator },
-    { "deviceval",         XkbSA_DeviceValuator },
-    { "devvaluator",       XkbSA_DeviceValuator },
-    { "devicevaluator",    XkbSA_DeviceValuator },
-    { "private",           PrivateAction        },
-    { NULL,                0                    }
-};
-
 static const LookupEntry fieldStrings[] = {
     { "clearLocks",       ACTION_FIELD_CLEAR_LOCKS   },
     { "latchToLock",      ACTION_FIELD_LATCH_TO_LOCK },
@@ -174,58 +163,27 @@ static const LookupEntry fieldStrings[] = {
 };
 
 static bool
-stringToValue(const LookupEntry tab[], const char *string,
-              unsigned int *value_rtrn)
-{
-    const LookupEntry *entry;
-
-    if (!string)
-        return false;
-
-    for (entry = tab; entry->name; entry++) {
-        if (istreq(entry->name, string)) {
-            *value_rtrn = entry->value;
-            return true;
-        }
-    }
-
-    return false;
-}
-
-static const char *
-valueToString(const LookupEntry tab[], unsigned int value)
-{
-    const LookupEntry *entry;
-
-    for (entry = tab; entry->name; entry++)
-        if (entry->value == value)
-            return entry->name;
-
-    return "unknown";
-}
-
-static bool
 stringToAction(const char *str, unsigned *type_rtrn)
 {
-    return stringToValue(actionStrings, str, type_rtrn);
+    return LookupString(actionTypeNames, str, type_rtrn);
 }
 
 static bool
 stringToField(const char *str, enum action_field *field_rtrn)
 {
-    return stringToValue(fieldStrings, str, field_rtrn);
+    return LookupString(fieldStrings, str, field_rtrn);
 }
 
 static const char *
 fieldText(enum action_field field)
 {
-    return valueToString(fieldStrings, field);
+    return LookupValue(fieldStrings, 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,
@@ -236,7 +194,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,
@@ -247,7 +205,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,
@@ -258,7 +216,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,
@@ -274,21 +232,21 @@ HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
                const ExprDef *value)
 
 {
-    return ReportIllegal(keymap, action->type, field);
+    return true;
 }
 
 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)
+                    enum xkb_action_flags *flags_inout)
 {
-    unsigned tmp;
+    enum xkb_action_flags tmp;
     bool result;
 
     if (field == ACTION_FIELD_CLEAR_LOCKS)
-        tmp = XkbSA_ClearLocks;
+        tmp = ACTION_LOCK_CLEAR;
     else if (field == ACTION_FIELD_LATCH_TO_LOCK)
-        tmp = XkbSA_LatchToLock;
+        tmp = ACTION_LATCH_TO_LOCK;
     else
         return false;           /* WSGO! */
 
@@ -304,8 +262,8 @@ CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action,
 }
 
 static bool
-CheckModifierField(struct xkb_keymap *keymap, unsigned action,
-                   const ExprDef *value, unsigned *flags_inout,
+CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
+                   const ExprDef *value, enum xkb_action_flags *flags_inout,
                    xkb_mod_mask_t *mods_rtrn)
 {
     if (value->op == EXPR_IDENT) {
@@ -315,16 +273,16 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action,
                        istreq(valStr, "modmapmods"))) {
 
             *mods_rtrn = 0;
-            *flags_inout |= XkbSA_UseModMapMods;
+            *flags_inout |= ACTION_MODS_LOOKUP_MODMAP;
             return true;
         }
     }
 
-    if (!ExprResolveVModMask(keymap, value, mods_rtrn))
+    if (!ExprResolveModMask(keymap, value, MOD_BOTH, mods_rtrn))
         return ReportMismatch(keymap, action,
                               ACTION_FIELD_MODIFIERS, "modifier mask");
 
-    *flags_inout &= ~XkbSA_UseModMapMods;
+    *flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP;
     return true;
 }
 
@@ -334,8 +292,7 @@ HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
                    const ExprDef *value)
 {
     struct xkb_mod_action *act = &action->mods;
-    unsigned rtrn;
-    unsigned t1;
+    enum xkb_action_flags rtrn, t1;
     xkb_mod_mask_t t2;
 
     if (array_ndx != NULL) {
@@ -381,7 +338,7 @@ HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
                const ExprDef *value)
 {
     struct xkb_mod_action *act = &action->mods;
-    unsigned t1;
+    enum xkb_action_flags t1;
     xkb_mod_mask_t t2;
 
     if (array_ndx && field == ACTION_FIELD_MODIFIERS)
@@ -406,17 +363,17 @@ HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
 
 static bool
 CheckGroupField(struct xkb_keymap *keymap, unsigned action,
-                const ExprDef *value, unsigned *flags_inout,
-                xkb_group_index_t *grp_rtrn)
+                const ExprDef *value, enum xkb_action_flags *flags_inout,
+                xkb_layout_index_t *grp_rtrn)
 {
     const ExprDef *spec;
 
     if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
-        *flags_inout &= ~XkbSA_GroupAbsolute;
+        *flags_inout &= ~ACTION_ABSOLUTE_SWITCH;
         spec = value->value.child;
     }
     else {
-        *flags_inout |= XkbSA_GroupAbsolute;
+        *flags_inout |= ACTION_ABSOLUTE_SWITCH;
         spec = value;
     }
 
@@ -438,9 +395,8 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
                     const ExprDef *value)
 {
     struct xkb_group_action *act = &action->group;
-    unsigned rtrn;
-    unsigned t1;
-    xkb_group_index_t t2;
+    enum xkb_action_flags rtrn, t1;
+    xkb_layout_index_t t2;
 
     if (array_ndx != NULL) {
         switch (field) {
@@ -486,8 +442,8 @@ HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action,
                 const ExprDef *value)
 {
     struct xkb_group_action *act = &action->group;
-    unsigned t1;
-    xkb_group_index_t t2;
+    enum xkb_action_flags t1;
+    xkb_layout_index_t t2;
 
     if ((array_ndx != NULL) && (field == ACTION_FIELD_GROUP))
         return ReportActionNotArray(keymap, action->type, field);
@@ -527,12 +483,12 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
 
         if (field == ACTION_FIELD_X) {
             if (absolute)
-                act->flags |= XkbSA_MoveAbsoluteX;
+                act->flags |= ACTION_ABSOLUTE_X;
             act->x = val;
         }
         else {
             if (absolute)
-                act->flags |= XkbSA_MoveAbsoluteY;
+                act->flags |= ACTION_ABSOLUTE_Y;
             act->y = val;
         }
 
@@ -545,9 +501,9 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
             return ReportMismatch(keymap, action->type, field, "boolean");
 
         if (set)
-            act->flags &= ~XkbSA_NoAcceleration;
+            act->flags &= ~ACTION_NO_ACCEL;
         else
-            act->flags |= XkbSA_NoAcceleration;
+            act->flags |= ACTION_NO_ACCEL;
     }
 
     return ReportIllegal(keymap, action->type, field);
@@ -555,9 +511,9 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
 
 static const LookupEntry lockWhich[] = {
     { "both", 0 },
-    { "lock", XkbSA_LockNoUnlock },
-    { "neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock) },
-    { "unlock", XkbSA_LockNoLock },
+    { "lock", ACTION_LOCK_NO_UNLOCK },
+    { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) },
+    { "unlock", ACTION_LOCK_NO_LOCK },
     { NULL, 0 }
 };
 
@@ -588,9 +544,9 @@ 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;
+        enum xkb_action_flags val;
 
         if (array_ndx)
             return ReportActionNotArray(keymap, action->type, field);
@@ -599,7 +555,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
             return ReportMismatch(keymap, action->type, field,
                                   "lock or unlock");
 
-        act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
+        act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
         act->flags |= val;
         return true;
     }
@@ -627,9 +583,9 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
 }
 
 static const LookupEntry ptrDflts[] = {
-    { "dfltbtn", XkbSA_AffectDfltBtn },
-    { "defaultbutton", XkbSA_AffectDfltBtn },
-    { "button", XkbSA_AffectDfltBtn },
+    { "dfltbtn", 1 },
+    { "defaultbutton", 1 },
+    { "button", 1 },
     { NULL, 0 }
 };
 
@@ -649,7 +605,6 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
         if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
             return ReportMismatch(keymap, action->type, field,
                                   "pointer component");
-        act->affect = val;
         return true;
     }
     else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) {
@@ -660,11 +615,11 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
             return ReportActionNotArray(keymap, action->type, field);
 
         if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
-            act->flags &= ~XkbSA_DfltBtnAbsolute;
+            act->flags &= ~ACTION_ABSOLUTE_SWITCH;
             button = value->value.child;
         }
         else {
-            act->flags |= XkbSA_DfltBtnAbsolute;
+            act->flags |= ACTION_ABSOLUTE_SWITCH;
             button = value;
         }
 
@@ -692,73 +647,6 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
     return ReportIllegal(keymap, action->type, field);
 }
 
-static const LookupEntry isoNames[] = {
-    { "mods", XkbSA_ISONoAffectMods },
-    { "modifiers", XkbSA_ISONoAffectMods },
-    { "group", XkbSA_ISONoAffectGroup },
-    { "groups", XkbSA_ISONoAffectGroup },
-    { "ptr", XkbSA_ISONoAffectPtr },
-    { "pointer", XkbSA_ISONoAffectPtr },
-    { "ctrls", XkbSA_ISONoAffectCtrls },
-    { "controls", XkbSA_ISONoAffectCtrls },
-    { "all", ~((unsigned) 0) },
-    { "none", 0 },
-    { NULL, 0 },
-};
-
-static bool
-HandleISOLock(struct xkb_keymap *keymap, union xkb_action *action,
-              enum action_field field, const ExprDef *array_ndx,
-              const ExprDef *value)
-{
-    struct xkb_iso_action *act = &action->iso;
-
-    if (field == ACTION_FIELD_MODIFIERS) {
-        unsigned flags;
-        xkb_mod_mask_t mods;
-
-        if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
-
-        flags = act->flags;
-        if (!CheckModifierField(keymap, action->type, value, &flags, &mods))
-            return false;
-
-        act->flags = flags & (~XkbSA_ISODfltIsGroup);
-        act->mods.mods = mods;
-        return true;
-    }
-    else if (field == ACTION_FIELD_GROUP) {
-        xkb_group_index_t group;
-        unsigned flags;
-
-        if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
-
-        flags = act->flags;
-        if (!CheckGroupField(keymap, action->type, value, &flags, &group))
-            return false;
-
-        act->flags = flags | XkbSA_ISODfltIsGroup;
-        act->group = group;
-        return true;
-    } else if (ACTION_FIELD_AFFECT) {
-        xkb_mod_mask_t mask;
-
-        if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
-
-        if (!ExprResolveMask(keymap->ctx, value, &mask, isoNames))
-            return ReportMismatch(keymap, action->type, field,
-                                  "keyboard component");
-
-        act->affect = (~mask) & XkbSA_ISOAffectMask;
-        return true;
-    }
-
-    return ReportIllegal(keymap, action->type, field);
-}
-
 static bool
 HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
                    enum action_field field, const ExprDef *array_ndx,
@@ -774,11 +662,11 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
             return ReportActionNotArray(keymap, action->type, field);
 
         if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
-            act->flags &= ~XkbSA_SwitchAbsolute;
+            act->flags &= ~ACTION_ABSOLUTE_SWITCH;
             scrn = value->value.child;
         }
         else {
-            act->flags |= XkbSA_SwitchAbsolute;
+            act->flags |= ACTION_ABSOLUTE_SWITCH;
             scrn = value;
         }
 
@@ -806,9 +694,9 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
             return ReportMismatch(keymap, action->type, field, "boolean");
 
         if (set)
-            act->flags &= ~XkbSA_SwitchApplication;
+            act->flags &= ~ACTION_SAME_SCREEN;
         else
-            act->flags |= XkbSA_SwitchApplication;
+            act->flags |= ACTION_SAME_SCREEN;
 
         return true;
     }
@@ -816,27 +704,6 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
     return ReportIllegal(keymap, action->type, field);
 }
 
-const LookupEntry ctrlNames[] = {
-    { "repeatkeys", XkbRepeatKeysMask },
-    { "repeat", XkbRepeatKeysMask },
-    { "autorepeat", XkbRepeatKeysMask },
-    { "slowkeys", XkbSlowKeysMask },
-    { "bouncekeys", XkbBounceKeysMask },
-    { "stickykeys", XkbStickyKeysMask },
-    { "mousekeys", XkbMouseKeysMask },
-    { "mousekeysaccel", XkbMouseKeysAccelMask },
-    { "accessxkeys", XkbAccessXKeysMask },
-    { "accessxtimeout", XkbAccessXTimeoutMask },
-    { "accessxfeedback", XkbAccessXFeedbackMask },
-    { "audiblebell", XkbAudibleBellMask },
-    { "ignoregrouplock", XkbIgnoreGroupLockMask },
-    { "all", XkbAllBooleanCtrlsMask },
-    { "overlay1", 0 },
-    { "overlay2", 0 },
-    { "none", 0 },
-    { NULL, 0 }
-};
-
 static bool
 HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
                       enum action_field field, const ExprDef *array_ndx,
@@ -850,7 +717,7 @@ HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
         if (array_ndx)
             return ReportActionNotArray(keymap, action->type, field);
 
-        if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlNames))
+        if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
             return ReportMismatch(keymap, action->type, field,
                                   "controls mask");
 
@@ -861,258 +728,6 @@ HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
     return ReportIllegal(keymap, action->type, field);
 }
 
-static const LookupEntry evNames[] = {
-    { "press", XkbSA_MessageOnPress },
-    { "keypress", XkbSA_MessageOnPress },
-    { "release", XkbSA_MessageOnRelease },
-    { "keyrelease", XkbSA_MessageOnRelease },
-    { "all", XkbSA_MessageOnPress | XkbSA_MessageOnRelease },
-    { "none", 0 },
-    { NULL, 0 }
-};
-
-static bool
-HandleActionMessage(struct xkb_keymap *keymap, union xkb_action *action,
-                    enum action_field field, const ExprDef *array_ndx,
-                    const ExprDef *value)
-{
-    struct xkb_message_action *act = &action->msg;
-
-    if (field == ACTION_FIELD_REPORT) {
-        unsigned int mask;
-
-        if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
-
-        if (!ExprResolveMask(keymap->ctx, value, &mask, evNames))
-            return ReportMismatch(keymap, action->type, field,
-                                  "key event mask");
-
-        /* FIXME: Something seems wrong here... */
-        act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
-        act->flags = mask & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
-        return true;
-    }
-    else if (field == ACTION_FIELD_GEN_KEY_EVENT) {
-        bool set;
-
-        if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
-
-        if (!ExprResolveBoolean(keymap->ctx, value, &set))
-            return ReportMismatch(keymap, action->type, field, "boolean");
-
-        if (set)
-            act->flags |= XkbSA_MessageGenKeyEvent;
-        else
-            act->flags &= ~XkbSA_MessageGenKeyEvent;
-
-        return true;
-    }
-    else if (field == ACTION_FIELD_DATA && !array_ndx) {
-        const char *str;
-        int len;
-
-        if (!ExprResolveString(keymap->ctx, value, &str))
-            return ReportMismatch(keymap, action->type, field, "string");
-
-        len = strlen(str);
-        if (len < 1 || len > 6) {
-            log_warn(keymap->ctx,
-                     "An action message can hold only 6 bytes; "
-                     "Extra %d bytes ignored\n", len - 6);
-        }
-
-        strncpy((char *) act->message, str, 6);
-        return true;
-    }
-    else if (field == ACTION_FIELD_DATA && array_ndx) {
-        int ndx, datum;
-
-        if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
-            log_err(keymap->ctx,
-                    "Array subscript must be integer; "
-                    "Illegal subscript ignored\n");
-            return false;
-        }
-
-        if (ndx < 0 || ndx > 5) {
-            log_err(keymap->ctx,
-                    "An action message is at most 6 bytes long; "
-                    "Attempt to use data[%d] ignored\n", ndx);
-            return false;
-        }
-
-        if (!ExprResolveInteger(keymap->ctx, value, &datum))
-            return ReportMismatch(keymap, action->type, field, "integer");
-
-        if (datum < 0 || datum > 255) {
-            log_err(keymap->ctx,
-                    "Message data must be in the range 0..255; "
-                    "Illegal datum %d ignored\n", datum);
-            return false;
-        }
-
-        act->message[ndx] = (uint8_t) datum;
-        return true;
-    }
-
-    return ReportIllegal(keymap, action->type, field);
-}
-
-static bool
-HandleRedirectKey(struct xkb_keymap *keymap, union xkb_action *action,
-                  enum action_field field, const ExprDef *array_ndx,
-                  const ExprDef *value)
-{
-    struct xkb_key *key;
-    struct xkb_redirect_key_action *act = &action->redirect;
-    unsigned t1;
-    xkb_mod_mask_t t2;
-    unsigned long tmp;
-    char key_name[XkbKeyNameLength];
-
-    if (array_ndx != NULL)
-        return ReportActionNotArray(keymap, action->type, field);
-
-    switch (field) {
-    case ACTION_FIELD_KEYCODE:
-        if (!ExprResolveKeyName(keymap->ctx, value, key_name))
-            return ReportMismatch(keymap, action->type, field, "key name");
-
-        tmp = KeyNameToLong(key_name);
-        key = FindNamedKey(keymap, tmp, true, 0);
-        if (!key)
-            return ReportNotFound(keymap, action->type, field, "Key",
-                                  KeyNameText(key_name));
-        act->new_kc = XkbKeyGetKeycode(keymap, key);
-        return true;
-
-    case ACTION_FIELD_MODS_TO_CLEAR:
-    case ACTION_FIELD_MODIFIERS:
-        t1 = 0;
-        if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
-            act->mods_mask |= (t2 & 0xff);
-            if (field == ACTION_FIELD_MODIFIERS)
-                act->mods |= (t2 & 0xff);
-            else
-                act->mods &= ~(t2 & 0xff);
-
-            t2 = (t2 >> XkbNumModifiers) & 0xffff;
-            act->vmods_mask |= t2;
-            if (field == ACTION_FIELD_MODIFIERS)
-                act->vmods |= t2;
-            else
-                act->vmods &= ~t2;
-            return true;
-        }
-        return true;
-
-    default:
-        break;
-    }
-
-    return ReportIllegal(keymap, action->type, field);
-}
-
-static bool
-HandleDeviceBtn(struct xkb_keymap *keymap, union xkb_action *action,
-                enum action_field field, const ExprDef *array_ndx,
-                const ExprDef *value)
-{
-    struct xkb_device_button_action *act = &action->devbtn;
-
-    if (field == ACTION_FIELD_BUTTON) {
-        int val;
-
-        if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
-
-        if (!ExprResolveInteger(keymap->ctx, value, &val))
-            return ReportMismatch(keymap, action->type, field,
-                                  "integer (range 1..255)");
-
-        if (val < 0 || val > 255) {
-            log_err(keymap->ctx,
-                    "Button must specify default or be in the range 1..255; "
-                    "Illegal button value %d ignored\n", val);
-            return false;
-        }
-
-        act->button = val;
-        return true;
-    }
-    else if (action->type == XkbSA_LockDeviceBtn &&
-             field == ACTION_FIELD_AFFECT) {
-        unsigned int val;
-
-        if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
-
-        if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
-            return ReportMismatch(keymap, action->type, field,
-                                  "lock or unlock");
-
-        act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
-        act->flags |= val;
-        return true;
-    }
-    else if (field == ACTION_FIELD_COUNT) {
-        int btn;
-
-        if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
-
-        /* XXX: Should this actually be ResolveButton? */
-        if (!ExprResolveButton(keymap->ctx, value, &btn))
-            return ReportMismatch(keymap, action->type, field, "integer");
-
-        if (btn < 0 || btn > 255) {
-            log_err(keymap->ctx,
-                    "The count field must have a value in the range 0..255; "
-                    "Illegal count %d ignored\n", btn);
-            return false;
-        }
-
-        act->count = btn;
-        return true;
-    }
-    else if (field == ACTION_FIELD_DEVICE) {
-        int val;
-
-        if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
-
-        if (!ExprResolveInteger(keymap->ctx, value, &val))
-            return ReportMismatch(keymap, action->type, field,
-                                  "integer (range 1..255)");
-
-        if (val < 0 || val > 255) {
-            log_err(keymap->ctx,
-                    "Device must specify default or be in the range 1..255; "
-                    "Illegal device value %d ignored\n", val);
-            return false;
-        }
-
-        act->device = val;
-        return true;
-    }
-
-    return ReportIllegal(keymap, action->type, field);
-}
-
-static bool
-HandleDeviceValuator(struct xkb_keymap *keymap, union xkb_action *action,
-                     enum action_field field, const ExprDef *array_ndx,
-                     const ExprDef *value)
-{
-    struct xkb_device_valuator_action *act = &action->devval;
-    (void) act;
-
-    /*  XXX - Not yet implemented */
-    return false;
-}
-
 static bool
 HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
               enum action_field field, const ExprDef *array_ndx,
@@ -1124,7 +739,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,
@@ -1133,17 +748,38 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
             return false;
         }
 
-        act->type = (uint8_t) type;
+        /*
+         * It's possible for someone to write something like this:
+         *      actions = [ Private(type=3,data[0]=1,data[1]=3,data[2]=3) ]
+         * where the type refers to some existing action type, e.g. LockMods.
+         * This assumes that this action's struct is layed out in memory
+         * exactly as described in the XKB specification and libraries.
+         * We, however, have changed these structs in various ways, so this
+         * assumption is no longer true. Since this is a lousy "feature", we
+         * make actions like these no-ops for now.
+         */
+        if (type < ACTION_TYPE_PRIVATE) {
+            log_info(keymap->ctx,
+                     "Private actions of type %s are not supported; Ignored\n",
+                     ActionTypeText(type));
+            act->type = ACTION_TYPE_NONE;
+        }
+        else {
+            act->type = (enum xkb_action_type) type;
+        }
+
         return true;
     }
     else if (field == ACTION_FIELD_DATA) {
         if (array_ndx == NULL) {
+            xkb_atom_t val;
             const char *str;
             int len;
 
-            if (!ExprResolveString(keymap->ctx, value, &str))
+            if (!ExprResolveString(keymap->ctx, value, &val))
                 return ReportMismatch(keymap, action->type, field, "string");
 
+            str = xkb_atom_text(keymap->ctx, val);
             len = strlen(str);
             if (len < 1 || len > 7) {
                 log_warn(keymap->ctx,
@@ -1167,9 +803,9 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
 
             if (ndx < 0 || ndx >= sizeof(act->data)) {
                 log_err(keymap->ctx,
-                        "The data for a private action is %zu bytes long; "
+                        "The data for a private action is %lu bytes long; "
                         "Attempt to use data[%d] ignored\n",
-                        sizeof(act->data), ndx);
+                        (unsigned long) sizeof(act->data), ndx);
                 return false;
             }
 
@@ -1188,7 +824,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,
@@ -1197,54 +833,34 @@ 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_ISOLock] = HandleISOLock,
-    [XkbSA_Terminate] = HandleNoAction,
-    [XkbSA_SwitchScreen] = HandleSwitchScreen,
-    [XkbSA_SetControls] = HandleSetLockControls,
-    [XkbSA_LockControls] = HandleSetLockControls,
-    [XkbSA_ActionMessage] = HandleActionMessage,
-    [XkbSA_RedirectKey] = HandleRedirectKey,
-    [XkbSA_DeviceBtn] = HandleDeviceBtn,
-    [XkbSA_LockDeviceBtn] = HandleDeviceBtn,
-    [XkbSA_DeviceValuator] = HandleDeviceValuator,
-    [PrivateAction] = HandlePrivate,
+static const actionHandler handleAction[_ACTION_TYPE_NUM_ENTRIES] = {
+    [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,
 };
 
 /***====================================================================***/
 
-static void
-ApplyActionFactoryDefaults(union xkb_action *action)
-{
-    if (action->type == XkbSA_SetPtrDflt) {
-        /* Increment default button. */
-        action->dflt.affect = XkbSA_AffectDfltBtn;
-        action->dflt.flags = 0;
-        action->dflt.value = 1;
-    }
-    else if (action->type == XkbSA_ISOLock) {
-        action->iso.mods.mods = (1 << ModNameToIndex(XKB_MOD_NAME_CAPS));
-    }
-}
-
 bool
 HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
-                union xkb_action *action, ActionInfo *info)
+                union xkb_action *action, ActionsInfo *info)
 {
     ExprDef *arg;
     const char *str;
-    unsigned hndlrType;
+    unsigned handler_type;
 
     if (def->op != EXPR_ACTION_DECL) {
         log_err(keymap->ctx, "Expected an action definition, found %s\n",
@@ -1253,32 +869,17 @@ HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
     }
 
     str = xkb_atom_text(keymap->ctx, def->value.action.name);
-    if (!stringToAction(str, &hndlrType)) {
+    if (!stringToAction(str, &handler_type)) {
         log_err(keymap->ctx, "Unknown action %s\n", str);
         return false;
     }
 
-    action->type = hndlrType;
-
     /*
-     * Go through all of the ActionInfo's which change the default values
-     * for this action->type and apply them to this action, e.g. if the
-     * action is latchMods, and a statement such as this:
+     * Get the default values for this action type, as modified by
+     * statements such as:
      *     latchMods.clearLocks = True;
-     * appears in the section before, then we apply it.
      */
-    if (action->type != XkbSA_NoAction) {
-        ApplyActionFactoryDefaults(action);
-
-        for (; info; info = info->next) {
-            if (info->action != XkbSA_NoAction && info->action != hndlrType)
-                continue;
-
-            if (!handleAction[hndlrType](keymap, action, info->field,
-                                         info->array_ndx, info->value))
-                return false;
-        }
-    }
+    *action = info->actions[handler_type];
 
     /*
      * Now change the action properties as specified for this
@@ -1322,61 +923,30 @@ HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
             return false;
         }
 
-        if (!handleAction[hndlrType](keymap, action, fieldNdx, arrayRtrn,
-                                     value))
+        if (!handleAction[handler_type](keymap, action, fieldNdx, arrayRtrn,
+                                        value))
             return false;
     }
 
     return true;
 }
 
+
 bool
 SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field,
-               ExprDef *array_ndx, ExprDef *value, ActionInfo **info_rtrn)
+               ExprDef *array_ndx, ExprDef *value, ActionsInfo *info)
 {
-    ActionInfo *new, *old;
-
-    new = malloc(sizeof(*new));
-    if (!new) {
-        log_wsgo(keymap->ctx, "Couldn't allocate space for action default\n");
-        goto err;
-    }
-
-    if (istreq(elem, "action")) {
-        new->action = XkbSA_NoAction;
-    }
-    else {
-        if (!stringToAction(elem, &new->action))
-            goto err;
+    unsigned action;
+    enum action_field action_field;
 
-        if (new->action == XkbSA_NoAction) {
-            log_err(keymap->ctx,
-                    "\"%s\" is not a valid field in a NoAction action\n",
-                    field);
-            goto err;
-        }
-    }
+    if (!stringToAction(elem, &action))
+        return false;
 
-    if (!stringToField(field, &new->field)) {
+    if (!stringToField(field, &action_field)) {
         log_err(keymap->ctx, "\"%s\" is not a legal field name\n", field);
-        goto err;
+        return false;
     }
 
-    new->array_ndx = array_ndx;
-    new->value = value;
-
-    new->next = NULL;
-    old = *info_rtrn;
-    while (old && old->next)
-        old = old->next;
-    if (!old)
-        *info_rtrn = new;
-    else
-        old->next = new;
-
-    return true;
-
-err:
-    free(new);
-    return false;
+    return handleAction[action](keymap, &info->actions[action],
+                                action_field, array_ndx, value);
 }