kbproto unentanglement: XkbNumIndicators Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
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. */