diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/keymap-dump.c | 20 | ||||
-rw-r--r-- | src/xkb-priv.h | 12 | ||||
-rw-r--r-- | src/xkbcomp/action.c | 96 | ||||
-rw-r--r-- | src/xkbcomp/action.h | 2 | ||||
-rw-r--r-- | src/xkbcomp/compat.c | 11 | ||||
-rw-r--r-- | src/xkbcomp/symbols.c | 4 |
6 files changed, 63 insertions, 82 deletions
diff --git a/src/keymap-dump.c b/src/keymap-dump.c index f04f6cc..f406f31 100644 --- a/src/keymap-dump.c +++ b/src/keymap-dump.c @@ -397,9 +397,9 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, if (!suffix) suffix = ""; - type = ActionTypeText(action->any.type); + type = ActionTypeText(action->type); - switch (action->any.type) { + switch (action->type) { case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods: @@ -408,10 +408,10 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, else args = VModMaskText(keymap, action->mods.mods.mods); write_buf(buf, "%s%s(modifiers=%s%s%s)%s", prefix, type, args, - (action->any.type != XkbSA_LockGroup && + (action->type != XkbSA_LockGroup && (action->mods.flags & XkbSA_ClearLocks)) ? ",clearLocks" : "", - (action->any.type != XkbSA_LockGroup && + (action->type != XkbSA_LockGroup && (action->mods.flags & XkbSA_LatchToLock)) ? ",latchToLock" : "", suffix); @@ -425,10 +425,10 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, action->group.group > 0) ? "+" : "", (action->group.flags & XkbSA_GroupAbsolute) ? action->group.group + 1 : action->group.group, - (action->any.type != XkbSA_LockGroup && + (action->type != XkbSA_LockGroup && (action->group.flags & XkbSA_ClearLocks)) ? ",clearLocks" : "", - (action->any.type != XkbSA_LockGroup && + (action->type != XkbSA_LockGroup && (action->group.flags & XkbSA_LatchToLock)) ? ",latchToLock" : "", suffix); @@ -521,10 +521,10 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, default: write_buf(buf, "%s%s(type=0x%02x,data[0]=0x%02x,data[1]=0x%02x,data[2]=0x%02x,data[3]=0x%02x,data[4]=0x%02x,data[5]=0x%02x,data[6]=0x%02x)%s", - prefix, type, action->any.type, action->any.data[0], - action->any.data[1], action->any.data[2], - action->any.data[3], action->any.data[4], - action->any.data[5], action->any.data[6], + prefix, type, action->type, action->priv.data[0], + action->priv.data[1], action->priv.data[2], + action->priv.data[3], action->priv.data[4], + action->priv.data[5], action->priv.data[6], suffix); break; } diff --git a/src/xkb-priv.h b/src/xkb-priv.h index f53805f..61ba590 100644 --- a/src/xkb-priv.h +++ b/src/xkb-priv.h @@ -148,11 +148,6 @@ struct xkb_mods { xkb_mod_mask_t mask; /* computed effective mask */ }; -struct xkb_any_action { - uint8_t type; - uint8_t data[7]; -}; - struct xkb_mod_action { uint8_t type; uint8_t flags; @@ -240,8 +235,12 @@ struct xkb_pointer_button_action { int8_t button; }; +struct xkb_private_action { + uint8_t type; + uint8_t data[7]; +}; + union xkb_action { - struct xkb_any_action any; struct xkb_mod_action mods; struct xkb_group_action group; struct xkb_iso_action iso; @@ -254,6 +253,7 @@ union xkb_action { struct xkb_pointer_action ptr; /* XXX delete for DeviceValuator */ struct xkb_pointer_button_action btn; /* XXX delete for DeviceBtn */ struct xkb_message_action msg; /* XXX just delete */ + struct xkb_private_action priv; unsigned char type; }; diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c index a2dd9ed..0d37688 100644 --- a/src/xkbcomp/action.c +++ b/src/xkbcomp/action.c @@ -219,7 +219,7 @@ ReportNotFound(struct xkb_keymap *keymap, unsigned action, unsigned field, } static bool -HandleNoAction(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { @@ -277,16 +277,15 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action, } static bool -HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_mod_action *act; + struct xkb_mod_action *act = &action->mods; unsigned rtrn; unsigned t1; xkb_mod_mask_t t2; - act = (struct xkb_mod_action *) action; if (array_ndx != NULL) { switch (field) { case F_ClearLocks: @@ -318,14 +317,13 @@ HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action, } static bool -HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_mod_action *act; + struct xkb_mod_action *act = &action->mods; unsigned t1; xkb_mod_mask_t t2; - act = (struct xkb_mod_action *) action; if ((array_ndx != NULL) && (field == F_Modifiers)) return ReportActionNotArray(keymap, action->type, field); switch (field) { @@ -370,16 +368,15 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action, } static bool -HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_group_action *act; + struct xkb_group_action *act = &action->group; unsigned rtrn; unsigned t1; xkb_group_index_t t2; - act = (struct xkb_group_action *) action; if (array_ndx != NULL) { switch (field) { case F_ClearLocks: @@ -411,15 +408,14 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action, } static bool -HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_group_action *act; + struct xkb_group_action *act = &action->group; unsigned t1; xkb_group_index_t t2; - act = (struct xkb_group_action *) action; if ((array_ndx != NULL) && (field == F_Group)) return ReportActionNotArray(keymap, action->type, field); if (field == F_Group) { @@ -435,13 +431,12 @@ HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action, } static bool -HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_pointer_action *act; + struct xkb_pointer_action *act = &action->ptr; bool absolute; - act = (struct xkb_pointer_action *) action; if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y))) return ReportActionNotArray(keymap, action->type, field); @@ -493,12 +488,11 @@ static const LookupEntry lockWhich[] = { }; static bool -HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_pointer_button_action *act; + struct xkb_pointer_button_action *act = &action->btn; - act = (struct xkb_pointer_button_action *) action; if (field == F_Button) { int btn; @@ -564,13 +558,12 @@ static const LookupEntry ptrDflts[] = { }; static bool -HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_pointer_default_action *act; + struct xkb_pointer_default_action *act = &action->dflt; - act = (struct xkb_pointer_default_action *) action; if (field == F_Affect) { unsigned int val; @@ -638,12 +631,11 @@ static const LookupEntry isoNames[] = { }; static bool -HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleISOLock(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_iso_action *act; + struct xkb_iso_action *act = &action->iso; - act = (struct xkb_iso_action *) action; if (field == F_Modifiers) { unsigned flags; xkb_mod_mask_t mods; @@ -691,13 +683,12 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action, } static bool -HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_switch_screen_action *act; + struct xkb_switch_screen_action *act = &action->screen; - act = (struct xkb_switch_screen_action *) action; if (field == F_Screen) { const ExprDef *scrn; int val; @@ -771,13 +762,12 @@ const LookupEntry ctrlNames[] = { static bool HandleSetLockControls(struct xkb_keymap *keymap, - struct xkb_any_action *action, + union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_controls_action *act; + struct xkb_controls_action *act = &action->ctrls; - act = (struct xkb_controls_action *) action; if (field == F_Controls) { unsigned int mask; @@ -806,13 +796,12 @@ static const LookupEntry evNames[] = { }; static bool -HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleActionMessage(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_message_action *act; + struct xkb_message_action *act = &action->msg; - act = (struct xkb_message_action *) action; if (field == F_Report) { unsigned int mask; @@ -896,12 +885,12 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action, } static bool -HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleRedirectKey(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { struct xkb_key *key; - struct xkb_redirect_key_action *act; + struct xkb_redirect_key_action *act = &action->redirect; unsigned t1; xkb_mod_mask_t t2; unsigned long tmp; @@ -910,7 +899,6 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action, if (array_ndx != NULL) return ReportActionNotArray(keymap, action->type, field); - act = (struct xkb_redirect_key_action *) action; switch (field) { case F_Keycode: if (!ExprResolveKeyName(keymap->ctx, value, key_name)) @@ -948,13 +936,12 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action, } static bool -HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleDeviceBtn(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { - struct xkb_device_button_action *act; + struct xkb_device_button_action *act = &action->devbtn; - act = (struct xkb_device_button_action *) action; if (field == F_Button) { int val; @@ -1034,24 +1021,23 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action, } static bool -HandleDeviceValuator(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandleDeviceValuator(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { -#if 0 - ExprResult rtrn; - struct xkb_device_valuator_action *act; + struct xkb_device_valuator_action *act = &action->devval; + (void) act; - act = (struct xkb_device_valuator_action *) action; /* XXX - Not yet implemented */ -#endif return false; } static bool -HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action, +HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value) { + struct xkb_private_action *act = &action->priv; + if (field == F_Type) { int type; @@ -1065,7 +1051,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action, return false; } - action->type = (uint8_t) type; + act->type = (uint8_t) type; return true; } else if (field == F_Data) { @@ -1084,7 +1070,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action, return false; } - strncpy((char *) action->data, str, sizeof(action->data)); + strncpy((char *) act->data, str, sizeof(act->data)); return true; } else { @@ -1097,16 +1083,16 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action, return false; } - if (ndx < 0 || ndx >= sizeof(action->data)) { + if (ndx < 0 || ndx >= sizeof(act->data)) { log_err(keymap->ctx, "The data for a private action is %zu bytes long; " "Attempt to use data[%d] ignored\n", - sizeof(action->data), ndx); + sizeof(act->data), ndx); return false; } if (!ExprResolveInteger(keymap->ctx, value, &datum)) - return ReportMismatch(keymap, action->type, field, "integer"); + return ReportMismatch(keymap, act->type, field, "integer"); if (datum < 0 || datum > 255) { log_err(keymap->ctx, @@ -1115,7 +1101,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action, return false; } - action->data[ndx] = (uint8_t) datum; + act->data[ndx] = (uint8_t) datum; return true; } } @@ -1124,7 +1110,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action, } typedef bool (*actionHandler)(struct xkb_keymap *keymap, - struct xkb_any_action *action, unsigned field, + union xkb_action *action, unsigned field, const ExprDef *array_ndx, const ExprDef *value); static const actionHandler handleAction[XkbSA_NumActions + 1] = { @@ -1170,7 +1156,7 @@ ApplyActionFactoryDefaults(union xkb_action * action) int HandleActionDef(ExprDef * def, struct xkb_keymap *keymap, - struct xkb_any_action *action, ActionInfo *info) + union xkb_action *action, ActionInfo *info) { ExprDef *arg; const char *str; diff --git a/src/xkbcomp/action.h b/src/xkbcomp/action.h index 3d63468..5cf67d9 100644 --- a/src/xkbcomp/action.h +++ b/src/xkbcomp/action.h @@ -68,7 +68,7 @@ typedef struct _ActionInfo { extern int HandleActionDef(ExprDef *def, struct xkb_keymap *keymap, - struct xkb_any_action *action, + union xkb_action *action, ActionInfo *info); extern int diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 1fbf2b1..b00f64a 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -158,8 +158,6 @@ ClearIndicatorMapInfo(struct xkb_context *ctx, LEDInfo * info) static void InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id) { - unsigned int i; - info->keymap = keymap; info->name = NULL; info->file_id = file_id; @@ -172,9 +170,8 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id) info->dflt.merge = MERGE_OVERRIDE; info->dflt.interp.flags = 0; info->dflt.interp.virtual_mod = XkbNoModifier; + memset(&info->dflt.interp.act, 0, sizeof(info->dflt.interp.act)); info->dflt.interp.act.type = XkbSA_NoAction; - for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++) - info->dflt.interp.act.any.data[i] = 0; ClearIndicatorMapInfo(keymap->ctx, &info->ledDflt); info->ledDflt.file_id = file_id; info->ledDflt.defined = 0; @@ -188,7 +185,6 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id) static void ClearCompatInfo(CompatInfo *info) { - unsigned int i; ActionInfo *next_act; SymInterpInfo *si, *next_si; LEDInfo *led, *next_led; @@ -200,9 +196,8 @@ ClearCompatInfo(CompatInfo *info) info->dflt.merge = MERGE_AUGMENT; info->dflt.interp.flags = 0; info->dflt.interp.virtual_mod = XkbNoModifier; + memset(&info->dflt.interp.act, 0, sizeof(info->dflt.interp.act)); info->dflt.interp.act.type = XkbSA_NoAction; - for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++) - info->dflt.interp.act.any.data[i] = 0; ClearIndicatorMapInfo(keymap->ctx, &info->ledDflt); info->nInterps = 0; list_foreach_safe(si, next_si, &info->interps, entry) @@ -640,7 +635,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field, if (arrayNdx) return ReportSINotArray(info, si, field); - if (!HandleActionDef(value, keymap, &si->interp.act.any, info->act)) + if (!HandleActionDef(value, keymap, &si->interp.act, info->act)) return false; si->defined |= SI_FIELD_ACTION; diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c index 5993a9a..7574520 100644 --- a/src/xkbcomp/symbols.c +++ b/src/xkbcomp/symbols.c @@ -925,7 +925,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, xkb_group_index_t ndx; size_t nActs; ExprDef *act; - struct xkb_any_action *toAct; + union xkb_action *toAct; if (!GetGroupIndex(info, keyi, arrayNdx, ACTIONS, &ndx)) return false; @@ -970,7 +970,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, } keyi->actsDefined |= (1 << ndx); - toAct = (struct xkb_any_action *) darray_mem(keyi->acts[ndx], 0); + toAct = darray_mem(keyi->acts[ndx], 0); act = value->value.child; for (i = 0; i < nActs; i++, toAct++) { if (!HandleActionDef(act, info->keymap, toAct, info->action)) { |