keycodes: ignore explicit minimum/maximum statements These statements are pretty pointless for us; we don't restrict keycodes like X does, and if someone writes e.g. maximum = 255 but only has 100 keys, we currently happily alloc all those empty keys. xkbcomp already handles the case when these statements aren't given, and uses a computed min/max instead. We should just always use that. (Of course since keycodes/evdev currently uses almost all of the keycodes in the range it declares, including 255, this doesn't save any memory for the common user right now). Signed-off-by: Ran Benita <ran234@gmail.com>
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 199 200 201 202 203 204 205
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 51b7973..e913f60 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -239,11 +239,6 @@ write_keycodes(struct xkb_keymap *keymap, struct buf *buf)
else
write_buf(buf, "\txkb_keycodes {\n");
- write_buf(buf, "\t\tminimum = %d;\n",
- keymap->min_key_code);
- write_buf(buf, "\t\tmaximum = %d;\n",
- keymap->max_key_code);
-
xkb_foreach_key(key, keymap) {
if (key->name[0] == '\0')
continue;
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index 96d3e0f..18d800a 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -40,17 +40,6 @@
* of up to 4 letters, by which it can be referred to later, e.g. in the
* symbols section.
*
- * Minimum/Maximum keycode
- * -----------------------
- * Statements of the form:
- * minimum = 8;
- * maximum = 255;
- *
- * The file may explicitly declare the minimum and/or maximum keycode
- * contained therein (traditionally 8-255, inherited from old xfree86
- * keycodes). If these are stated explicitly, they are enforced. If
- * they are not stated, they are computed automatically.
- *
* Keycode statements
* ------------------
* Statements of the form:
@@ -142,8 +131,6 @@ typedef struct _KeyNamesInfo {
xkb_keycode_t computedMin; /* lowest keycode stored */
xkb_keycode_t computedMax; /* highest keycode stored */
- xkb_keycode_t explicitMin;
- xkb_keycode_t explicitMax;
darray(unsigned long) names;
darray(unsigned int) files;
IndicatorNameInfo indicator_names[XKB_NUM_INDICATORS];
@@ -441,14 +428,6 @@ MergeIncludedKeycodes(KeyNamesInfo *into, KeyNamesInfo *from,
if (!MergeAliases(into, from, merge))
into->errorCount++;
-
- if (from->explicitMin != 0)
- if (into->explicitMin == 0 || into->explicitMin > from->explicitMin)
- into->explicitMin = from->explicitMin;
-
- if (from->explicitMax > 0)
- if (into->explicitMax == 0 || into->explicitMax < from->explicitMax)
- into->explicitMax = from->explicitMax;
}
static void
@@ -495,15 +474,6 @@ HandleIncludeKeycodes(KeyNamesInfo *info, IncludeStmt *stmt)
static int
HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge)
{
- if ((info->explicitMin != 0 && stmt->value < info->explicitMin) ||
- (info->explicitMax != 0 && stmt->value > info->explicitMax)) {
- log_err(info->ctx, "Illegal keycode %lu for name %s; "
- "Must be in the range %d-%d inclusive\n",
- stmt->value, KeyNameText(stmt->name), info->explicitMin,
- info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
- return 0;
- }
-
if (stmt->merge != MERGE_DEFAULT) {
if (stmt->merge == MERGE_REPLACE)
merge = MERGE_OVERRIDE;
@@ -566,16 +536,11 @@ HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge,
return true;
}
-#define MIN_KEYCODE_DEF 0
-#define MAX_KEYCODE_DEF 1
-
static int
HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
{
const char *elem, *field;
- xkb_keycode_t kc;
ExprDef *arrayNdx;
- int which;
if (!ExprResolveLhs(info->ctx, stmt->name, &elem, &field, &arrayNdx))
return false;
@@ -586,77 +551,13 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
return false;
}
- if (istreq(field, "minimum")) {
- which = MIN_KEYCODE_DEF;
- }
- else if (istreq(field, "maximum")) {
- which = MAX_KEYCODE_DEF;
- }
- else {
+ if (!istreq(field, "minimum") && !istreq(field, "maximum")) {
log_err(info->ctx, "Unknown field encountered; "
"Assigment to field %s ignored\n", field);
return false;
}
- if (arrayNdx != NULL) {
- log_err(info->ctx, "The %s setting is not an array; "
- "Illegal array reference ignored\n", field);
- return false;
- }
-
- if (!ExprResolveKeyCode(info->ctx, stmt->value, &kc)) {
- log_err(info->ctx, "Illegal keycode encountered; "
- "Assignment to field %s ignored\n", field);
- return false;
- }
-
- if (kc > XKB_KEYCODE_MAX) {
- log_err(info->ctx,
- "Illegal keycode %d (must be in the range %d-%d inclusive); "
- "Value of \"%s\" not changed\n",
- kc, 0, XKB_KEYCODE_MAX, field);
- return false;
- }
-
- if (which == MIN_KEYCODE_DEF) {
- if (info->explicitMax > 0 && info->explicitMax < kc) {
- log_err(info->ctx,
- "Minimum key code (%d) must be <= maximum key code (%d); "
- "Minimum key code value not changed\n",
- kc, info->explicitMax);
- return false;
- }
-
- if (info->computedMax > 0 && info->computedMin < kc) {
- log_err(info->ctx,
- "Minimum key code (%d) must be <= lowest defined key (%d); "
- "Minimum key code value not changed\n",
- kc, info->computedMin);
- return false;
- }
-
- info->explicitMin = kc;
- }
- else if (which == MAX_KEYCODE_DEF) {
- if (info->explicitMin > 0 && info->explicitMin > kc) {
- log_err(info->ctx,
- "Maximum code (%d) must be >= minimum key code (%d); "
- "Maximum code value not changed\n",
- kc, info->explicitMin);
- return false;
- }
-
- if (info->computedMax > 0 && info->computedMax > kc) {
- log_err(info->ctx,
- "Maximum code (%d) must be >= highest defined key (%d); "
- "Maximum code value not changed\n",
- kc, info->computedMax);
- return false;
- }
-
- info->explicitMax = kc;
- }
-
+ /* We ignore explicit min/max statements, we always use computed. */
return true;
}
@@ -796,15 +697,8 @@ CopyKeyNamesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info)
xkb_keycode_t kc;
xkb_led_index_t idx;
- if (info->explicitMin > 0)
- keymap->min_key_code = info->explicitMin;
- else
- keymap->min_key_code = info->computedMin;
-
- if (info->explicitMax > 0)
- keymap->max_key_code = info->explicitMax;
- else
- keymap->max_key_code = info->computedMax;
+ keymap->min_key_code = info->computedMin;
+ keymap->max_key_code = info->computedMax;
darray_resize0(keymap->keys, keymap->max_key_code + 1);
for (kc = info->computedMin; kc <= info->computedMax; kc++)
diff --git a/test/data/keymaps/stringcomp.data b/test/data/keymaps/stringcomp.data
index 6d2f3e6..d463655 100644
--- a/test/data/keymaps/stringcomp.data
+++ b/test/data/keymaps/stringcomp.data
@@ -1,7 +1,5 @@
xkb_keymap {
xkb_keycodes "evdev_aliases(qwerty)" {
- minimum = 8;
- maximum = 255;
<ESC> = 9;
<AE01> = 10;
<AE02> = 11;