Regroup actions into current vs. deprecated, resize vmod
authorDaniel Stone <daniel@fooishbar.org>
Wed, 16 Jun 2010 23:51:49 +0000 (00:51 +0100)
committerDaniel Stone <daniel@fooishbar.org>
Tue, 22 Jun 2010 14:56:56 +0000 (15:56 +0100)
Use Xkbc* for all our actions that we intend to keep around, and Xkb*
for deprecated ones we can hopefully get rid of, at least internally.

While we're at it, make vmods be a uint32_t.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
include/X11/extensions/XKBcommon.h
src/malloc.c
src/xkbcomp/action.c
src/xkbcomp/compat.c

index 1057895..2c17304 100644 (file)
@@ -28,85 +28,116 @@ authorization from the authors.
 #ifndef _XKBCOMMON_H_
 #define _XKBCOMMON_H_
 
+#include <stdint.h>
 #include <stdio.h>
 #include <X11/Xfuncproto.h>
 #include <X11/extensions/XKBstrcommon.h>
 #include <X11/extensions/XKBrulescommon.h>
 
 /* Action structures used in the server */
+
+#define XkbcAnyActionDataSize 18
+typedef struct _XkbcAnyAction {
+    unsigned char   type;
+    unsigned char   pad[XkbcAnyActionDataSize];
+} XkbcAnyAction;
+
 typedef struct _XkbcModAction {
     unsigned char   type;
-    unsigned char   flags;
-    unsigned char   mask;
-    unsigned char   real_mods;
-    unsigned int    vmods;
+    uint8_t         flags;
+    uint32_t        mask;
+    uint32_t        real_mods;
+    uint32_t        vmods;
 } XkbcModAction;
 
-typedef struct _XkbcISOAction {
+typedef struct _XkbcGroupAction {
     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;
+    int16_t         group;
+} XkbcGroupAction;
 
-typedef struct _XkbcPtrAction {
+typedef struct _XkbcISOAction {
     unsigned char   type;
-    unsigned char   flags;
-    int             x;
-    int             y;
-} XkbcPtrAction;
+    uint8_t         flags;
+    int16_t         group;
+    uint32_t        mask;
+    uint32_t        vmods;
+    uint32_t        real_mods;
+    uint8_t         affect;
+} XkbcISOAction;
 
 typedef struct _XkbcCtrlsAction {
     unsigned char   type;
     unsigned char   flags;
-    unsigned long   ctrls;
+    uint32_t        ctrls;
 } XkbcCtrlsAction;
 
-typedef struct  _XkbcRedirectKeyAction {
+typedef struct _XkbcDeviceBtnAction {
+    unsigned char   type;
+    unsigned char   flags;
+    uint16_t        device;
+    uint16_t        button;
+    uint8_t         count;
+} XkbcDeviceBtnAction;
+
+typedef struct _XkbcDeviceValuatorAction {
     unsigned char   type;
-    unsigned char   new_key;
-    unsigned char   mods_mask;
-    unsigned char   mods;
-    unsigned int    vmods_mask;
-    unsigned int    vmods;
-} XkbcRedirectKeyAction;
+    uint8_t         v1_what;
+    uint16_t        device;
+    uint16_t        v1_index;
+    int16_t         v1_value;
+    uint16_t        v2_index;
+    int16_t         v2_value;
+    uint8_t         v2_what;
+} XkbcDeviceValuatorAction;
+
+typedef struct _XkbcPtrDfltAction {
+    unsigned char   type;
+    uint8_t         flags;
+    uint8_t         affect;
+    uint8_t         value;
+} XkbcPtrDfltAction;
+
+typedef struct _XkbcSwitchScreenAction {
+    unsigned char   type;
+    uint8_t         flags;
+    uint8_t         screen;
+} XkbcSwitchScreenAction;
 
 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;
+    XkbcAnyAction            any;
+    XkbcModAction            mods;
+    XkbcGroupAction          group;
+    XkbcISOAction            iso;
+    XkbcCtrlsAction          ctrls;
+    XkbcDeviceBtnAction      devbtn;
+    XkbcDeviceValuatorAction devval;
+    XkbcPtrDfltAction        dflt;
+    XkbcSwitchScreenAction   screen;
+    XkbRedirectKeyAction     redirect; /* XXX wholly unnecessary? */
+    XkbPtrAction             ptr; /* XXX delete for DeviceValuator */
+    XkbPtrBtnAction          btn; /* XXX delete for DeviceBtn */
+    XkbMessageAction         msg; /* XXX just delete */
     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;
+
+    XkbcAction          *acts;
+    XkbBehavior         *behaviors;
+    unsigned short      *key_acts;
+    unsigned char       *explicits;
+    uint32_t            vmods[XkbNumVirtualMods];
+    uint32_t            *vmodmap;
 } XkbcServerMapRec, *XkbcServerMapPtr;
 
 /* Common keyboard description structure */
