Copy over missing action structs from kbproto
[platform/upstream/libxkbcommon.git] / src / xkbcomp / action.c
index 3f0953d..b149dfd 100644 (file)
@@ -334,7 +334,7 @@ ReportNotFound(unsigned action, unsigned field, const char *what, char *bad)
 
 static Bool
 HandleNoAction(XkbcDescPtr xkb,
-               XkbAnyAction * action,
+               struct xkb_any_action * action,
                unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     return ReportIllegal(action->type, field);
@@ -392,14 +392,14 @@ CheckModifierField(XkbcDescPtr xkb,
 
 static Bool
 HandleSetLatchMods(XkbcDescPtr xkb,
-                   XkbAnyAction * action,
+                   struct xkb_any_action * action,
                    unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
-    XkbcModAction *act;
+    struct xkb_mod_action *act;
     unsigned rtrn;
     unsigned t1, t2;
 
-    act = (XkbcModAction *) action;
+    act = (struct xkb_mod_action *) action;
     if (array_ndx != NULL)
     {
         switch (field)
@@ -437,13 +437,13 @@ HandleSetLatchMods(XkbcDescPtr xkb,
 
 static Bool
 HandleLockMods(XkbcDescPtr xkb,
-               XkbAnyAction * action,
+               struct xkb_any_action * action,
                unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
-    XkbcModAction *act;
+    struct xkb_mod_action *act;
     unsigned t1, t2;
 
-    act = (XkbcModAction *) action;
+    act = (struct xkb_mod_action *) action;
     if ((array_ndx != NULL) && (field == F_Modifiers))
         return ReportActionNotArray(action->type, field);
     switch (field)
@@ -512,7 +512,7 @@ CheckGroupField(unsigned action,
 
 static Bool
 HandleSetLatchGroup(XkbcDescPtr xkb,
-                    XkbAnyAction * action,
+                    struct xkb_any_action * action,
                     unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     XkbGroupAction *act;
@@ -557,7 +557,7 @@ HandleSetLatchGroup(XkbcDescPtr xkb,
 
 static Bool
 HandleLockGroup(XkbcDescPtr xkb,
-                XkbAnyAction * action,
+                struct xkb_any_action * action,
                 unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     XkbGroupAction *act;
@@ -583,14 +583,14 @@ HandleLockGroup(XkbcDescPtr xkb,
 
 static Bool
 HandleMovePtr(XkbcDescPtr xkb,
-              XkbAnyAction * action,
+              struct xkb_any_action * action,
               unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbcPtrAction *act;
+    struct xkb_pointer_action *act;
     Bool absolute;
 
-    act = (XkbcPtrAction *) action;
+    act = (struct xkb_pointer_action *) action;
     if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
         return ReportActionNotArray(action->type, field);
 
@@ -606,13 +606,13 @@ HandleMovePtr(XkbcDescPtr xkb,
         {
             if (absolute)
                 act->flags |= XkbSA_MoveAbsoluteX;
-            act->x = rtrn.ival;
+            XkbSetPtrActionX(act, rtrn.ival);
         }
         else
         {
             if (absolute)
                 act->flags |= XkbSA_MoveAbsoluteY;
-            act->y = rtrn.ival;
+            XkbSetPtrActionY(act, rtrn.ival);
         }
         return True;
     }
@@ -648,13 +648,13 @@ static LookupEntry lockWhich[] = {
 
 static Bool
 HandlePtrBtn(XkbcDescPtr xkb,
-             XkbAnyAction * action,
+             struct xkb_any_action * action,
              unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbPtrBtnAction *act;
+    struct xkb_pointer_button_action *act;
 
-    act = (XkbPtrBtnAction *) action;
+    act = (struct xkb_pointer_button_action *) action;
     if (field == F_Button)
     {
         if (array_ndx != NULL)
@@ -710,7 +710,7 @@ static LookupEntry ptrDflts[] = {
 
 static Bool
 HandleSetPtrDflt(XkbcDescPtr xkb,
-                 XkbAnyAction * action,
+                 struct xkb_any_action * action,
                  unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
@@ -783,15 +783,15 @@ static LookupEntry isoNames[] = {
 
 static Bool
 HandleISOLock(XkbcDescPtr xkb,
-              XkbAnyAction * action,
+              struct xkb_any_action * action,
               unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbcISOAction *act;
+    struct xkb_iso_action *act;
     unsigned flags, mods;
     int group;
 
-    act = (XkbcISOAction *) action;
+    act = (struct xkb_iso_action *) action;
     switch (field)
     {
     case F_Modifiers:
@@ -813,7 +813,7 @@ HandleISOLock(XkbcDescPtr xkb,
         if (CheckGroupField(action->type, value, &flags, &group))
         {
             act->flags = flags | XkbSA_ISODfltIsGroup;
-            XkbSASetGroup(act, group);
+            act->group = group;
             return True;
         }
         return False;
@@ -830,7 +830,7 @@ HandleISOLock(XkbcDescPtr xkb,
 
 static Bool
 HandleSwitchScreen(XkbcDescPtr xkb,
-                   XkbAnyAction * action,
+                   struct xkb_any_action * action,
                    unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
@@ -922,13 +922,13 @@ LookupEntry ctrlNames[] = {
 
 static Bool
 HandleSetLockControls(XkbcDescPtr xkb,
-                      XkbAnyAction * action,
+                      struct xkb_any_action * action,
                       unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbcCtrlsAction *act;
+    struct xkb_controls_action *act;
 
-    act = (XkbcCtrlsAction *) action;
+    act = (struct xkb_controls_action *) action;
     if (field == F_Controls)
     {
         if (array_ndx != NULL)
@@ -954,13 +954,13 @@ static LookupEntry evNames[] = {
 
 static Bool
 HandleActionMessage(XkbcDescPtr xkb,
-                    XkbAnyAction * action,
+                    struct xkb_any_action * action,
                     unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbMessageAction *act;
+    struct xkb_message_action *act;
 
-    act = (XkbMessageAction *) action;
+    act = (struct xkb_message_action *) action;
     switch (field)
     {
     case F_Report:
@@ -1032,18 +1032,18 @@ HandleActionMessage(XkbcDescPtr xkb,
 
 static Bool
 HandleRedirectKey(XkbcDescPtr xkb,
-                  XkbAnyAction * action,
+                  struct xkb_any_action * action,
                   unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbcRedirectKeyAction *act;
+    struct xkb_redirect_key_action *act;
     unsigned t1, t2;
     unsigned long tmp;
 
     if (array_ndx != NULL)
         return ReportActionNotArray(action->type, field);
 
-    act = (XkbcRedirectKeyAction *) action;
+    act = (struct xkb_redirect_key_action *) action;
     switch (field)
     {
     case F_Keycode:
@@ -1069,11 +1069,11 @@ HandleRedirectKey(XkbcDescPtr xkb,
                 act->mods &= ~(t2 & 0xff);
 
             t2 = (t2 >> 8) & 0xffff;
-            act->vmods_mask |= t2;
+            XkbSARedirectSetVModsMask(act, XkbSARedirectVModsMask(act) | t2);
             if (field == F_Modifiers)
-                act->vmods |= t2;
+                XkbSARedirectSetVMods(act, XkbSARedirectVMods(act) | t2);
             else
-                act->vmods &= ~t2;
+                XkbSARedirectSetVMods(act, XkbSARedirectVMods(act) & ~t2);
             return True;
         }
         return True;
@@ -1083,7 +1083,7 @@ HandleRedirectKey(XkbcDescPtr xkb,
 
 static Bool
 HandleDeviceBtn(XkbcDescPtr xkb,
-                XkbAnyAction * action,
+                struct xkb_any_action * action,
                 unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
@@ -1153,7 +1153,7 @@ HandleDeviceBtn(XkbcDescPtr xkb,
 
 static Bool
 HandleDeviceValuator(XkbcDescPtr xkb,
-                     XkbAnyAction * action,
+                     struct xkb_any_action * action,
                      unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
 #if 0
@@ -1168,7 +1168,7 @@ HandleDeviceValuator(XkbcDescPtr xkb,
 
 static Bool
 HandlePrivate(XkbcDescPtr xkb,
-              XkbAnyAction * action,
+              struct xkb_any_action * action,
               unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
@@ -1200,7 +1200,7 @@ HandlePrivate(XkbcDescPtr xkb,
                     ACTION("Extra %d bytes ignored\n", len - 6);
                     return False;
                 }
-                strncpy((char *) action->data, rtrn.str, 7);
+                strncpy((char *) action->pad, rtrn.str, XkbcAnyActionDataSize);
             }
             free(rtrn.str);
             return True;
@@ -1215,9 +1215,9 @@ HandlePrivate(XkbcDescPtr xkb,
                 return False;
             }
             ndx = rtrn.uval;
-            if (ndx > 6)
+            if (ndx >= XkbcAnyActionDataSize)
             {
-                ERROR("The data for a private action is 7 bytes long\n");
+                ERROR("The data for a private action is 18 bytes long\n");
                 ACTION("Attempt to use data[%d] ignored\n", ndx);
                 return False;
             }
@@ -1229,7 +1229,7 @@ HandlePrivate(XkbcDescPtr xkb,
                 ACTION("Illegal datum %d ignored\n", rtrn.ival);
                 return False;
             }
-            action->data[ndx] = rtrn.uval;
+            action->pad[ndx] = rtrn.uval;
             return True;
         }
     }
@@ -1237,7 +1237,7 @@ HandlePrivate(XkbcDescPtr xkb,
 }
 
 typedef Bool(*actionHandler) (XkbcDescPtr /* xkb */ ,
-                              XkbAnyAction * /* action */ ,
+                              struct xkb_any_action * /* action */ ,
                               unsigned /* field */ ,
                               ExprDef * /* array_ndx */ ,
                               ExprDef * /* value */
@@ -1271,13 +1271,13 @@ static actionHandler handleAction[XkbSA_NumActions + 1] = {
 /***====================================================================***/
 
 static void
-ApplyActionFactoryDefaults(XkbcAction * action)
+ApplyActionFactoryDefaults(union xkb_action * action)
 {
     if (action->type == XkbSA_SetPtrDflt)
     {                           /* increment default button */
         action->dflt.affect = XkbSA_AffectDfltBtn;
         action->dflt.flags = 0;
-        XkbSASetPtrDfltValue(&action->dflt, 1);
+        action->dflt.value = 1;
     }
     else if (action->type == XkbSA_ISOLock)
     {
@@ -1290,7 +1290,7 @@ ApplyActionFactoryDefaults(XkbcAction * action)
 int
 HandleActionDef(ExprDef * def,
                 XkbcDescPtr xkb,
-                XkbAnyAction * action, unsigned mergeMode, ActionInfo * info)
+                struct xkb_any_action * action, unsigned mergeMode, ActionInfo * info)
 {
     ExprDef *arg;
     register char *str;
@@ -1305,7 +1305,7 @@ HandleActionDef(ExprDef * def,
                exprOpText(def->op));
         return False;
     }
-    str = XkbcAtomGetString(def->value.action.name);
+    str = XkbcAtomText(def->value.action.name);
     if (!str)
     {
         WSGO("Missing name in action definition!!\n");
@@ -1319,7 +1319,7 @@ HandleActionDef(ExprDef * def,
     action->type = hndlrType = tmp;
     if (action->type != XkbSA_NoAction)
     {
-        ApplyActionFactoryDefaults((XkbcAction *) action);
+        ApplyActionFactoryDefaults((union xkb_action *) action);
         while (info)
         {
             if ((info->action == XkbSA_NoAction)