Esempio n. 1
0
static bool
HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
               enum action_field field, const ExprDef *array_ndx,
               const ExprDef *value)
{
    struct xkb_mod_action *act = &action->mods;
    enum xkb_action_flags t1;
    xkb_mod_mask_t t2;

    if (array_ndx && field == ACTION_FIELD_MODIFIERS)
        return ReportActionNotArray(keymap, action->type, field);

    switch (field) {
    case ACTION_FIELD_MODIFIERS:
        t1 = act->flags;
        if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
            act->flags = t1;
            act->mods.mods = t2;
            return true;
        }
        return false;

    default:
        break;
    }

    return ReportIllegal(keymap, action->type, field);
}
Esempio n. 2
0
static bool
HandleSetLatchLockMods(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_mod_action *act = &action->mods;
    const enum xkb_action_type type = action->type;

    if (field == ACTION_FIELD_MODIFIERS)
        return CheckModifierField(ctx, mods, action->type, array_ndx, value,
                                  &act->flags, &act->mods.mods);
    if ((type == ACTION_TYPE_MOD_SET || type == ACTION_TYPE_MOD_LATCH) &&
        field == ACTION_FIELD_CLEAR_LOCKS)
        return CheckBooleanFlag(ctx, action->type, field,
                                ACTION_LOCK_CLEAR, array_ndx, value,
                                &act->flags);
    if (type == ACTION_TYPE_MOD_LATCH &&
        field == ACTION_FIELD_LATCH_TO_LOCK)
        return CheckBooleanFlag(ctx, action->type, field,
                                ACTION_LATCH_TO_LOCK, array_ndx, value,
                                &act->flags);
    if (type == ACTION_TYPE_MOD_LOCK &&
        field == ACTION_FIELD_AFFECT)
        return CheckAffectField(ctx, action->type, array_ndx, value,
                                &act->flags);

    return ReportIllegal(ctx, action->type, field);
}
Esempio n. 3
0
static bool
HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
                   enum action_field field, const ExprDef *array_ndx,
                   const ExprDef *value)
{
    struct xkb_mod_action *act = &action->mods;
    enum xkb_action_flags rtrn, t1;
    xkb_mod_mask_t t2;

    if (array_ndx != NULL) {
        switch (field) {
        case ACTION_FIELD_CLEAR_LOCKS:
        case ACTION_FIELD_LATCH_TO_LOCK:
        case ACTION_FIELD_MODIFIERS:
            return ReportActionNotArray(keymap, action->type, field);
        default:
            break;
        }
    }

    switch (field) {
    case ACTION_FIELD_CLEAR_LOCKS:
    case ACTION_FIELD_LATCH_TO_LOCK:
        rtrn = act->flags;
        if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
            act->flags = rtrn;
            return true;
        }
        return false;

    case ACTION_FIELD_MODIFIERS:
        t1 = act->flags;
        if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
            act->flags = t1;
            act->mods.mods = t2;
            return true;
        }
        return false;

    default:
        break;
    }

    return ReportIllegal(keymap, action->type, field);
}