Remove AutoKeyNames feature

If this keymap flag is set, whenever a key name appears in one of the
sections which does not exist (i.e. has not been declared in keycodes),
it finds the first unused keycode and attaches it that name.

This might have been useful when you could compile the symbols section
or geometry section without a keycodes section, but we don't support
this anymore. It's also pretty useless for any real work, because the
user has no way of knowing the keycode and so it will never be used.
Finally the only obscure way left to set this flag is by including a
keycodes file called "computed".

Just remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-08-10 13:08:03 +03:00
parent ef518a10af
commit 34e690ceeb
6 changed files with 8 additions and 34 deletions

View File

@ -917,7 +917,7 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
return ReportMismatch(keymap, action->type, field, "key name");
tmp = KeyNameToLong(key_name);
key = FindNamedKey(keymap, tmp, true, CreateKeyNames(keymap), 0);
key = FindNamedKey(keymap, tmp, true, 0);
if (!key)
return ReportNotFound(keymap, action->type, field, "Key",
KeyNameText(key_name));

View File

@ -547,14 +547,6 @@ HandleIncludeKeycodes(KeyNamesInfo *info, IncludeStmt *stmt)
XkbFile *rtrn;
KeyNamesInfo included, next_incl;
/* XXX: What's that? */
if (stmt->file && streq(stmt->file, "computed")) {
info->keymap->flags |= AutoKeyNames;
info->explicitMin = 0;
info->explicitMax = XKB_KEYCODE_MAX;
return (info->errorCount == 0);
}
InitKeyNamesInfo(&included, info->keymap, info->file_id);
if (stmt->stmt) {
free(included.name);
@ -893,8 +885,7 @@ ApplyAliases(KeyNamesInfo *info)
old = &darray_item(keymap->key_aliases, 0);
list_foreach(alias, &info->aliases, entry) {
key = FindNamedKey(keymap, alias->real, false,
CreateKeyNames(keymap), 0);
key = FindNamedKey(keymap, alias->real, false, 0);
if (!key) {
log_lvl(info->keymap->ctx, 5,
"Attempt to alias %s to non-existent key %s; Ignored\n",
@ -904,7 +895,7 @@ ApplyAliases(KeyNamesInfo *info)
continue;
}
key = FindNamedKey(keymap, alias->alias, false, false, 0);
key = FindNamedKey(keymap, alias->alias, false, 0);
if (key) {
log_lvl(info->keymap->ctx, 5,
"Attempt to create alias with the name of a real key; "

View File

@ -113,15 +113,13 @@ ProcessIncludeFile(struct xkb_context *ctx,
* @param keymap The keymap to search in.
* @param name The 4-letter name of the key as a long.
* @param use_aliases true if the key aliases should be searched too.
* @param create If true and the key is not found, it is added to the
* keymap->names at the first free keycode.
* @param start_from Keycode to start searching from.
*
* @return the key if it is found, NULL otherwise.
*/
struct xkb_key *
FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
bool use_aliases, bool create, xkb_keycode_t start_from)
bool use_aliases, xkb_keycode_t start_from)
{
struct xkb_key *key;
@ -137,17 +135,7 @@ FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
if (use_aliases) {
unsigned long new_name;
if (FindKeyNameForAlias(keymap, name, &new_name))
return FindNamedKey(keymap, new_name, false, create, 0);
}
if (create) {
/* Find first unused key and store our key here */
xkb_foreach_key(key, keymap) {
if (key->name[0] == '\0') {
LongToKeyName(name, key->name);
return key;
}
}
return FindNamedKey(keymap, new_name, false, 0);
}
return NULL;

View File

@ -1696,8 +1696,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
useAlias = (start_from == 0);
key = FindNamedKey(keymap, keyi->name, useAlias,
CreateKeyNames(keymap), start_from);
key = FindNamedKey(keymap, keyi->name, useAlias, start_from);
if (!key) {
if (start_from == 0)
log_lvl(info->keymap->ctx, 5,
@ -1853,8 +1852,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
struct xkb_keymap *keymap = info->keymap;
if (!entry->haveSymbol) {
key = FindNamedKey(keymap, entry->u.keyName, true,
CreateKeyNames(keymap), 0);
key = FindNamedKey(keymap, entry->u.keyName, true, 0);
if (!key) {
log_lvl(info->keymap->ctx, 5,
"Key %s not found in keycodes; "

View File

@ -37,7 +37,7 @@ ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
struct xkb_key *
FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
bool use_aliases, bool create, xkb_keycode_t start_from);
bool use_aliases, xkb_keycode_t start_from);
extern bool
FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,

View File

@ -238,7 +238,4 @@ extern bool
CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge);
#define AutoKeyNames (1L << 0)
#define CreateKeyNames(x) ((x)->flags & AutoKeyNames)
#endif /* XKBCOMP_H */