Invert LookupModMask/LookupVModMask order
authorDaniel Stone <daniel@fooishbar.org>
Mon, 20 Feb 2012 17:07:48 +0000 (17:07 +0000)
committerDaniel Stone <daniel@fooishbar.org>
Mon, 20 Feb 2012 17:07:48 +0000 (17:07 +0000)
We never want to solely lookup a virtual modifier without also looking
up core modifiers.  So, rather than chaining the vmod lookup inside the
core modifier lookup, invert the ordering.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
src/xkbcomp/expr.c
src/xkbcomp/expr.h
src/xkbcomp/vmod.c

index b8586e9..e34a754 100644 (file)
@@ -243,7 +243,7 @@ LookupModIndex(char * priv, uint32_t field, unsigned type,
     return SimpleLookup((char *) modIndexNames, field, type, val_rtrn);
 }
 
-static int
+int
 LookupModMask(char * priv, uint32_t field, unsigned type,
               ExprResult * val_rtrn)
 {
@@ -999,12 +999,7 @@ int
 ExprResolveModMask(ExprDef * expr,
                    ExprResult * val_rtrn)
 {
-    LookupPriv priv;
-
-    priv.chain = NULL;
-    priv.chainPriv = NULL;
-    return ExprResolveMaskLookup(expr, val_rtrn, LookupModMask,
-                                 (char *) & priv);
+    return ExprResolveMaskLookup(expr, val_rtrn, LookupModMask, NULL);
 }
 
 int
@@ -1012,12 +1007,8 @@ ExprResolveVModMask(ExprDef * expr,
                     ExprResult * val_rtrn,
                     struct xkb_desc *xkb)
 {
-    LookupPriv priv;
-
-    priv.chain = LookupVModMask;
-    priv.chainPriv = (char *) xkb;
-    return ExprResolveMaskLookup(expr, val_rtrn, LookupModMask,
-                                 (char *) & priv);
+    return ExprResolveMaskLookup(expr, val_rtrn, LookupVModMask,
+                                 (char *) xkb);
 }
 
 int
index e399e1c..feed902 100644 (file)
@@ -51,6 +51,18 @@ typedef struct _LookupEntry
 extern char *exprOpText(unsigned        /* type */
     );
 
+extern int LookupModMask(char * /* priv */ ,
+                         uint32_t /* field */ ,
+                         unsigned /* type */ ,
+                         ExprResult *  /* val_rtrn */
+    );
+
+extern int LookupVModMask(char * /* priv */ ,
+                          uint32_t /* field */ ,
+                          unsigned /* type */ ,
+                          ExprResult *  /* val_rtrn */
+    );
+
 extern int LookupModIndex(char * /* priv */ ,
                           uint32_t /* field */ ,
                           unsigned /* type */ ,
index 17a9892..31b0b4c 100644 (file)
@@ -190,19 +190,24 @@ LookupVModIndex(char * priv, uint32_t field, unsigned type,
 }
 
 /**
- * Get the mask for the given modifier and set val_rtrn.uval to the mask.
- * Note that the mask returned is always > 512.
+ * Get the mask for the given (virtual or core) modifier and set
+ * val_rtrn.uval to the mask value.
  *
  * @param priv Pointer to xkb data structure.
- * @param val_rtrn Set to the mask returned.
+ * @param val_rtrn Member uval is set to the mask returned.
  *
  * @return True on success, False otherwise. If False is returned, val_rtrn is
  * undefined.
  */
 int
-LookupVModMask(char * priv, uint32_t field, unsigned type, ExprResult * val_rtrn)
+LookupVModMask(char * priv, uint32_t field, unsigned type,
+               ExprResult * val_rtrn)
 {
-    if (LookupVModIndex(priv, field, type, val_rtrn))
+    if (LookupModMask(NULL, field, type, val_rtrn))
+    {
+        return True;
+    }
+    else if (LookupVModIndex(priv, field, type, val_rtrn))
     {
         register unsigned ndx = val_rtrn->uval;
         val_rtrn->uval = (1 << (XkbNumModifiers + ndx));