action: s/hndlrType/handler_type
[platform/upstream/libxkbcommon.git] / src / xkbcomp / action.c
index f83c220..22762c6 100644 (file)
@@ -748,7 +748,26 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
             return false;
         }
 
-        act->type = (enum xkb_action_type) 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) {
@@ -841,7 +860,7 @@ HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
 {
     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",
@@ -850,7 +869,7 @@ 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;
     }
@@ -860,7 +879,7 @@ HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
      * statements such as:
      *     latchMods.clearLocks = True;
      */
-    *action = info->actions[hndlrType];
+    *action = info->actions[handler_type];
 
     /*
      * Now change the action properties as specified for this
@@ -904,8 +923,8 @@ 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;
     }