From 11ea079175289f272564eb2ef3be31716b6b0112 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 20 Feb 2012 17:07:48 +0000 Subject: [PATCH] Invert LookupModMask/LookupVModMask order 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 --- src/xkbcomp/expr.c | 17 ++++------------- src/xkbcomp/expr.h | 12 ++++++++++++ src/xkbcomp/vmod.c | 15 ++++++++++----- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index b8586e9..e34a754 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -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 diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h index e399e1c..feed902 100644 --- a/src/xkbcomp/expr.h +++ b/src/xkbcomp/expr.h @@ -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 */ , diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c index 17a9892..31b0b4c 100644 --- a/src/xkbcomp/vmod.c +++ b/src/xkbcomp/vmod.c @@ -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)); -- 2.7.4