diff options
author | Ran Benita <ran234@gmail.com> | 2014-02-15 21:48:31 +0200 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2014-02-15 21:48:31 +0200 |
commit | 7c5e79159b5f5cd533a078c7672705e2ffa0a798 (patch) | |
tree | e874e088970dc3844dfe53753bba994b1323b893 /src/xkbcomp | |
parent | 1b2bb204e0baa2246a6232aea762c1edb00cd44a (diff) | |
download | libxkbcommon-7c5e79159b5f5cd533a078c7672705e2ffa0a798.tar.gz libxkbcommon-7c5e79159b5f5cd533a078c7672705e2ffa0a798.tar.bz2 libxkbcommon-7c5e79159b5f5cd533a078c7672705e2ffa0a798.zip |
action: fix missing support for "affect" field
Support for setting this field was missing from the LockMods and
LockControls actions.
Based on a xkbcomp patch by Andreas Wettstein.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/xkbcomp')
-rw-r--r-- | src/xkbcomp/action.c | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c index 44bc73f..fa2bf5b 100644 --- a/src/xkbcomp/action.c +++ b/src/xkbcomp/action.c @@ -311,6 +311,29 @@ HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action, return ReportIllegal(keymap, action->type, field); } +static const LookupEntry lockWhich[] = { + { "both", 0 }, + { "lock", ACTION_LOCK_NO_UNLOCK }, + { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) }, + { "unlock", ACTION_LOCK_NO_LOCK }, + { NULL, 0 } +}; + +static bool +CheckAffectField(struct xkb_keymap *keymap, enum xkb_action_type action, + const ExprDef *value, enum xkb_action_flags *flags_inout) +{ + enum xkb_action_flags flags; + + if (!ExprResolveEnum(keymap->ctx, value, &flags, lockWhich)) + return ReportMismatch(keymap, action, ACTION_FIELD_AFFECT, + "lock, unlock, both, neither"); + + *flags_inout &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK); + *flags_inout |= flags; + return true; +} + static bool HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action, enum action_field field, const ExprDef *array_ndx, @@ -318,13 +341,16 @@ HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action, { struct xkb_mod_action *act = &action->mods; - if (array_ndx && field == ACTION_FIELD_MODIFIERS) + if (array_ndx && (field == ACTION_FIELD_MODIFIERS || + field == ACTION_FIELD_AFFECT)) return ReportActionNotArray(keymap, action->type, field); switch (field) { case ACTION_FIELD_MODIFIERS: return CheckModifierField(keymap, action->type, value, &act->flags, &act->mods.mods); + case ACTION_FIELD_AFFECT: + return CheckAffectField(keymap, action->type, value, &act->flags); default: break; } @@ -472,14 +498,6 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action, return ReportIllegal(keymap, action->type, field); } -static const LookupEntry lockWhich[] = { - { "both", 0 }, - { "lock", ACTION_LOCK_NO_UNLOCK }, - { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) }, - { "unlock", ACTION_LOCK_NO_LOCK }, - { NULL, 0 } -}; - static bool HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action, enum action_field field, const ExprDef *array_ndx, @@ -509,18 +527,10 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action, } else if (action->type == ACTION_TYPE_PTR_LOCK && field == ACTION_FIELD_AFFECT) { - enum xkb_action_flags val; - if (array_ndx) return ReportActionNotArray(keymap, action->type, field); - if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich)) - return ReportMismatch(keymap, action->type, field, - "lock or unlock"); - - act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK); - act->flags |= val; - return true; + return CheckAffectField(keymap, action->type, value, &act->flags); } else if (field == ACTION_FIELD_COUNT) { int val; @@ -688,6 +698,12 @@ HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action, act->ctrls = mask; return true; } + else if (field == ACTION_FIELD_AFFECT) { + if (array_ndx) + return ReportActionNotArray(keymap, action->type, field); + + return CheckAffectField(keymap, action->type, value, &act->flags); + } return ReportIllegal(keymap, action->type, field); } |