kbproto unentanglement: XkbNumIndicators

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-08-21 12:47:28 +01:00
parent 4b8ceae91f
commit 74ec4c1c3f
7 changed files with 22 additions and 19 deletions

View File

@ -256,7 +256,7 @@ write_keycodes(struct xkb_keymap *keymap, struct buf *buf)
KeyNameText(key->name), XkbKeyGetKeycode(keymap, key)); 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) if (keymap->indicators[i].name == XKB_ATOM_NONE)
continue; continue;
write_buf(buf, "\t\tindicator %d = \"%s\";\n", i + 1, 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"); 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]; struct xkb_indicator_map *map = &keymap->indicators[i];
if (map->which_groups == 0 && map->groups == 0 && if (map->which_groups == 0 && map->groups == 0 &&
map->which_mods == 0 && map->mods.mods == 0 && map->which_mods == 0 && map->mods.mods == 0 &&

View File

@ -232,7 +232,7 @@ xkb_map_num_leds(struct xkb_keymap *keymap)
xkb_led_index_t ret = 0; xkb_led_index_t ret = 0;
xkb_led_index_t i; 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 || if (keymap->indicators[i].which_groups ||
keymap->indicators[i].which_mods || keymap->indicators[i].which_mods ||
keymap->indicators[i].ctrls) keymap->indicators[i].ctrls)

View File

@ -530,7 +530,7 @@ xkb_state_led_update_all(struct xkb_state *state)
state->leds = 0; 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]; struct xkb_indicator_map *map = &state->keymap->indicators[led];
xkb_mod_mask_t mod_mask = 0; xkb_mod_mask_t mod_mask = 0;
uint32_t group_mask = 0; uint32_t group_mask = 0;

View File

@ -96,7 +96,10 @@ typedef uint32_t xkb_atom_t;
#define XKB_LEVEL_INVALID 0xffffffff #define XKB_LEVEL_INVALID 0xffffffff
#define XKB_KEY_NAME_LENGTH 4 #define XKB_KEY_NAME_LENGTH 4
/* These should all be dynamic. */
#define XKB_NUM_GROUPS 4 #define XKB_NUM_GROUPS 4
#define XKB_NUM_INDICATORS 32
struct xkb_context { struct xkb_context {
int refcnt; int refcnt;
@ -356,7 +359,7 @@ struct xkb_keymap {
xkb_group_index_t num_groups; xkb_group_index_t num_groups;
xkb_atom_t group_names[XKB_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 *keycodes_section_name;
char *symbols_section_name; char *symbols_section_name;

View File

@ -130,7 +130,7 @@
* After all of the xkb_compat sections have been compiled, the following * After all of the xkb_compat sections have been compiled, the following
* members of struct xkb_keymap are finalized: * members of struct xkb_keymap are finalized:
* darray(struct xkb_sym_interpret) sym_interpret; * 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; * char *compat_section_name;
* TODO: virtual modifiers. * TODO: virtual modifiers.
*/ */
@ -947,27 +947,27 @@ CopyIndicatorMapDefs(CompatInfo *info)
* Find the indicator with the given name, if it was already * Find the indicator with the given name, if it was already
* declared in keycodes. * 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) if (keymap->indicators[i].name == led->im.name)
break; break;
/* Not previously declared; create it with next free index. */ /* Not previously declared; create it with next free index. */
if (i >= XkbNumIndicators) { if (i >= XKB_NUM_INDICATORS) {
log_dbg(keymap->ctx, log_dbg(keymap->ctx,
"Indicator name \"%s\" was not declared in the keycodes section; " "Indicator name \"%s\" was not declared in the keycodes section; "
"Adding new indicator\n", "Adding new indicator\n",
xkb_atom_text(keymap->ctx, led->im.name)); 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) if (keymap->indicators[i].name == XKB_ATOM_NONE)
break; break;
/* Not place to put it; ignore. */ /* Not place to put it; ignore. */
if (i >= XkbNumIndicators) { if (i >= XKB_NUM_INDICATORS) {
log_err(keymap->ctx, log_err(keymap->ctx,
"Too many indicators (maximum is %d); " "Too many indicators (maximum is %d); "
"Indicator name \"%s\" ignored\n", "Indicator name \"%s\" ignored\n",
XkbNumIndicators, XKB_NUM_INDICATORS,
xkb_atom_text(keymap->ctx, led->im.name)); xkb_atom_text(keymap->ctx, led->im.name));
continue; continue;
} }

View File

@ -98,7 +98,7 @@
* indicator 3 = "Scroll Lock"; * indicator 3 = "Scroll Lock";
* *
* Assigns a name the indicator (i.e. keyboard LED) with the given index. * 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 * The indicator may be referred by this name later in the compat section
* and by the user. * and by the user.
* *
@ -111,7 +111,7 @@
* darray(struct xkb_key_alias) key_aliases; * darray(struct xkb_key_alias) key_aliases;
* char *keycodes_section_name; * char *keycodes_section_name;
* The 'name' field of indicators declared in xkb_keycodes: * 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: * Further, the array of keys:
* darray(struct xkb_key) keys; * darray(struct xkb_key) keys;
* had been resized to its final size (i.e. all of the xkb_key objects are * 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; xkb_keycode_t explicitMax;
darray(unsigned long) names; darray(unsigned long) names;
darray(unsigned int) files; darray(unsigned int) files;
IndicatorNameInfo indicator_names[XkbNumIndicators]; IndicatorNameInfo indicator_names[XKB_NUM_INDICATORS];
darray(AliasInfo) aliases; darray(AliasInfo) aliases;
struct xkb_context *ctx; struct xkb_context *ctx;
@ -179,7 +179,7 @@ FindIndicatorByName(KeyNamesInfo *info, xkb_atom_t name,
{ {
xkb_led_index_t idx; 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) { if (info->indicator_names[idx].name == name) {
*idx_out = idx; *idx_out = idx;
return &info->indicator_names[idx]; return &info->indicator_names[idx];
@ -438,7 +438,7 @@ MergeIncludedKeycodes(KeyNamesInfo *into, KeyNamesInfo *from,
into->errorCount++; into->errorCount++;
} }
for (idx = 0; idx < XkbNumIndicators; idx++) { for (idx = 0; idx < XKB_NUM_INDICATORS; idx++) {
IndicatorNameInfo *led = &from->indicator_names[idx]; IndicatorNameInfo *led = &from->indicator_names[idx];
if (led->name == XKB_ATOM_NONE) if (led->name == XKB_ATOM_NONE)
continue; continue;
@ -676,7 +676,7 @@ HandleIndicatorNameDef(KeyNamesInfo *info, IndicatorNameDef *def,
IndicatorNameInfo ii; IndicatorNameInfo ii;
xkb_atom_t name; xkb_atom_t name;
if (def->ndx < 1 || def->ndx > XkbNumIndicators) { if (def->ndx < 1 || def->ndx > XKB_NUM_INDICATORS) {
info->errorCount++; info->errorCount++;
log_err(info->ctx, log_err(info->ctx,
"Name specified for illegal indicator index %d\n; Ignored\n", "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); 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]; IndicatorNameInfo *led = &info->indicator_names[idx];
if (led->name == XKB_ATOM_NONE) if (led->name == XKB_ATOM_NONE)
continue; continue;

View File

@ -246,7 +246,7 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
} }
/* Update vmod -> indicator maps. */ /* Update vmod -> indicator maps. */
for (led = 0; led < XkbNumIndicators; led++) for (led = 0; led < XKB_NUM_INDICATORS; led++)
ComputeEffectiveMask(keymap, &keymap->indicators[led].mods); ComputeEffectiveMask(keymap, &keymap->indicators[led].mods);
/* Find maximum number of groups out of all keys in the keymap. */ /* Find maximum number of groups out of all keys in the keymap. */