expr: drop ExprResult from ResolveMask
Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
2e4933cda7
commit
38614c886c
|
@ -245,7 +245,6 @@ static bool
|
|||
CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
|
||||
unsigned *flags_inout, xkb_mod_mask_t *mods_rtrn)
|
||||
{
|
||||
ExprResult rtrn;
|
||||
if (value->op == EXPR_IDENT) {
|
||||
const char *valStr;
|
||||
valStr = xkb_atom_text(keymap->ctx, value->value.str);
|
||||
|
@ -258,10 +257,9 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
|
|||
}
|
||||
}
|
||||
|
||||
if (!ExprResolveVModMask(keymap, value, &rtrn))
|
||||
if (!ExprResolveVModMask(keymap, value, mods_rtrn))
|
||||
return ReportMismatch(keymap, action, F_Modifiers, "modifier mask");
|
||||
|
||||
*mods_rtrn = (xkb_mod_mask_t) rtrn.ival;
|
||||
*flags_inout &= ~XkbSA_UseModMapMods;
|
||||
return true;
|
||||
}
|
||||
|
@ -624,46 +622,53 @@ static bool
|
|||
HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
|
||||
unsigned field, ExprDef *array_ndx, ExprDef *value)
|
||||
{
|
||||
ExprResult rtrn;
|
||||
struct xkb_iso_action *act;
|
||||
unsigned flags;
|
||||
xkb_mod_mask_t mods;
|
||||
xkb_group_index_t group;
|
||||
|
||||
act = (struct xkb_iso_action *) action;
|
||||
switch (field) {
|
||||
case F_Modifiers:
|
||||
if (array_ndx != NULL)
|
||||
return ReportActionNotArray(keymap, action->type, field);
|
||||
flags = act->flags;
|
||||
if (CheckModifierField(keymap, action->type, value, &flags, &mods)) {
|
||||
act->flags = flags & (~XkbSA_ISODfltIsGroup);
|
||||
act->real_mods = mods & 0xff;
|
||||
act->vmods = (mods >> 8) & 0xff;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (field == F_Modifiers) {
|
||||
unsigned flags;
|
||||
xkb_mod_mask_t mods;
|
||||
|
||||
case F_Group:
|
||||
if (array_ndx != NULL)
|
||||
if (array_ndx)
|
||||
return ReportActionNotArray(keymap, action->type, field);
|
||||
flags = act->flags;
|
||||
if (CheckGroupField(keymap, action->type, value, &flags, &group)) {
|
||||
act->flags = flags | XkbSA_ISODfltIsGroup;
|
||||
act->group = group;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
case F_Affect:
|
||||
if (array_ndx != NULL)
|
||||
return ReportActionNotArray(keymap, action->type, field);
|
||||
if (!ExprResolveMask(keymap->ctx, value, &rtrn, isoNames))
|
||||
return ReportMismatch(keymap, action->type, field,
|
||||
"keyboard component");
|
||||
act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask;
|
||||
flags = act->flags;
|
||||
if (!CheckModifierField(keymap, action->type, value, &flags, &mods))
|
||||
return false;
|
||||
|
||||
act->flags = flags & (~XkbSA_ISODfltIsGroup);
|
||||
act->real_mods = mods & 0xff;
|
||||
act->vmods = (mods >> 8) & 0xff;
|
||||
return true;
|
||||
}
|
||||
else if (field == F_Group) {
|
||||
xkb_group_index_t group;
|
||||
unsigned flags;
|
||||
|
||||
if (array_ndx)
|
||||
return ReportActionNotArray(keymap, action->type, field);
|
||||
|
||||
flags = act->flags;
|
||||
if (!CheckGroupField(keymap, action->type, value, &flags, &group))
|
||||
return false;
|
||||
|
||||
act->flags = flags | XkbSA_ISODfltIsGroup;
|
||||
act->group = group;
|
||||
return true;
|
||||
} else if (F_Affect) {
|
||||
xkb_mod_mask_t mask;
|
||||
|
||||
if (array_ndx)
|
||||
return ReportActionNotArray(keymap, action->type, field);
|
||||
|
||||
if (!ExprResolveMask(keymap->ctx, value, &mask, isoNames))
|
||||
return ReportMismatch(keymap, action->type, field,
|
||||
"keyboard component");
|
||||
|
||||
act->affect = (~mask) & XkbSA_ISOAffectMask;
|
||||
return true;
|
||||
}
|
||||
|
||||
return ReportIllegal(keymap, action->type, field);
|
||||
}
|
||||
|
||||
|
@ -752,19 +757,23 @@ HandleSetLockControls(struct xkb_keymap *keymap,
|
|||
unsigned field, ExprDef *array_ndx,
|
||||
ExprDef *value)
|
||||
{
|
||||
ExprResult rtrn;
|
||||
struct xkb_controls_action *act;
|
||||
|
||||
act = (struct xkb_controls_action *) action;
|
||||
if (field == F_Controls) {
|
||||
if (array_ndx != NULL)
|
||||
unsigned int mask;
|
||||
|
||||
if (array_ndx)
|
||||
return ReportActionNotArray(keymap, action->type, field);
|
||||
if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
|
||||
|
||||
if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlNames))
|
||||
return ReportMismatch(keymap, action->type, field,
|
||||
"controls mask");
|
||||
act->ctrls = rtrn.uval;
|
||||
|
||||
act->ctrls = mask;
|
||||
return true;
|
||||
}
|
||||
|
||||
return ReportIllegal(keymap, action->type, field);
|
||||
}
|
||||
|
||||
|
@ -782,25 +791,27 @@ static bool
|
|||
HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
|
||||
unsigned field, ExprDef *array_ndx, ExprDef *value)
|
||||
{
|
||||
ExprResult rtrn;
|
||||
const char *str;
|
||||
bool set;
|
||||
struct xkb_message_action *act;
|
||||
|
||||
act = (struct xkb_message_action *) action;
|
||||
switch (field) {
|
||||
case F_Report:
|
||||
if (array_ndx != NULL)
|
||||
if (field == F_Report) {
|
||||
unsigned int mask;
|
||||
|
||||
if (array_ndx)
|
||||
return ReportActionNotArray(keymap, action->type, field);
|
||||
if (!ExprResolveMask(keymap->ctx, value, &rtrn, evNames))
|
||||
|
||||
if (!ExprResolveMask(keymap->ctx, value, &mask, evNames))
|
||||
return ReportMismatch(keymap, action->type, field,
|
||||
"key event mask");
|
||||
act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
|
||||
act->flags =
|
||||
rtrn.uval & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
|
||||
return true;
|
||||
|
||||
case F_GenKeyEvent:
|
||||
/* FIXME: Something seems wrong here... */
|
||||
act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
|
||||
act->flags = mask & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
|
||||
return true;
|
||||
}
|
||||
else if (field == F_GenKeyEvent) {
|
||||
bool set;
|
||||
|
||||
if (array_ndx)
|
||||
return ReportActionNotArray(keymap, action->type, field);
|
||||
|
||||
|
@ -813,54 +824,52 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
|
|||
act->flags &= ~XkbSA_MessageGenKeyEvent;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (field == F_Data && !array_ndx) {
|
||||
const char *str;
|
||||
int len;
|
||||
|
||||
case F_Data:
|
||||
if (array_ndx == NULL) {
|
||||
int len;
|
||||
if (!ExprResolveString(keymap->ctx, value, &str))
|
||||
return ReportMismatch(keymap, action->type, field, "string");
|
||||
|
||||
if (!ExprResolveString(keymap->ctx, value, &str))
|
||||
return ReportMismatch(keymap, action->type, field, "string");
|
||||
|
||||
len = strlen(str);
|
||||
if (len < 1 || len > 6) {
|
||||
log_warn(keymap->ctx,
|
||||
"An action message can hold only 6 bytes; "
|
||||
"Extra %d bytes ignored\n", len - 6);
|
||||
}
|
||||
|
||||
strncpy((char *) act->message, str, 6);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
int ndx, datum;
|
||||
|
||||
if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
|
||||
log_err(keymap->ctx,
|
||||
"Array subscript must be integer; "
|
||||
"Illegal subscript ignored\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ndx < 0 || ndx > 5) {
|
||||
log_err(keymap->ctx,
|
||||
"An action message is at most 6 bytes long; "
|
||||
"Attempt to use data[%d] ignored\n", ndx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ExprResolveInteger(keymap->ctx, value, &datum))
|
||||
return ReportMismatch(keymap, action->type, field, "integer");
|
||||
|
||||
if (datum < 0 || datum > 255) {
|
||||
log_err(keymap->ctx,
|
||||
"Message data must be in the range 0..255; "
|
||||
"Illegal datum %d ignored\n", datum);
|
||||
return false;
|
||||
}
|
||||
|
||||
act->message[ndx] = (uint8_t) datum;
|
||||
len = strlen(str);
|
||||
if (len < 1 || len > 6) {
|
||||
log_warn(keymap->ctx,
|
||||
"An action message can hold only 6 bytes; "
|
||||
"Extra %d bytes ignored\n", len - 6);
|
||||
}
|
||||
|
||||
strncpy((char *) act->message, str, 6);
|
||||
return true;
|
||||
}
|
||||
else if (field == F_Data && array_ndx) {
|
||||
int ndx, datum;
|
||||
|
||||
if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
|
||||
log_err(keymap->ctx,
|
||||
"Array subscript must be integer; "
|
||||
"Illegal subscript ignored\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ndx < 0 || ndx > 5) {
|
||||
log_err(keymap->ctx,
|
||||
"An action message is at most 6 bytes long; "
|
||||
"Attempt to use data[%d] ignored\n", ndx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ExprResolveInteger(keymap->ctx, value, &datum))
|
||||
return ReportMismatch(keymap, action->type, field, "integer");
|
||||
|
||||
if (datum < 0 || datum > 255) {
|
||||
log_err(keymap->ctx,
|
||||
"Message data must be in the range 0..255; "
|
||||
"Illegal datum %d ignored\n", datum);
|
||||
return false;
|
||||
}
|
||||
|
||||
act->message[ndx] = (uint8_t) datum;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -366,10 +366,8 @@ AddGroupCompat(CompatInfo *info, xkb_group_index_t group, GroupCompatInfo *new)
|
|||
static bool
|
||||
ResolveStateAndPredicate(ExprDef * expr,
|
||||
unsigned *pred_rtrn,
|
||||
unsigned *mods_rtrn, CompatInfo * info)
|
||||
xkb_mod_mask_t *mods_rtrn, CompatInfo * info)
|
||||
{
|
||||
ExprResult result;
|
||||
|
||||
if (expr == NULL) {
|
||||
*pred_rtrn = XkbSI_AnyOfOrNone;
|
||||
*mods_rtrn = ~0;
|
||||
|
@ -407,11 +405,7 @@ ResolveStateAndPredicate(ExprDef * expr,
|
|||
}
|
||||
}
|
||||
|
||||
if (ExprResolveModMask(info->keymap->ctx, expr, &result)) {
|
||||
*mods_rtrn = result.uval;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return ExprResolveModMask(info->keymap->ctx, expr, mods_rtrn);
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
@ -761,35 +755,41 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
|
|||
struct xkb_keymap *keymap = info->keymap;
|
||||
|
||||
if (istreq(field, "modifiers") || istreq(field, "mods")) {
|
||||
if (arrayNdx != NULL)
|
||||
xkb_mod_mask_t mask;
|
||||
|
||||
if (arrayNdx)
|
||||
return ReportIndicatorNotArray(info, led, field);
|
||||
|
||||
if (!ExprResolveVModMask(keymap, value, &rtrn))
|
||||
if (!ExprResolveVModMask(keymap, value, &mask))
|
||||
return ReportIndicatorBadType(info, led, field, "modifier mask");
|
||||
|
||||
led->real_mods = rtrn.uval & 0xff;
|
||||
led->vmods = (rtrn.uval >> 8) & 0xff;
|
||||
led->real_mods = mask & 0xff;
|
||||
led->vmods = (mask >> 8) & 0xff;
|
||||
led->defined |= _LED_Mods;
|
||||
}
|
||||
else if (istreq(field, "groups")) {
|
||||
if (arrayNdx != NULL)
|
||||
unsigned int mask;
|
||||
|
||||
if (arrayNdx)
|
||||
return ReportIndicatorNotArray(info, led, field);
|
||||
|
||||
if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupNames))
|
||||
if (!ExprResolveMask(keymap->ctx, value, &mask, groupNames))
|
||||
return ReportIndicatorBadType(info, led, field, "group mask");
|
||||
|
||||
led->groups = rtrn.uval;
|
||||
led->groups = mask;
|
||||
led->defined |= _LED_Groups;
|
||||
}
|
||||
else if (istreq(field, "controls") || istreq(field, "ctrls")) {
|
||||
if (arrayNdx != NULL)
|
||||
unsigned int mask;
|
||||
|
||||
if (arrayNdx)
|
||||
return ReportIndicatorNotArray(info, led, field);
|
||||
|
||||
if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
|
||||
if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlNames))
|
||||
return ReportIndicatorBadType(info, led, field,
|
||||
"controls mask");
|
||||
|
||||
led->ctrls = rtrn.uval;
|
||||
led->ctrls = mask;
|
||||
led->defined |= _LED_Ctrls;
|
||||
}
|
||||
else if (istreq(field, "allowexplicit")) {
|
||||
|
@ -810,24 +810,28 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
|
|||
}
|
||||
else if (istreq(field, "whichmodstate") ||
|
||||
istreq(field, "whichmodifierstate")) {
|
||||
if (arrayNdx != NULL)
|
||||
unsigned int mask;
|
||||
|
||||
if (arrayNdx)
|
||||
return ReportIndicatorNotArray(info, led, field);
|
||||
|
||||
if (!ExprResolveMask(keymap->ctx, value, &rtrn, modComponentNames))
|
||||
if (!ExprResolveMask(keymap->ctx, value, &mask, modComponentNames))
|
||||
return ReportIndicatorBadType(info, led, field,
|
||||
"mask of modifier state components");
|
||||
|
||||
led->which_mods = rtrn.uval;
|
||||
led->which_mods = mask;
|
||||
}
|
||||
else if (istreq(field, "whichgroupstate")) {
|
||||
if (arrayNdx != NULL)
|
||||
unsigned mask;
|
||||
|
||||
if (arrayNdx)
|
||||
return ReportIndicatorNotArray(info, led, field);
|
||||
|
||||
if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupComponentNames))
|
||||
if (!ExprResolveMask(keymap->ctx, value, &mask, groupComponentNames))
|
||||
return ReportIndicatorBadType(info, led, field,
|
||||
"mask of group state components");
|
||||
|
||||
led->which_groups = rtrn.uval;
|
||||
led->which_groups = mask;
|
||||
}
|
||||
else if (istreq(field, "driveskbd") ||
|
||||
istreq(field, "driveskeyboard") ||
|
||||
|
@ -966,11 +970,11 @@ static int
|
|||
HandleGroupCompatDef(CompatInfo *info, GroupCompatDef *def,
|
||||
enum merge_mode merge)
|
||||
{
|
||||
ExprResult val;
|
||||
xkb_mod_mask_t mask;
|
||||
GroupCompatInfo tmp;
|
||||
|
||||
if (def->merge != MERGE_DEFAULT)
|
||||
merge = def->merge;
|
||||
merge = (def->merge == MERGE_DEFAULT ? merge : def->merge);
|
||||
|
||||
if (def->group < 1 || def->group > XkbNumKbdGroups) {
|
||||
log_err(info->keymap->ctx,
|
||||
"Keyboard group must be in the range 1..%u; "
|
||||
|
@ -978,17 +982,20 @@ HandleGroupCompatDef(CompatInfo *info, GroupCompatDef *def,
|
|||
XkbNumKbdGroups, def->group);
|
||||
return false;
|
||||
}
|
||||
|
||||
tmp.file_id = info->file_id;
|
||||
tmp.merge = merge;
|
||||
if (!ExprResolveVModMask(info->keymap, def->def, &val)) {
|
||||
|
||||
if (!ExprResolveVModMask(info->keymap, def->def, &mask)) {
|
||||
log_err(info->keymap->ctx,
|
||||
"Expected a modifier mask in group compatibility definition; "
|
||||
"Ignoring illegal compatibility map for group %u\n",
|
||||
def->group);
|
||||
return false;
|
||||
}
|
||||
tmp.real_mods = val.uval & 0xff;
|
||||
tmp.vmods = (val.uval >> 8) & 0xffff;
|
||||
|
||||
tmp.real_mods = mask & 0xff;
|
||||
tmp.vmods = (mask >> 8) & 0xffff;
|
||||
tmp.defined = true;
|
||||
return AddGroupCompat(info, def->group - 1, &tmp);
|
||||
}
|
||||
|
|
|
@ -813,26 +813,44 @@ ExprResolveMaskLookup(struct xkb_context *ctx, ExprDef *expr,
|
|||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
ExprResolveMask(struct xkb_context *ctx, ExprDef *expr,
|
||||
ExprResult *val_rtrn, const LookupEntry *values)
|
||||
unsigned int *mask_rtrn, const LookupEntry *values)
|
||||
{
|
||||
return ExprResolveMaskLookup(ctx, expr, val_rtrn, SimpleLookup, values);
|
||||
ExprResult result;
|
||||
bool ok;
|
||||
|
||||
ok = ExprResolveMaskLookup(ctx, expr, &result, SimpleLookup, values);
|
||||
if (ok)
|
||||
*mask_rtrn = (unsigned int) result.ival;
|
||||
return ok;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr,
|
||||
ExprResult *val_rtrn)
|
||||
xkb_mod_mask_t *mask_rtrn)
|
||||
{
|
||||
return ExprResolveMaskLookup(ctx, expr, val_rtrn, LookupModMask, NULL);
|
||||
ExprResult result;
|
||||
bool ok;
|
||||
|
||||
ok = ExprResolveMaskLookup(ctx, expr, &result, LookupModMask, NULL);
|
||||
if (ok)
|
||||
*mask_rtrn = (xkb_mod_mask_t) result.ival;
|
||||
return ok;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
ExprResolveVModMask(struct xkb_keymap *keymap, ExprDef *expr,
|
||||
ExprResult *val_rtrn)
|
||||
xkb_mod_mask_t *mask_rtrn)
|
||||
{
|
||||
return ExprResolveMaskLookup(keymap->ctx, expr, val_rtrn, LookupVModMask,
|
||||
keymap);
|
||||
ExprResult result;
|
||||
bool ok;
|
||||
|
||||
ok = ExprResolveMaskLookup(keymap->ctx, expr, &result, LookupVModMask,
|
||||
keymap);
|
||||
if (ok)
|
||||
*mask_rtrn = (xkb_mod_mask_t) result.ival;
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -58,13 +58,13 @@ extern bool
|
|||
LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
|
||||
enum expr_value_type type, ExprResult *val_rtrn);
|
||||
|
||||
extern int
|
||||
bool
|
||||
ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr,
|
||||
ExprResult *val_rtrn);
|
||||
xkb_mod_mask_t *mask_rtrn);
|
||||
|
||||
extern int
|
||||
bool
|
||||
ExprResolveVModMask(struct xkb_keymap *keymap, ExprDef *expr,
|
||||
ExprResult *val_rtrn);
|
||||
xkb_mod_mask_t *mask_rtrn);
|
||||
|
||||
bool
|
||||
ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr, bool *set_rtrn);
|
||||
|
@ -98,9 +98,9 @@ extern int
|
|||
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
|
||||
const LookupEntry *values);
|
||||
|
||||
extern int
|
||||
ExprResolveMask(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
|
||||
const LookupEntry *values);
|
||||
bool
|
||||
ExprResolveMask(struct xkb_context *ctx, ExprDef *expr,
|
||||
unsigned int *mask_rtrn, const LookupEntry *values);
|
||||
|
||||
bool
|
||||
ExprResolveKeySym(struct xkb_context *ctx, ExprDef *expr,
|
||||
|
|
|
@ -531,21 +531,21 @@ static bool
|
|||
SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
|
||||
ExprDef *value)
|
||||
{
|
||||
ExprResult rtrn;
|
||||
unsigned int level;
|
||||
struct xkb_kt_map_entry entry;
|
||||
xkb_mod_mask_t mask;
|
||||
|
||||
if (arrayNdx == NULL)
|
||||
return ReportTypeShouldBeArray(info, type, "map entry");
|
||||
|
||||
if (!ExprResolveVModMask(info->keymap, arrayNdx, &rtrn))
|
||||
if (!ExprResolveVModMask(info->keymap, arrayNdx, &mask))
|
||||
return ReportTypeBadType(info, type, "map entry", "modifier mask");
|
||||
|
||||
entry.mods.real_mods = rtrn.uval & 0xff; /* modifiers < 512 */
|
||||
entry.mods.vmods = (rtrn.uval >> 8) & 0xffff; /* modifiers > 512 */
|
||||
entry.mods.real_mods = mask & 0xff; /* modifiers < 512 */
|
||||
entry.mods.vmods = (mask >> 8) & 0xffff; /* modifiers > 512 */
|
||||
|
||||
if ((entry.mods.real_mods & (~type->mask)) ||
|
||||
((entry.mods.vmods & (~type->vmask)) != 0)) {
|
||||
(entry.mods.vmods & (~type->vmask))) {
|
||||
log_lvl(info->keymap->ctx, 1,
|
||||
"Map entry for unused modifiers in %s; "
|
||||
"Using %s instead of %s\n",
|
||||
|
@ -574,18 +574,18 @@ static bool
|
|||
SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
|
||||
ExprDef *value)
|
||||
{
|
||||
ExprResult rtrn;
|
||||
xkb_mod_mask_t mask;
|
||||
PreserveInfo new;
|
||||
|
||||
if (arrayNdx == NULL)
|
||||
return ReportTypeShouldBeArray(info, type, "preserve entry");
|
||||
|
||||
if (!ExprResolveVModMask(info->keymap, arrayNdx, &rtrn))
|
||||
if (!ExprResolveVModMask(info->keymap, arrayNdx, &mask))
|
||||
return ReportTypeBadType(info, type, "preserve entry",
|
||||
"modifier mask");
|
||||
|
||||
new.indexMods = rtrn.uval & 0xff;
|
||||
new.indexVMods = (rtrn.uval >> 8) & 0xffff;
|
||||
new.indexMods = mask & 0xff;
|
||||
new.indexVMods = (mask >> 8) & 0xffff;
|
||||
|
||||
if ((new.indexMods & (~type->mask)) ||
|
||||
(new.indexVMods & (~type->vmask))) {
|
||||
|
@ -601,7 +601,7 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
|
|||
PreserveIndexTxt(info, &new));
|
||||
}
|
||||
|
||||
if (!ExprResolveVModMask(info->keymap, value, &rtrn)) {
|
||||
if (!ExprResolveVModMask(info->keymap, value, &mask)) {
|
||||
log_err(info->keymap->ctx,
|
||||
"Preserve value in a key type is not a modifier mask; "
|
||||
"Ignoring preserve[%s] in type %s\n",
|
||||
|
@ -609,8 +609,8 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
|
|||
return false;
|
||||
}
|
||||
|
||||
new.preMods = rtrn.uval & 0xff;
|
||||
new.preVMods = (rtrn.uval >> 16) & 0xffff;
|
||||
new.preMods = mask & 0xff;
|
||||
new.preVMods = (mask >> 16) & 0xffff;
|
||||
|
||||
if ((new.preMods & (~new.indexMods)) ||
|
||||
(new.preVMods & (~new.indexVMods))) {
|
||||
|
@ -705,23 +705,24 @@ static bool
|
|||
SetKeyTypeField(KeyTypesInfo *info, KeyTypeInfo *type,
|
||||
const char *field, ExprDef *arrayNdx, ExprDef *value)
|
||||
{
|
||||
ExprResult tmp;
|
||||
|
||||
if (istreq(field, "modifiers")) {
|
||||
unsigned mods, vmods;
|
||||
if (arrayNdx != NULL)
|
||||
xkb_mod_mask_t mask, mods, vmods;
|
||||
|
||||
if (arrayNdx)
|
||||
log_warn(info->keymap->ctx,
|
||||
"The modifiers field of a key type is not an array; "
|
||||
"Illegal array subscript ignored\n");
|
||||
|
||||
/* get modifier mask for current type */
|
||||
if (!ExprResolveVModMask(info->keymap, value, &tmp)) {
|
||||
if (!ExprResolveVModMask(info->keymap, value, &mask)) {
|
||||
log_err(info->keymap->ctx,
|
||||
"Key type mask field must be a modifier mask; "
|
||||
"Key type definition ignored\n");
|
||||
return false;
|
||||
}
|
||||
mods = tmp.uval & 0xff; /* core mods */
|
||||
vmods = (tmp.uval >> 8) & 0xffff; /* xkb virtual mods */
|
||||
|
||||
mods = mask & 0xff; /* core mods */
|
||||
vmods = (mask >> 8) & 0xffff; /* xkb virtual mods */
|
||||
if (type->defined & _KT_Mask) {
|
||||
log_warn(info->keymap->ctx,
|
||||
"Multiple modifier mask definitions for key type %s; "
|
||||
|
|
|
@ -1061,9 +1061,11 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
|||
else if (istreq(field, "vmods") ||
|
||||
istreq(field, "virtualmods") ||
|
||||
istreq(field, "virtualmodifiers")) {
|
||||
ok = ExprResolveVModMask(info->keymap, value, &tmp);
|
||||
xkb_mod_mask_t mask;
|
||||
|
||||
ok = ExprResolveVModMask(info->keymap, value, &mask);
|
||||
if (ok) {
|
||||
keyi->vmodmap = (tmp.uval >> 8);
|
||||
keyi->vmodmap = (mask >> 8);
|
||||
keyi->defined |= _Key_VModMap;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -66,7 +66,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
|
|||
xkb_mod_index_t i;
|
||||
int nextFree;
|
||||
xkb_mod_mask_t bit;
|
||||
ExprResult mod;
|
||||
xkb_mod_mask_t mask;
|
||||
|
||||
nextFree = -1;
|
||||
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
|
||||
|
@ -92,19 +92,19 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
|
|||
if (!stmt->value)
|
||||
return true;
|
||||
|
||||
if (!ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
|
||||
if (!ExprResolveModMask(keymap->ctx, stmt->value, &mask)) {
|
||||
log_err(keymap->ctx, "Declaration of %s ignored\n",
|
||||
xkb_atom_text(keymap->ctx, stmt->name));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mod.uval == keymap->vmods[i])
|
||||
if (mask == keymap->vmods[i])
|
||||
return true;
|
||||
|
||||
str1 = ModMaskText(keymap->vmods[i], true);
|
||||
if (mergeMode == MERGE_OVERRIDE) {
|
||||
str2 = str1;
|
||||
str1 = ModMaskText(mod.uval, true);
|
||||
str1 = ModMaskText(mask, true);
|
||||
}
|
||||
|
||||
log_warn(keymap->ctx,
|
||||
|
@ -113,7 +113,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
|
|||
xkb_atom_text(keymap->ctx, stmt->name), str1, str2);
|
||||
|
||||
if (mergeMode == MERGE_OVERRIDE)
|
||||
keymap->vmods[i] = mod.uval;
|
||||
keymap->vmods[i] = mask;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -134,13 +134,13 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
|
|||
if (!stmt->value)
|
||||
return true;
|
||||
|
||||
if (!ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
|
||||
if (!ExprResolveModMask(keymap->ctx, stmt->value, &mask)) {
|
||||
log_err(keymap->ctx, "Declaration of %s ignored\n",
|
||||
xkb_atom_text(keymap->ctx, stmt->name));
|
||||
return false;
|
||||
}
|
||||
|
||||
keymap->vmods[nextFree] = mod.uval;
|
||||
keymap->vmods[nextFree] = mask;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue