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>master
parent
1b2bb204e0
commit
7c5e79159b
|
@ -311,6 +311,29 @@ HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
|
||||||
return ReportIllegal(keymap, action->type, field);
|
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
|
static bool
|
||||||
HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
|
HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
|
||||||
enum action_field field, const ExprDef *array_ndx,
|
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;
|
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);
|
return ReportActionNotArray(keymap, action->type, field);
|
||||||
|
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case ACTION_FIELD_MODIFIERS:
|
case ACTION_FIELD_MODIFIERS:
|
||||||
return CheckModifierField(keymap, action->type, value,
|
return CheckModifierField(keymap, action->type, value,
|
||||||
&act->flags, &act->mods.mods);
|
&act->flags, &act->mods.mods);
|
||||||
|
case ACTION_FIELD_AFFECT:
|
||||||
|
return CheckAffectField(keymap, action->type, value, &act->flags);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -472,14 +498,6 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
|
||||||
return ReportIllegal(keymap, action->type, field);
|
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
|
static bool
|
||||||
HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
|
HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
|
||||||
enum action_field field, const ExprDef *array_ndx,
|
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 &&
|
else if (action->type == ACTION_TYPE_PTR_LOCK &&
|
||||||
field == ACTION_FIELD_AFFECT) {
|
field == ACTION_FIELD_AFFECT) {
|
||||||
enum xkb_action_flags val;
|
|
||||||
|
|
||||||
if (array_ndx)
|
if (array_ndx)
|
||||||
return ReportActionNotArray(keymap, action->type, field);
|
return ReportActionNotArray(keymap, action->type, field);
|
||||||
|
|
||||||
if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
|
return CheckAffectField(keymap, action->type, value, &act->flags);
|
||||||
return ReportMismatch(keymap, action->type, field,
|
|
||||||
"lock or unlock");
|
|
||||||
|
|
||||||
act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
|
|
||||||
act->flags |= val;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else if (field == ACTION_FIELD_COUNT) {
|
else if (field == ACTION_FIELD_COUNT) {
|
||||||
int val;
|
int val;
|
||||||
|
@ -688,6 +698,12 @@ HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
|
||||||
act->ctrls = mask;
|
act->ctrls = mask;
|
||||||
return true;
|
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);
|
return ReportIllegal(keymap, action->type, field);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue