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>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
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);
}