static bool HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action, enum action_field field, const ExprDef *array_ndx, const ExprDef *value) { struct xkb_pointer_default_action *act = &action->dflt; if (field == ACTION_FIELD_AFFECT) { unsigned int val; if (array_ndx) return ReportActionNotArray(keymap, action->type, field); if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts)) return ReportMismatch(keymap, action->type, field, "pointer component"); return true; } else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) { const ExprDef *button; int btn; if (array_ndx) return ReportActionNotArray(keymap, action->type, field); if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) { act->flags &= ~ACTION_ABSOLUTE_SWITCH; button = value->unary.child; } else { act->flags |= ACTION_ABSOLUTE_SWITCH; button = value; } if (!ExprResolveButton(keymap->ctx, button, &btn)) return ReportMismatch(keymap, action->type, field, "integer (range 1..5)"); if (btn < 0 || btn > 5) { log_err(keymap->ctx, "New default button value must be in the range 1..5; " "Illegal default button value %d ignored\n", btn); return false; } if (btn == 0) { log_err(keymap->ctx, "Cannot set default pointer button to \"default\"; " "Illegal default button setting ignored\n"); return false; } act->value = (value->expr.op == EXPR_NEGATE ? -btn: btn); return true; } return ReportIllegal(keymap, action->type, field); }
static bool HandlePtrBtn(struct xkb_context *ctx, const struct xkb_mod_set *mods, union xkb_action *action, enum action_field field, const ExprDef *array_ndx, const ExprDef *value) { struct xkb_pointer_button_action *act = &action->btn; if (field == ACTION_FIELD_BUTTON) { int btn; if (array_ndx) return ReportActionNotArray(ctx, action->type, field); if (!ExprResolveButton(ctx, value, &btn)) return ReportMismatch(ctx, action->type, field, "integer (range 1..5)"); if (btn < 0 || btn > 5) { log_err(ctx, "Button must specify default or be in the range 1..5; " "Illegal button value %d ignored\n", btn); return false; } act->button = btn; return true; } else if (action->type == ACTION_TYPE_PTR_LOCK && field == ACTION_FIELD_AFFECT) { return CheckAffectField(ctx, action->type, array_ndx, value, &act->flags); } else if (field == ACTION_FIELD_COUNT) { int val; if (array_ndx) return ReportActionNotArray(ctx, action->type, field); if (!ExprResolveInteger(ctx, value, &val)) return ReportMismatch(ctx, action->type, field, "integer"); if (val < 0 || val > 255) { log_err(ctx, "The count field must have a value in the range 0..255; " "Illegal count %d ignored\n", val); return false; } act->count = (uint8_t) val; return true; } return ReportIllegal(ctx, action->type, field); }
static bool HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action, enum action_field field, const ExprDef *array_ndx, const ExprDef *value) { struct xkb_pointer_button_action *act = &action->btn; if (field == ACTION_FIELD_BUTTON) { int btn; if (array_ndx) return ReportActionNotArray(keymap, action->type, field); if (!ExprResolveButton(keymap->ctx, value, &btn)) return ReportMismatch(keymap, action->type, field, "integer (range 1..5)"); if (btn < 0 || btn > 5) { log_err(keymap->ctx, "Button must specify default or be in the range 1..5; " "Illegal button value %d ignored\n", btn); return false; } act->button = btn; return true; } 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; } else if (field == ACTION_FIELD_COUNT) { int btn; if (array_ndx) return ReportActionNotArray(keymap, action->type, field); /* XXX: Should this actually be ResolveButton? */ if (!ExprResolveButton(keymap->ctx, value, &btn)) return ReportMismatch(keymap, action->type, field, "integer"); if (btn < 0 || btn > 255) { log_err(keymap->ctx, "The count field must have a value in the range 0..255; " "Illegal count %d ignored\n", btn); return false; } act->count = btn; return true; } return ReportIllegal(keymap, action->type, field); }