From 74ec4c1c3fa9d7ff739013728d42ff06d72697c7 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 21 Aug 2012 12:47:28 +0100 Subject: [PATCH] kbproto unentanglement: XkbNumIndicators Signed-off-by: Daniel Stone --- src/keymap-dump.c | 4 ++-- src/map.c | 2 +- src/state.c | 2 +- src/xkb-priv.h | 5 ++++- src/xkbcomp/compat.c | 12 ++++++------ src/xkbcomp/keycodes.c | 14 +++++++------- src/xkbcomp/keymap.c | 2 +- 7 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/keymap-dump.c b/src/keymap-dump.c index 84e141b..0aebf54 100644 --- a/src/keymap-dump.c +++ b/src/keymap-dump.c @@ -256,7 +256,7 @@ write_keycodes(struct xkb_keymap *keymap, struct buf *buf) KeyNameText(key->name), XkbKeyGetKeycode(keymap, key)); } - for (i = 0; i < XkbNumIndicators; i++) { + for (i = 0; i < XKB_NUM_INDICATORS; i++) { if (keymap->indicators[i].name == XKB_ATOM_NONE) continue; write_buf(buf, "\t\tindicator %d = \"%s\";\n", i + 1, @@ -561,7 +561,7 @@ write_compat(struct xkb_keymap *keymap, struct buf *buf) write_buf(buf, "\t\t};\n"); } - for (i = 0; i < XkbNumIndicators; i++) { + for (i = 0; i < XKB_NUM_INDICATORS; i++) { struct xkb_indicator_map *map = &keymap->indicators[i]; if (map->which_groups == 0 && map->groups == 0 && map->which_mods == 0 && map->mods.mods == 0 && diff --git a/src/map.c b/src/map.c index 9a2be6b..1ed5a44 100644 --- a/src/map.c +++ b/src/map.c @@ -232,7 +232,7 @@ xkb_map_num_leds(struct xkb_keymap *keymap) xkb_led_index_t ret = 0; xkb_led_index_t i; - for (i = 0; i < XkbNumIndicators; i++) + for (i = 0; i < XKB_NUM_INDICATORS; i++) if (keymap->indicators[i].which_groups || keymap->indicators[i].which_mods || keymap->indicators[i].ctrls) diff --git a/src/state.c b/src/state.c index 2532f87..bc77a9c 100644 --- a/src/state.c +++ b/src/state.c @@ -530,7 +530,7 @@ xkb_state_led_update_all(struct xkb_state *state) state->leds = 0; - for (led = 0; led < XkbNumIndicators; led++) { + for (led = 0; led < XKB_NUM_INDICATORS; led++) { struct xkb_indicator_map *map = &state->keymap->indicators[led]; xkb_mod_mask_t mod_mask = 0; uint32_t group_mask = 0; diff --git a/src/xkb-priv.h b/src/xkb-priv.h index 62a1dea..468cf6b 100644 --- a/src/xkb-priv.h +++ b/src/xkb-priv.h @@ -96,7 +96,10 @@ typedef uint32_t xkb_atom_t; #define XKB_LEVEL_INVALID 0xffffffff #define XKB_KEY_NAME_LENGTH 4 + +/* These should all be dynamic. */ #define XKB_NUM_GROUPS 4 +#define XKB_NUM_INDICATORS 32 struct xkb_context { int refcnt; @@ -356,7 +359,7 @@ struct xkb_keymap { xkb_group_index_t num_groups; xkb_atom_t group_names[XKB_NUM_GROUPS]; - struct xkb_indicator_map indicators[XkbNumIndicators]; + struct xkb_indicator_map indicators[XKB_NUM_INDICATORS]; char *keycodes_section_name; char *symbols_section_name; diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 3d8b940..6bfc635 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -130,7 +130,7 @@ * After all of the xkb_compat sections have been compiled, the following * members of struct xkb_keymap are finalized: * darray(struct xkb_sym_interpret) sym_interpret; - * struct xkb_indicator_map indicators[XkbNumIndicators]; + * struct xkb_indicator_map indicators[XKB_NUM_INDICATORS]; * char *compat_section_name; * TODO: virtual modifiers. */ @@ -947,27 +947,27 @@ CopyIndicatorMapDefs(CompatInfo *info) * Find the indicator with the given name, if it was already * declared in keycodes. */ - for (i = 0; i < XkbNumIndicators; i++) + for (i = 0; i < XKB_NUM_INDICATORS; i++) if (keymap->indicators[i].name == led->im.name) break; /* Not previously declared; create it with next free index. */ - if (i >= XkbNumIndicators) { + if (i >= XKB_NUM_INDICATORS) { log_dbg(keymap->ctx, "Indicator name \"%s\" was not declared in the keycodes section; " "Adding new indicator\n", xkb_atom_text(keymap->ctx, led->im.name)); - for (i = 0; i < XkbNumIndicators; i++) + for (i = 0; i < XKB_NUM_INDICATORS; i++) if (keymap->indicators[i].name == XKB_ATOM_NONE) break; /* Not place to put it; ignore. */ - if (i >= XkbNumIndicators) { + if (i >= XKB_NUM_INDICATORS) { log_err(keymap->ctx, "Too many indicators (maximum is %d); " "Indicator name \"%s\" ignored\n", - XkbNumIndicators, + XKB_NUM_INDICATORS, xkb_atom_text(keymap->ctx, led->im.name)); continue; } diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c index 3688af4..454b6f3 100644 --- a/src/xkbcomp/keycodes.c +++ b/src/xkbcomp/keycodes.c @@ -98,7 +98,7 @@ * indicator 3 = "Scroll Lock"; * * Assigns a name the indicator (i.e. keyboard LED) with the given index. - * The amount of possible indicators is predetermined (XkbNumIndicators). + * The amount of possible indicators is predetermined (XKB_NUM_INDICATORS). * The indicator may be referred by this name later in the compat section * and by the user. * @@ -111,7 +111,7 @@ * darray(struct xkb_key_alias) key_aliases; * char *keycodes_section_name; * The 'name' field of indicators declared in xkb_keycodes: - * struct xkb_indicator_map indicators[XkbNumIndicators]; + * struct xkb_indicator_map indicators[XKB_NUM_INDICATORS]; * Further, the array of keys: * darray(struct xkb_key) keys; * had been resized to its final size (i.e. all of the xkb_key objects are @@ -146,7 +146,7 @@ typedef struct _KeyNamesInfo { xkb_keycode_t explicitMax; darray(unsigned long) names; darray(unsigned int) files; - IndicatorNameInfo indicator_names[XkbNumIndicators]; + IndicatorNameInfo indicator_names[XKB_NUM_INDICATORS]; darray(AliasInfo) aliases; struct xkb_context *ctx; @@ -179,7 +179,7 @@ FindIndicatorByName(KeyNamesInfo *info, xkb_atom_t name, { xkb_led_index_t idx; - for (idx = 0; idx < XkbNumIndicators; idx++) { + for (idx = 0; idx < XKB_NUM_INDICATORS; idx++) { if (info->indicator_names[idx].name == name) { *idx_out = idx; return &info->indicator_names[idx]; @@ -438,7 +438,7 @@ MergeIncludedKeycodes(KeyNamesInfo *into, KeyNamesInfo *from, into->errorCount++; } - for (idx = 0; idx < XkbNumIndicators; idx++) { + for (idx = 0; idx < XKB_NUM_INDICATORS; idx++) { IndicatorNameInfo *led = &from->indicator_names[idx]; if (led->name == XKB_ATOM_NONE) continue; @@ -676,7 +676,7 @@ HandleIndicatorNameDef(KeyNamesInfo *info, IndicatorNameDef *def, IndicatorNameInfo ii; xkb_atom_t name; - if (def->ndx < 1 || def->ndx > XkbNumIndicators) { + if (def->ndx < 1 || def->ndx > XKB_NUM_INDICATORS) { info->errorCount++; log_err(info->ctx, "Name specified for illegal indicator index %d\n; Ignored\n", @@ -822,7 +822,7 @@ CopyKeyNamesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info) keymap->keycodes_section_name = strdup_safe(info->name); - for (idx = 0; idx < XkbNumIndicators; idx++) { + for (idx = 0; idx < XKB_NUM_INDICATORS; idx++) { IndicatorNameInfo *led = &info->indicator_names[idx]; if (led->name == XKB_ATOM_NONE) continue; diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c index 5c1de7a..6529921 100644 --- a/src/xkbcomp/keymap.c +++ b/src/xkbcomp/keymap.c @@ -246,7 +246,7 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap) } /* Update vmod -> indicator maps. */ - for (led = 0; led < XkbNumIndicators; led++) + for (led = 0; led < XKB_NUM_INDICATORS; led++) ComputeEffectiveMask(keymap, &keymap->indicators[led].mods); /* Find maximum number of groups out of all keys in the keymap. */ -- 2.7.4