src/xkbcomp/include.c \
src/xkbcomp/include.h \
src/xkbcomp/keycodes.c \
- src/xkbcomp/keycodes.h \
src/xkbcomp/keymap.c \
src/xkbcomp/keymap-dump.c \
src/xkbcomp/parser.y \
return key->repeats;
}
+
+struct xkb_key *
+XkbKeyByName(struct xkb_keymap *keymap, xkb_atom_t name, bool use_aliases)
+{
+ struct xkb_key *key;
+
+ xkb_foreach_key(key, keymap)
+ if (key->name == name)
+ return key;
+
+ if (use_aliases) {
+ xkb_atom_t new_name = XkbResolveKeyAlias(keymap, name);
+ if (new_name != XKB_ATOM_NONE)
+ return XkbKeyByName(keymap, new_name, false);
+ }
+
+ return NULL;
+}
+
+xkb_atom_t
+XkbResolveKeyAlias(struct xkb_keymap *keymap, xkb_atom_t name)
+{
+ const struct xkb_key_alias *alias;
+
+ darray_foreach(alias, keymap->key_aliases)
+ if (name == alias->alias)
+ return alias->real;
+
+ return XKB_ATOM_NONE;
+}
char *compat_section_name;
};
+#define xkb_foreach_key(iter, keymap) \
+ for (iter = keymap->keys + keymap->min_key_code; \
+ iter <= keymap->keys + keymap->max_key_code; \
+ iter++)
+
static inline const struct xkb_key *
XkbKey(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
return &keymap->keys[kc];
}
-#define xkb_foreach_key(iter, keymap) \
- for (iter = keymap->keys + keymap->min_key_code; \
- iter <= keymap->keys + keymap->max_key_code; \
- iter++)
-
static inline xkb_level_index_t
XkbKeyGroupWidth(const struct xkb_key *key, xkb_layout_index_t layout)
{
return key->groups[layout].type->num_levels;
}
+struct xkb_key *
+XkbKeyByName(struct xkb_keymap *keymap, xkb_atom_t name, bool use_aliases);
+
+xkb_atom_t
+XkbResolveKeyAlias(struct xkb_keymap *keymap, xkb_atom_t name);
+
xkb_layout_index_t
wrap_group_into_range(int32_t group,
xkb_layout_index_t num_groups,
#include "text.h"
#include "expr.h"
#include "action.h"
-#include "keycodes.h"
static const ExprDef constTrue = {
.common = { .type = STMT_EXPR, .next = NULL },
#include "xkbcomp-priv.h"
#include "text.h"
#include "expr.h"
-#include "keycodes.h"
#include "include.h"
/*
struct xkb_key_alias new;
/* Check that ->real is a key. */
- key = FindNamedKey(keymap, alias->real, false);
+ key = XkbKeyByName(keymap, alias->real, false);
if (!key) {
log_vrb(info->ctx, 5,
"Attempt to alias %s to non-existent key %s; Ignored\n",
}
/* Check that ->alias is not a key. */
- key = FindNamedKey(keymap, alias->alias, false);
+ key = XkbKeyByName(keymap, alias->alias, false);
if (key) {
log_vrb(info->ctx, 5,
"Attempt to create alias with the name of a real key; "
ClearKeyNamesInfo(&info);
return false;
}
-
-/***====================================================================***/
-
-struct xkb_key *
-FindNamedKey(struct xkb_keymap *keymap, xkb_atom_t name, bool use_aliases)
-{
- struct xkb_key *key;
-
- xkb_foreach_key(key, keymap)
- if (key->name == name)
- return key;
-
- if (use_aliases) {
- xkb_atom_t new_name;
- if (FindKeyNameForAlias(keymap, name, &new_name))
- return FindNamedKey(keymap, new_name, false);
- }
-
- return NULL;
-}
-
-bool
-FindKeyNameForAlias(struct xkb_keymap *keymap, xkb_atom_t name,
- xkb_atom_t *real_name)
-{
- const struct xkb_key_alias *a;
-
- darray_foreach(a, keymap->key_aliases) {
- if (name == a->alias) {
- *real_name = a->real;
- return true;
- }
- }
-
- return false;
-}
+++ /dev/null
-/************************************************************
- * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
- *
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting
- * documentation, and that the name of Silicon Graphics not be
- * used in advertising or publicity pertaining to distribution
- * of the software without specific prior written permission.
- * Silicon Graphics makes no representation about the suitability
- * of this software for any purpose. It is provided "as is"
- * without any express or implied warranty.
- *
- * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- * THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- ********************************************************/
-
-#ifndef XKBCOMP_KEYCODES_H
-#define XKBCOMP_KEYCODES_H
-
-struct xkb_key *
-FindNamedKey(struct xkb_keymap *keymap, xkb_atom_t name, bool use_aliases);
-
-bool
-FindKeyNameForAlias(struct xkb_keymap *keymap, xkb_atom_t name,
- xkb_atom_t *real_name);
-
-#endif
#include "expr.h"
#include "action.h"
#include "vmod.h"
-#include "keycodes.h"
#include "include.h"
#include "keysym.h"
* following loop) is enough, and we won't get multiple KeyInfo's
* for the same key because of aliases.
*/
- if (FindKeyNameForAlias(info->keymap, keyi->name, &real_name))
+ real_name = XkbResolveKeyAlias(info->keymap, keyi->name);
+ if (real_name != XKB_ATOM_NONE)
keyi->name = real_name;
darray_foreach(iter, info->keys)
* The name is guaranteed to be real and not an alias (see
* AddKeySymbols), so 'false' is safe here.
*/
- key = FindNamedKey(keymap, keyi->name, false);
+ key = XkbKeyByName(keymap, keyi->name, false);
if (!key) {
log_vrb(info->keymap->ctx, 5,
"Key %s not found in keycodes; Symbols ignored\n",
struct xkb_keymap *keymap = info->keymap;
if (!entry->haveSymbol) {
- key = FindNamedKey(keymap, entry->u.keyName, true);
+ key = XkbKeyByName(keymap, entry->u.keyName, true);
if (!key) {
log_vrb(info->keymap->ctx, 5,
"Key %s not found in keycodes; "