From 70c775f69d2a5ac529468a7d296523ecc171f547 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 10 Sep 2012 20:38:46 +0100 Subject: [PATCH] kbproto unentanglement: action flags Signed-off-by: Daniel Stone --- src/keymap-dump.c | 35 +++++++++++++------------- src/state.c | 18 ++++++------- src/xkb-priv.h | 29 +++++++++++++++------ src/xkbcomp/action.c | 60 +++++++++++++++++++++----------------------- src/xkbcomp/keymap.c | 2 +- 5 files changed, 79 insertions(+), 65 deletions(-) diff --git a/src/keymap-dump.c b/src/keymap-dump.c index cca6313..6a139a1 100644 --- a/src/keymap-dump.c +++ b/src/keymap-dump.c @@ -385,16 +385,16 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, case ACTION_TYPE_MOD_SET: case ACTION_TYPE_MOD_LATCH: case ACTION_TYPE_MOD_LOCK: - if (action->mods.flags & XkbSA_UseModMapMods) + if (action->mods.flags & ACTION_MODS_LOOKUP_MODMAP) args = "modMapMods"; else args = VModMaskText(keymap, action->mods.mods.mods); write_buf(buf, "%s%s(modifiers=%s%s%s)%s", prefix, type, args, (action->type != ACTION_TYPE_MOD_LOCK && - (action->mods.flags & XkbSA_ClearLocks)) ? + (action->mods.flags & ACTION_LOCK_CLEAR)) ? ",clearLocks" : "", (action->type != ACTION_TYPE_MOD_LOCK && - (action->mods.flags & XkbSA_LatchToLock)) ? + (action->mods.flags & ACTION_LATCH_TO_LOCK)) ? ",latchToLock" : "", suffix); break; @@ -403,15 +403,15 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, case ACTION_TYPE_GROUP_LATCH: case ACTION_TYPE_GROUP_LOCK: write_buf(buf, "%s%s(group=%s%d%s%s)%s", prefix, type, - (!(action->group.flags & XkbSA_GroupAbsolute) && + (!(action->group.flags & ACTION_ABSOLUTE_SWITCH) && action->group.group > 0) ? "+" : "", - (action->group.flags & XkbSA_GroupAbsolute) ? + (action->group.flags & ACTION_ABSOLUTE_SWITCH) ? action->group.group + 1 : action->group.group, (action->type != ACTION_TYPE_GROUP_LOCK && - (action->group.flags & XkbSA_ClearLocks)) ? + (action->group.flags & ACTION_LOCK_CLEAR)) ? ",clearLocks" : "", (action->type != ACTION_TYPE_GROUP_LOCK && - (action->group.flags & XkbSA_LatchToLock)) ? + (action->group.flags & ACTION_LATCH_TO_LOCK)) ? ",latchToLock" : "", suffix); break; @@ -422,27 +422,28 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, case ACTION_TYPE_PTR_MOVE: write_buf(buf, "%s%s(x=%s%d,y=%s%d%s)%s", prefix, type, - (!(action->ptr.flags & XkbSA_MoveAbsoluteX) && + (!(action->ptr.flags & ACTION_ABSOLUTE_X) && action->ptr.x >= 0) ? "+" : "", action->ptr.x, - (!(action->ptr.flags & XkbSA_MoveAbsoluteY) && + (!(action->ptr.flags & ACTION_ABSOLUTE_Y) && action->ptr.y >= 0) ? "+" : "", action->ptr.y, - (action->ptr.flags & XkbSA_NoAcceleration) ? ",!accel" : "", + (action->ptr.flags & ACTION_NO_ACCEL) ? ",!accel" : "", suffix); break; case ACTION_TYPE_PTR_LOCK: - switch (action->btn.flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) { - case XkbSA_LockNoUnlock: + switch (action->btn.flags & + (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK)) { + case ACTION_LOCK_NO_UNLOCK: args = ",affect=lock"; break; - case XkbSA_LockNoLock: + case ACTION_LOCK_NO_LOCK: args = ",affect=unlock"; break; - case XkbSA_LockNoLock | XkbSA_LockNoUnlock: + case ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK: args = ",affect=neither"; break; @@ -467,7 +468,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, write_buf(buf, "%s%s(", prefix, type); if (action->dflt.affect == XkbSA_AffectDfltBtn) write_buf(buf, "affect=button,button=%s%d", - (!(action->dflt.flags & XkbSA_DfltBtnAbsolute) && + (!(action->dflt.flags & ACTION_ABSOLUTE_SWITCH) && action->dflt.value >= 0) ? "+" : "", action->dflt.value); write_buf(buf, ")%s", suffix); @@ -475,10 +476,10 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, case ACTION_TYPE_SWITCH_VT: write_buf(buf, "%s%s(screen=%s%d,%ssame)%s", prefix, type, - (!(action->screen.flags & XkbSA_SwitchAbsolute) && + (!(action->screen.flags & ACTION_ABSOLUTE_SWITCH) && action->screen.screen >= 0) ? "+" : "", action->screen.screen, - (action->screen.flags & XkbSA_SwitchApplication) ? "!" : "", + (action->screen.flags & ACTION_SAME_SCREEN) ? "!" : "", suffix); break; diff --git a/src/state.c b/src/state.c index d62677c..d6f4a53 100644 --- a/src/state.c +++ b/src/state.c @@ -161,7 +161,7 @@ xkb_filter_group_set_func(struct xkb_filter *filter, xkb_keycode_t kc, enum xkb_key_direction direction) { if (kc != filter->kc) { - filter->action.group.flags &= ~XkbSA_ClearLocks; + filter->action.group.flags &= ~ACTION_LOCK_CLEAR; return 1; } @@ -173,11 +173,11 @@ xkb_filter_group_set_func(struct xkb_filter *filter, xkb_keycode_t kc, return 0; } - if (filter->action.group.flags & XkbSA_GroupAbsolute) + if (filter->action.group.flags & ACTION_ABSOLUTE_SWITCH) filter->state->base_group = filter->action.group.group; else filter->state->base_group = -filter->action.group.group; - if (filter->action.group.flags & XkbSA_ClearLocks) + if (filter->action.group.flags & ACTION_LOCK_CLEAR) filter->state->locked_group = 0; filter->func = NULL; @@ -197,7 +197,7 @@ xkb_filter_group_set_new(struct xkb_state *state, xkb_keycode_t kc, filter->func = xkb_filter_group_set_func; filter->action = *action; - if (action->group.flags & XkbSA_GroupAbsolute) { + if (action->group.flags & ACTION_ABSOLUTE_SWITCH) { filter->action.group.group = filter->state->base_group; filter->state->base_group = action->group.group; } @@ -239,7 +239,7 @@ xkb_filter_group_lock_new(struct xkb_state *state, xkb_keycode_t kc, filter->func = xkb_filter_group_lock_func; filter->action = *action; - if (action->group.flags & XkbSA_GroupAbsolute) + if (action->group.flags & ACTION_ABSOLUTE_SWITCH) filter->state->locked_group = action->group.group; else filter->state->locked_group += action->group.group; @@ -252,7 +252,7 @@ xkb_filter_mod_set_func(struct xkb_filter *filter, xkb_keycode_t kc, enum xkb_key_direction direction) { if (kc != filter->kc) { - filter->action.mods.flags &= ~XkbSA_ClearLocks; + filter->action.mods.flags &= ~ACTION_LOCK_CLEAR; return 1; } @@ -265,7 +265,7 @@ xkb_filter_mod_set_func(struct xkb_filter *filter, xkb_keycode_t kc, } filter->state->clear_mods = filter->action.mods.mods.mask; - if (filter->action.mods.flags & XkbSA_ClearLocks) + if (filter->action.mods.flags & ACTION_LOCK_CLEAR) filter->state->locked_mods &= ~filter->action.mods.mods.mask; filter->func = NULL; @@ -367,7 +367,7 @@ xkb_filter_mod_latch_func(struct xkb_filter *filter, xkb_keycode_t kc, action->mods.flags == filter->action.mods.flags && action->mods.mods.mask == filter->action.mods.mods.mask) { filter->action = *action; - if (filter->action.mods.flags & XkbSA_LatchToLock) { + if (filter->action.mods.flags & ACTION_LATCH_TO_LOCK) { filter->action.type = ACTION_TYPE_MOD_LOCK; filter->func = xkb_filter_mod_lock_func; filter->state->locked_mods |= filter->action.mods.mods.mask; @@ -397,7 +397,7 @@ xkb_filter_mod_latch_func(struct xkb_filter *filter, xkb_keycode_t kc, * stage, so set PENDING and move our modifier from base to * latched. */ if (latch == NO_LATCH || - ((filter->action.mods.flags & XkbSA_ClearLocks) && + ((filter->action.mods.flags & ACTION_LOCK_CLEAR) && (filter->state->locked_mods & filter->action.mods.mods.mask) == filter->action.mods.mods.mask)) { /* XXX: We might be a bit overenthusiastic about clearing diff --git a/src/xkb-priv.h b/src/xkb-priv.h index d9ec6a0..a36ebbe 100644 --- a/src/xkb-priv.h +++ b/src/xkb-priv.h @@ -153,6 +153,19 @@ enum xkb_action_type { ACTION_TYPE_LAST }; +enum xkb_action_flags { + ACTION_LOCK_CLEAR = (1 << 0), + ACTION_LATCH_TO_LOCK = (1 << 1), + ACTION_LOCK_NO_LOCK = (1 << 2), + ACTION_LOCK_NO_UNLOCK = (1 << 3), + ACTION_MODS_LOOKUP_MODMAP = (1 << 4), + ACTION_ABSOLUTE_SWITCH = (1 << 5), + ACTION_ABSOLUTE_X = (1 << 6), + ACTION_ABSOLUTE_Y = (1 << 7), + ACTION_NO_ACCEL = (1 << 8), + ACTION_SAME_SCREEN = (1 << 9), +}; + struct xkb_mods { xkb_mod_mask_t mods; /* original real+virtual mods in definition */ xkb_mod_mask_t mask; /* computed effective mask */ @@ -160,37 +173,38 @@ struct xkb_mods { struct xkb_mod_action { enum xkb_action_type type; - uint8_t flags; + enum xkb_action_flags flags; struct xkb_mods mods; }; struct xkb_group_action { enum xkb_action_type type; - uint8_t flags; + enum xkb_action_flags flags; int32_t group; }; struct xkb_controls_action { enum xkb_action_type type; - uint8_t flags; + enum xkb_action_flags flags; uint32_t ctrls; }; struct xkb_pointer_default_action { enum xkb_action_type type; - uint8_t flags; + enum xkb_action_flags flags; uint8_t affect; int8_t value; }; struct xkb_switch_screen_action { enum xkb_action_type type; - uint8_t flags; + enum xkb_action_flags flags; int8_t screen; }; struct xkb_redirect_key_action { enum xkb_action_type type; + enum xkb_action_flags flags; xkb_keycode_t new_kc; uint8_t mods_mask; uint8_t mods; @@ -200,20 +214,21 @@ struct xkb_redirect_key_action { struct xkb_pointer_action { enum xkb_action_type type; - uint8_t flags; + enum xkb_action_flags flags; int16_t x; int16_t y; }; struct xkb_pointer_button_action { enum xkb_action_type type; - uint8_t flags; + enum xkb_action_flags flags; uint8_t count; int8_t button; }; struct xkb_private_action { enum xkb_action_type type; + enum xkb_action_flags flags; uint8_t data[7]; }; diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c index 1ef9498..f5b3264 100644 --- a/src/xkbcomp/action.c +++ b/src/xkbcomp/action.c @@ -213,15 +213,15 @@ HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action, static bool CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action, enum action_field field, const ExprDef * value, - unsigned *flags_inout) + enum xkb_action_flags *flags_inout) { - unsigned tmp; + enum xkb_action_flags tmp; bool result; if (field == ACTION_FIELD_CLEAR_LOCKS) - tmp = XkbSA_ClearLocks; + tmp = ACTION_LOCK_CLEAR; else if (field == ACTION_FIELD_LATCH_TO_LOCK) - tmp = XkbSA_LatchToLock; + tmp = ACTION_LATCH_TO_LOCK; else return false; /* WSGO! */ @@ -238,7 +238,7 @@ CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action, static bool CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action, - const ExprDef *value, unsigned *flags_inout, + const ExprDef *value, enum xkb_action_flags *flags_inout, xkb_mod_mask_t *mods_rtrn) { if (value->op == EXPR_IDENT) { @@ -248,7 +248,7 @@ CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action, istreq(valStr, "modmapmods"))) { *mods_rtrn = 0; - *flags_inout |= XkbSA_UseModMapMods; + *flags_inout |= ACTION_MODS_LOOKUP_MODMAP; return true; } } @@ -257,7 +257,7 @@ CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action, return ReportMismatch(keymap, action, ACTION_FIELD_MODIFIERS, "modifier mask"); - *flags_inout &= ~XkbSA_UseModMapMods; + *flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP; return true; } @@ -267,8 +267,7 @@ HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action, const ExprDef *value) { struct xkb_mod_action *act = &action->mods; - unsigned rtrn; - unsigned t1; + enum xkb_action_flags rtrn, t1; xkb_mod_mask_t t2; if (array_ndx != NULL) { @@ -314,7 +313,7 @@ HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action, const ExprDef *value) { struct xkb_mod_action *act = &action->mods; - unsigned t1; + enum xkb_action_flags t1; xkb_mod_mask_t t2; if (array_ndx && field == ACTION_FIELD_MODIFIERS) @@ -339,17 +338,17 @@ HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action, static bool CheckGroupField(struct xkb_keymap *keymap, unsigned action, - const ExprDef *value, unsigned *flags_inout, + const ExprDef *value, enum xkb_action_flags *flags_inout, xkb_group_index_t *grp_rtrn) { const ExprDef *spec; if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) { - *flags_inout &= ~XkbSA_GroupAbsolute; + *flags_inout &= ~ACTION_ABSOLUTE_SWITCH; spec = value->value.child; } else { - *flags_inout |= XkbSA_GroupAbsolute; + *flags_inout |= ACTION_ABSOLUTE_SWITCH; spec = value; } @@ -371,8 +370,7 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action, const ExprDef *value) { struct xkb_group_action *act = &action->group; - unsigned rtrn; - unsigned t1; + enum xkb_action_flags rtrn, t1; xkb_group_index_t t2; if (array_ndx != NULL) { @@ -419,7 +417,7 @@ HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action, const ExprDef *value) { struct xkb_group_action *act = &action->group; - unsigned t1; + enum xkb_action_flags t1; xkb_group_index_t t2; if ((array_ndx != NULL) && (field == ACTION_FIELD_GROUP)) @@ -460,12 +458,12 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action, if (field == ACTION_FIELD_X) { if (absolute) - act->flags |= XkbSA_MoveAbsoluteX; + act->flags |= ACTION_ABSOLUTE_X; act->x = val; } else { if (absolute) - act->flags |= XkbSA_MoveAbsoluteY; + act->flags |= ACTION_ABSOLUTE_Y; act->y = val; } @@ -478,9 +476,9 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action, return ReportMismatch(keymap, action->type, field, "boolean"); if (set) - act->flags &= ~XkbSA_NoAcceleration; + act->flags &= ~ACTION_NO_ACCEL; else - act->flags |= XkbSA_NoAcceleration; + act->flags |= ACTION_NO_ACCEL; } return ReportIllegal(keymap, action->type, field); @@ -488,9 +486,9 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action, static const LookupEntry lockWhich[] = { { "both", 0 }, - { "lock", XkbSA_LockNoUnlock }, - { "neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock) }, - { "unlock", XkbSA_LockNoLock }, + { "lock", ACTION_LOCK_NO_UNLOCK }, + { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) }, + { "unlock", ACTION_LOCK_NO_LOCK }, { NULL, 0 } }; @@ -523,7 +521,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action, } else if (action->type == ACTION_TYPE_PTR_LOCK && field == ACTION_FIELD_AFFECT) { - unsigned int val; + enum xkb_action_flags val; if (array_ndx) return ReportActionNotArray(keymap, action->type, field); @@ -532,7 +530,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action, return ReportMismatch(keymap, action->type, field, "lock or unlock"); - act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock); + act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK); act->flags |= val; return true; } @@ -593,11 +591,11 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action, return ReportActionNotArray(keymap, action->type, field); if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) { - act->flags &= ~XkbSA_DfltBtnAbsolute; + act->flags &= ~ACTION_ABSOLUTE_SWITCH; button = value->value.child; } else { - act->flags |= XkbSA_DfltBtnAbsolute; + act->flags |= ACTION_ABSOLUTE_SWITCH; button = value; } @@ -640,11 +638,11 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action, return ReportActionNotArray(keymap, action->type, field); if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) { - act->flags &= ~XkbSA_SwitchAbsolute; + act->flags &= ~ACTION_ABSOLUTE_SWITCH; scrn = value->value.child; } else { - act->flags |= XkbSA_SwitchAbsolute; + act->flags |= ACTION_ABSOLUTE_SWITCH; scrn = value; } @@ -672,9 +670,9 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action, return ReportMismatch(keymap, action->type, field, "boolean"); if (set) - act->flags &= ~XkbSA_SwitchApplication; + act->flags &= ~ACTION_SAME_SCREEN; else - act->flags |= XkbSA_SwitchApplication; + act->flags |= ACTION_SAME_SCREEN; return true; } diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c index aa113fd..210ccac 100644 --- a/src/xkbcomp/keymap.c +++ b/src/xkbcomp/keymap.c @@ -61,7 +61,7 @@ UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act, return; } - if (flags & XkbSA_UseModMapMods) { + if (flags & ACTION_MODS_LOOKUP_MODMAP) { /* XXX: what's that. */ mods->mods &= 0xff; mods->mods |= rmodmask;