index 3946d2c..1f814a0 100644 (file)
@@ -221,7 +221,7 @@ XkbcAllocServerMap(XkbcDescPtr xkb, unsigned which, unsigned nNewActions)
 
         if (!map->vmodmap) {
             i = xkb->max_key_code + 1;
-            map->vmodmap = _XkbTypedCalloc(i, unsigned short);
+            map->vmodmap = _XkbTypedCalloc(i, uint32_t);
             if (!map->vmodmap)
                 return BadAlloc;
         }
@@ -770,18 +770,18 @@ XkbcChangeKeycodeRange(XkbcDescPtr xkb, int minKC, int maxKC,
             }
 
             if (xkb->server->vmodmap) {
-                unsigned short *prev_vmodmap = xkb->server->vmodmap;
+                uint32_t *prev_vmodmap = xkb->server->vmodmap;
 
                 xkb->server->vmodmap = _XkbTypedRealloc(xkb->server->vmodmap,
                                                         maxKC + 1,
-                                                        unsigned short);
+                                                        uint32_t);
                 if (!xkb->server->vmodmap) {
                     _XkbFree(prev_vmodmap);
                     return BadAlloc;
                 }
 
                 bzero(&xkb->server->vmodmap[xkb->max_key_code],
-                      tmp * sizeof(unsigned short));
+                      tmp * sizeof(uint32_t));
                 if (changes)
                     changes->map.changed = _ExtendRange(changes->map.changed,
                                                 XkbVirtualModMapMask, maxKC,
index 3f0953d..1076030 100644 (file)
@@ -587,10 +587,10 @@ HandleMovePtr(XkbcDescPtr xkb,
               unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbcPtrAction *act;
+    XkbPtrAction *act;
     Bool absolute;
 
-    act = (XkbcPtrAction *) action;
+    act = (XkbPtrAction *) 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;
     }
@@ -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;
@@ -1036,14 +1036,14 @@ HandleRedirectKey(XkbcDescPtr xkb,
                   unsigned field, ExprDef * array_ndx, ExprDef * value)
 {
     ExprResult rtrn;
-    XkbcRedirectKeyAction *act;
+    XkbRedirectKeyAction *act;
     unsigned t1, t2;
     unsigned long tmp;
 
     if (array_ndx != NULL)
         return ReportActionNotArray(action->type, field);
 
-    act = (XkbcRedirectKeyAction *) action;
+    act = (XkbRedirectKeyAction *) 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;
@@ -1277,7 +1277,7 @@ ApplyActionFactoryDefaults(XkbcAction * action)
     {                           /* 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)
     {
index 461c759..1f3a40e 100644 (file)
@@ -118,7 +118,7 @@ InitCompatInfo(CompatInfo * info, XkbcDescPtr xkb)
     info->dflt.interp.flags = 0;
     info->dflt.interp.virtual_mod = XkbNoModifier;
     info->dflt.interp.act.type = XkbSA_NoAction;
-    for (i = 0; i < XkbAnyActionDataSize; i++)
+    for (i = 0; i < XkbcAnyActionDataSize; i++)
     {
         info->dflt.interp.act.data[i] = 0;
     }
@@ -146,7 +146,7 @@ ClearCompatInfo(CompatInfo * info, XkbcDescPtr xkb)
     info->dflt.interp.flags = 0;
     info->dflt.interp.virtual_mod = XkbNoModifier;
     info->dflt.interp.act.type = XkbSA_NoAction;
-    for (i = 0; i < XkbAnyActionDataSize; i++)
+    for (i = 0; i < XkbcAnyActionDataSize; i++)
     {
         info->dflt.interp.act.data[i] = 0;
     }