Change all 'xkb' xkb_keymap names to 'keymap'

To make it a bit more clear what it actually is.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-05-09 15:15:30 +01:00
parent e1af48bc04
commit 38cb639082
33 changed files with 829 additions and 841 deletions

View File

@ -329,13 +329,13 @@ xkb_map_new_from_string(struct xkb_context *context,
* Takes a new reference on a keymap.
*/
struct xkb_keymap *
xkb_map_ref(struct xkb_keymap *xkb);
xkb_map_ref(struct xkb_keymap *keymap);
/**
* Releases a reference on a keymap.
*/
void
xkb_map_unref(struct xkb_keymap *xkb);
xkb_map_unref(struct xkb_keymap *keymap);
/** @} */
@ -351,61 +351,61 @@ xkb_map_unref(struct xkb_keymap *xkb);
* Returns the number of modifiers active in the keymap.
*/
xkb_mod_index_t
xkb_map_num_mods(struct xkb_keymap *xkb);
xkb_map_num_mods(struct xkb_keymap *keymap);
/**
* Returns the name of the modifier specified by 'idx', or NULL if invalid.
*/
const char *
xkb_map_mod_get_name(struct xkb_keymap *xkb, xkb_mod_index_t idx);
xkb_map_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx);
/**
* Returns the index of the modifier specified by 'name', or XKB_MOD_INVALID.
*/
xkb_mod_index_t
xkb_map_mod_get_index(struct xkb_keymap *xkb, const char *name);
xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name);
/**
* Returns the number of groups active in the keymap.
*/
xkb_group_index_t
xkb_map_num_groups(struct xkb_keymap *xkb);
xkb_map_num_groups(struct xkb_keymap *keymap);
/**
* Returns the name of the group specified by 'idx', or NULL if invalid.
*/
const char *
xkb_map_group_get_name(struct xkb_keymap *xkb, xkb_group_index_t idx);
xkb_map_group_get_name(struct xkb_keymap *keymap, xkb_group_index_t idx);
/**
* Returns the index of the group specified by 'name', or XKB_GROUP_INVALID.
*/
xkb_group_index_t
xkb_map_group_get_index(struct xkb_keymap *xkb, const char *name);
xkb_map_group_get_index(struct xkb_keymap *keymap, const char *name);
/**
* Returns the number of groups active for the specified key.
*/
xkb_group_index_t
xkb_key_num_groups(struct xkb_keymap *xkb, xkb_keycode_t key);
xkb_key_num_groups(struct xkb_keymap *keymap, xkb_keycode_t key);
/**
* Returns the number of LEDs in the given map.
*/
xkb_led_index_t
xkb_map_num_leds(struct xkb_keymap *xkb);
xkb_map_num_leds(struct xkb_keymap *keymap);
/**
* Returns the name of the LED specified by 'idx', or NULL if invalid.
*/
const char *
xkb_map_led_get_name(struct xkb_keymap *xkb, xkb_led_index_t idx);
xkb_map_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx);
/**
* Returns the index of the LED specified by 'name', or XKB_LED_INVALID.
*/
xkb_led_index_t
xkb_map_led_get_index(struct xkb_keymap *xkb, const char *name);
xkb_map_led_get_index(struct xkb_keymap *keymap, const char *name);
/** @} */
@ -422,7 +422,7 @@ xkb_map_led_get_index(struct xkb_keymap *xkb, const char *name);
* failure.
*/
struct xkb_state *
xkb_state_new(struct xkb_keymap *xkb);
xkb_state_new(struct xkb_keymap *keymap);
/**
* Takes a new reference on a state object.

View File

@ -27,29 +27,31 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "alloc.h"
int
XkbcAllocClientMap(struct xkb_keymap * xkb, unsigned which, unsigned nTotalTypes)
XkbcAllocClientMap(struct xkb_keymap *keymap, unsigned which,
unsigned nTotalTypes)
{
struct xkb_client_map * map;
if (!xkb || ((nTotalTypes > 0) && (nTotalTypes < XkbNumRequiredTypes)))
if (!keymap || ((nTotalTypes > 0) && (nTotalTypes < XkbNumRequiredTypes)))
return BadValue;
if ((which & XkbKeySymsMask) && !xkb_keymap_keycode_range_is_legal(xkb)) {
if ((which & XkbKeySymsMask) &&
!xkb_keymap_keycode_range_is_legal(keymap)) {
#ifdef DEBUG
fprintf(stderr, "bad keycode (%d,%d) in XkbAllocClientMap\n",
xkb->min_key_code, xkb->max_key_code);
keymap->min_key_code, keymap->max_key_code);
#endif
return BadValue;
}
if (!xkb->map) {
if (!keymap->map) {
map = uTypedCalloc(1, struct xkb_client_map);
if (!map)
return BadAlloc;
xkb->map = map;
keymap->map = map;
}
else
map = xkb->map;
map = keymap->map;
if ((which & XkbKeyTypesMask) && (nTotalTypes > 0)) {
if (!map->types) {
@ -79,7 +81,7 @@ XkbcAllocClientMap(struct xkb_keymap * xkb, unsigned which, unsigned nTotalTypes
if (which & XkbKeySymsMask) {
if (!map->key_sym_map) {
map->key_sym_map = uTypedCalloc(xkb->max_key_code + 1,
map->key_sym_map = uTypedCalloc(keymap->max_key_code + 1,
struct xkb_sym_map);
if (!map->key_sym_map)
return BadAlloc;
@ -88,7 +90,8 @@ XkbcAllocClientMap(struct xkb_keymap * xkb, unsigned which, unsigned nTotalTypes
if (which & XkbModifierMapMask) {
if (!map->modmap) {
map->modmap = uTypedCalloc(xkb->max_key_code + 1, unsigned char);
map->modmap = uTypedCalloc(keymap->max_key_code + 1,
unsigned char);
if (!map->modmap)
return BadAlloc;
}
@ -98,15 +101,16 @@ XkbcAllocClientMap(struct xkb_keymap * xkb, unsigned which, unsigned nTotalTypes
}
int
XkbcAllocServerMap(struct xkb_keymap * xkb, unsigned which, unsigned nNewActions)
XkbcAllocServerMap(struct xkb_keymap *keymap, unsigned which,
unsigned nNewActions)
{
unsigned i;
struct xkb_server_map * map;
if (!xkb)
if (!keymap)
return BadMatch;
if (!xkb->server) {
if (!keymap->server) {
map = uTypedCalloc(1, struct xkb_server_map);
if (!map)
return BadAlloc;
@ -114,19 +118,19 @@ XkbcAllocServerMap(struct xkb_keymap * xkb, unsigned which, unsigned nNewActions
for (i = 0; i < XkbNumVirtualMods; i++)
map->vmods[i] = XkbNoModifierMask;
xkb->server = map;
keymap->server = map;
}
else
map = xkb->server;
map = keymap->server;
if (!which)
return Success;
if (!xkb_keymap_keycode_range_is_legal(xkb))
if (!xkb_keymap_keycode_range_is_legal(keymap))
return BadMatch;
if (!map->explicit) {
i = xkb->max_key_code + 1;
i = keymap->max_key_code + 1;
map->explicit = uTypedCalloc(i, unsigned char);
if (!map->explicit)
return BadAlloc;
@ -160,21 +164,21 @@ XkbcAllocServerMap(struct xkb_keymap * xkb, unsigned which, unsigned nNewActions
}
if (!map->key_acts) {
i = xkb->max_key_code + 1;
i = keymap->max_key_code + 1;
map->key_acts = uTypedCalloc(i, unsigned short);
if (!map->key_acts)
return BadAlloc;
}
if (!map->behaviors) {
i = xkb->max_key_code + 1;
i = keymap->max_key_code + 1;
map->behaviors = uTypedCalloc(i, struct xkb_behavior);
if (!map->behaviors)
return BadAlloc;
}
if (!map->vmodmap) {
i = xkb->max_key_code + 1;
i = keymap->max_key_code + 1;
map->vmodmap = uTypedCalloc(i, uint32_t);
if (!map->vmodmap)
return BadAlloc;
@ -230,62 +234,63 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into)
}
bool
XkbcResizeKeySyms(struct xkb_keymap * xkb, xkb_keycode_t key,
XkbcResizeKeySyms(struct xkb_keymap *keymap, xkb_keycode_t key,
unsigned int needed)
{
if (xkb->map->key_sym_map[key].size_syms >= needed)
if (keymap->map->key_sym_map[key].size_syms >= needed)
return true;
xkb->map->key_sym_map[key].syms =
uTypedRecalloc(xkb->map->key_sym_map[key].syms,
xkb->map->key_sym_map[key].size_syms,
keymap->map->key_sym_map[key].syms =
uTypedRecalloc(keymap->map->key_sym_map[key].syms,
keymap->map->key_sym_map[key].size_syms,
needed,
xkb_keysym_t);
if (!xkb->map->key_sym_map[key].syms) {
xkb->map->key_sym_map[key].size_syms = 0;
if (!keymap->map->key_sym_map[key].syms) {
keymap->map->key_sym_map[key].size_syms = 0;
return false;
}
xkb->map->key_sym_map[key].size_syms = needed;
keymap->map->key_sym_map[key].size_syms = needed;
return true;
}
union xkb_action *
XkbcResizeKeyActions(struct xkb_keymap * xkb, xkb_keycode_t key, uint32_t needed)
XkbcResizeKeyActions(struct xkb_keymap *keymap, xkb_keycode_t key,
uint32_t needed)
{
xkb_keycode_t i, nActs;
union xkb_action *newActs;
if (needed == 0) {
xkb->server->key_acts[key] = 0;
keymap->server->key_acts[key] = 0;
return NULL;
}
if (XkbKeyHasActions(xkb, key) &&
(XkbKeyGroupsWidth(xkb, key) >= needed))
return XkbKeyActionsPtr(xkb, key);
if (XkbKeyHasActions(keymap, key) &&
(XkbKeyGroupsWidth(keymap, key) >= needed))
return XkbKeyActionsPtr(keymap, key);
if (xkb->server->size_acts - xkb->server->num_acts >= (int)needed) {
xkb->server->key_acts[key] = xkb->server->num_acts;
xkb->server->num_acts += needed;
if (keymap->server->size_acts - keymap->server->num_acts >= (int)needed) {
keymap->server->key_acts[key] = keymap->server->num_acts;
keymap->server->num_acts += needed;
return &xkb->server->acts[xkb->server->key_acts[key]];
return &keymap->server->acts[keymap->server->key_acts[key]];
}
xkb->server->size_acts = xkb->server->num_acts + needed + 8;
newActs = uTypedCalloc(xkb->server->size_acts, union xkb_action);
keymap->server->size_acts = keymap->server->num_acts + needed + 8;
newActs = uTypedCalloc(keymap->server->size_acts, union xkb_action);
if (!newActs)
return NULL;
newActs[0].type = XkbSA_NoAction;
nActs = 1;
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) {
xkb_keycode_t nKeyActs, nCopy;
if ((xkb->server->key_acts[i] == 0) && (i != key))
if ((keymap->server->key_acts[i] == 0) && (i != key))
continue;
nCopy = nKeyActs = XkbKeyNumActions(xkb, i);
nCopy = nKeyActs = XkbKeyNumActions(keymap, i);
if (i == key) {
nKeyActs= needed;
if (needed < nCopy)
@ -293,35 +298,35 @@ XkbcResizeKeyActions(struct xkb_keymap * xkb, xkb_keycode_t key, uint32_t needed
}
if (nCopy > 0)
memcpy(&newActs[nActs], XkbKeyActionsPtr(xkb, i),
memcpy(&newActs[nActs], XkbKeyActionsPtr(keymap, i),
nCopy * sizeof(union xkb_action));
if (nCopy < nKeyActs)
memset(&newActs[nActs + nCopy], 0,
(nKeyActs - nCopy) * sizeof(union xkb_action));
xkb->server->key_acts[i] = nActs;
keymap->server->key_acts[i] = nActs;
nActs += nKeyActs;
}
free(xkb->server->acts);
xkb->server->acts = newActs;
xkb->server->num_acts = nActs;
free(keymap->server->acts);
keymap->server->acts = newActs;
keymap->server->num_acts = nActs;
return &xkb->server->acts[xkb->server->key_acts[key]];
return &keymap->server->acts[keymap->server->key_acts[key]];
}
void
XkbcFreeClientMap(struct xkb_keymap * xkb)
XkbcFreeClientMap(struct xkb_keymap *keymap)
{
struct xkb_client_map * map;
struct xkb_key_type * type;
xkb_keycode_t key;
int i;
if (!xkb || !xkb->map)
if (!keymap || !keymap->map)
return;
map = xkb->map;
map = keymap->map;
for (i = 0, type = map->types; i < map->num_types && type; i++, type++) {
int j;
@ -335,7 +340,7 @@ XkbcFreeClientMap(struct xkb_keymap * xkb)
free(map->types);
if (map->key_sym_map) {
for (key = xkb->min_key_code; key < xkb->max_key_code; key++) {
for (key = keymap->min_key_code; key < keymap->max_key_code; key++) {
free(map->key_sym_map[key].sym_index);
free(map->key_sym_map[key].num_syms);
free(map->key_sym_map[key].syms);
@ -344,43 +349,43 @@ XkbcFreeClientMap(struct xkb_keymap * xkb)
free(map->key_sym_map);
free(map->modmap);
free(xkb->map);
xkb->map = NULL;
free(keymap->map);
keymap->map = NULL;
}
void
XkbcFreeServerMap(struct xkb_keymap * xkb)
XkbcFreeServerMap(struct xkb_keymap *keymap)
{
struct xkb_server_map * map;
if (!xkb || !xkb->server)
if (keymap || keymap->server)
return;
map = xkb->server;
map = keymap->server;
free(map->explicit);
free(map->key_acts);
free(map->acts);
free(map->behaviors);
free(map->vmodmap);
free(xkb->server);
xkb->server = NULL;
free(keymap->server);
keymap->server = NULL;
}
int
XkbcAllocCompatMap(struct xkb_keymap *xkb, unsigned nSI)
XkbcAllocCompatMap(struct xkb_keymap *keymap, unsigned nSI)
{
struct xkb_compat_map * compat;
struct xkb_sym_interpret *prev_interpret;
if (!xkb)
if (!keymap)
return BadMatch;
if (xkb->compat) {
if (xkb->compat->size_si >= nSI)
if (keymap->compat) {
if (keymap->compat->size_si >= nSI)
return Success;
compat = xkb->compat;
compat = keymap->compat;
compat->size_si = nSI;
if (!compat->sym_interpret)
compat->num_si = 0;
@ -412,48 +417,49 @@ XkbcAllocCompatMap(struct xkb_keymap *xkb, unsigned nSI)
compat->size_si = nSI;
compat->num_si = 0;
memset(&compat->groups[0], 0, XkbNumKbdGroups * sizeof(struct xkb_mods));
xkb->compat = compat;
keymap->compat = compat;
return Success;
}
static void
XkbcFreeCompatMap(struct xkb_keymap * xkb)
XkbcFreeCompatMap(struct xkb_keymap *keymap)
{
struct xkb_compat_map * compat;
if (!xkb || !xkb->compat)
if (!keymap || !keymap->compat)
return;
compat = xkb->compat;
compat = keymap->compat;
free(compat->sym_interpret);
free(compat);
xkb->compat = NULL;
keymap->compat = NULL;
}
int
XkbcAllocNames(struct xkb_keymap * xkb, unsigned which, unsigned nTotalAliases)
XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
unsigned nTotalAliases)
{
struct xkb_names * names;
if (!xkb)
if (!keymap)
return BadMatch;
if (!xkb->names) {
xkb->names = uTypedCalloc(1, struct xkb_names);
if (!xkb->names)
if (!keymap->names) {
keymap->names = uTypedCalloc(1, struct xkb_names);
if (!keymap->names)
return BadAlloc;
}
names = xkb->names;
names = keymap->names;
if ((which & XkbKTLevelNamesMask) && xkb->map && xkb->map->types) {
if ((which & XkbKTLevelNamesMask) && keymap->map && keymap->map->types) {
int i;
struct xkb_key_type * type;
type = xkb->map->types;
for (i = 0; i < xkb->map->num_types; i++, type++) {
type = keymap->map->types;
for (i = 0; i < keymap->map->num_types; i++, type++) {
if (!type->level_names) {
type->level_names = uTypedCalloc(type->num_levels, const char *);
if (!type->level_names)
@ -463,10 +469,11 @@ XkbcAllocNames(struct xkb_keymap * xkb, unsigned which, unsigned nTotalAliases)
}
if ((which & XkbKeyNamesMask) && !names->keys) {
if (!xkb_keymap_keycode_range_is_legal(xkb))
if (!xkb_keymap_keycode_range_is_legal(keymap))
return BadMatch;
names->keys = uTypedCalloc(xkb->max_key_code + 1, struct xkb_key_name);
names->keys = uTypedCalloc(keymap->max_key_code + 1,
struct xkb_key_name);
if (!names->keys)
return BadAlloc;
}
@ -498,17 +505,17 @@ XkbcAllocNames(struct xkb_keymap * xkb, unsigned which, unsigned nTotalAliases)
}
static void
XkbcFreeNames(struct xkb_keymap * xkb)
XkbcFreeNames(struct xkb_keymap *keymap)
{
struct xkb_names * names;
struct xkb_client_map * map;
int i;
if (!xkb || !xkb->names)
if (!keymap || !keymap->names)
return;
names = xkb->names;
map = xkb->map;
names = keymap->names;
map = keymap->map;
if (map && map->types) {
struct xkb_key_type * type = map->types;
@ -532,48 +539,48 @@ XkbcFreeNames(struct xkb_keymap * xkb)
free(names->keys);
free(names->key_aliases);
free(names);
xkb->names = NULL;
keymap->names = NULL;
}
int
XkbcAllocControls(struct xkb_keymap * xkb)
XkbcAllocControls(struct xkb_keymap *keymap)
{
if (!xkb)
if (!keymap)
return BadMatch;
if (!xkb->ctrls) {
xkb->ctrls = uTypedCalloc(1, struct xkb_controls);
if (!xkb->ctrls)
if (!keymap->ctrls) {
keymap->ctrls = uTypedCalloc(1, struct xkb_controls);
if (!keymap->ctrls)
return BadAlloc;
}
xkb->ctrls->per_key_repeat = uTypedCalloc(xkb->max_key_code << 3,
keymap->ctrls->per_key_repeat = uTypedCalloc(keymap->max_key_code >> 3,
unsigned char);
if (!xkb->ctrls->per_key_repeat)
if (!keymap->ctrls->per_key_repeat)
return BadAlloc;
return Success;
}
static void
XkbcFreeControls(struct xkb_keymap * xkb)
XkbcFreeControls(struct xkb_keymap *keymap)
{
if (xkb && xkb->ctrls) {
free(xkb->ctrls->per_key_repeat);
free(xkb->ctrls);
xkb->ctrls = NULL;
if (keymap && keymap->ctrls) {
free(keymap->ctrls->per_key_repeat);
free(keymap->ctrls);
keymap->ctrls = NULL;
}
}
int
XkbcAllocIndicatorMaps(struct xkb_keymap * xkb)
XkbcAllocIndicatorMaps(struct xkb_keymap *keymap)
{
if (!xkb)
if (!keymap)
return BadMatch;
if (!xkb->indicators) {
xkb->indicators = uTypedCalloc(1, struct xkb_indicator);
if (!xkb->indicators)
if (!keymap->indicators) {
keymap->indicators = uTypedCalloc(1, struct xkb_indicator);
if (!keymap->indicators)
return BadAlloc;
}
@ -581,41 +588,41 @@ XkbcAllocIndicatorMaps(struct xkb_keymap * xkb)
}
static void
XkbcFreeIndicatorMaps(struct xkb_keymap * xkb)
XkbcFreeIndicatorMaps(struct xkb_keymap *keymap)
{
if (xkb) {
free(xkb->indicators);
xkb->indicators = NULL;
if (keymap) {
free(keymap->indicators);
keymap->indicators = NULL;
}
}
struct xkb_keymap *
XkbcAllocKeyboard(struct xkb_context *context)
{
struct xkb_keymap *xkb;
struct xkb_keymap *keymap;
xkb = uTypedCalloc(1, struct xkb_keymap);
if (!xkb)
keymap = uTypedCalloc(1, struct xkb_keymap);
if (!keymap)
return NULL;
xkb->refcnt = 1;
xkb->context = xkb_context_ref(context);
keymap->refcnt = 1;
keymap->context = xkb_context_ref(context);
return xkb;
return keymap;
}
void
XkbcFreeKeyboard(struct xkb_keymap * xkb)
XkbcFreeKeyboard(struct xkb_keymap *keymap)
{
if (!xkb)
if (!keymap)
return;
XkbcFreeClientMap(xkb);
XkbcFreeServerMap(xkb);
XkbcFreeCompatMap(xkb);
XkbcFreeIndicatorMaps(xkb);
XkbcFreeNames(xkb);
XkbcFreeControls(xkb);
xkb_context_unref(xkb->context);
free(xkb);
XkbcFreeClientMap(keymap);
XkbcFreeServerMap(keymap);
XkbcFreeCompatMap(keymap);
XkbcFreeIndicatorMaps(keymap);
XkbcFreeNames(keymap);
XkbcFreeControls(keymap);
xkb_context_unref(keymap->context);
free(keymap);
}

View File

@ -30,42 +30,47 @@ authorization from the authors.
#include "xkb-priv.h"
extern int
XkbcAllocCompatMap(struct xkb_keymap *xkb, unsigned nSI);
XkbcAllocCompatMap(struct xkb_keymap *keymap, unsigned nSI);
extern int
XkbcAllocNames(struct xkb_keymap * xkb, unsigned which, unsigned nTotalAliases);
XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
unsigned nTotalAliases);
extern int
XkbcAllocControls(struct xkb_keymap *xkb);
XkbcAllocControls(struct xkb_keymap *keymap);
extern int
XkbcAllocIndicatorMaps(struct xkb_keymap * xkb);
XkbcAllocIndicatorMaps(struct xkb_keymap *keymap);
extern struct xkb_keymap *
XkbcAllocKeyboard(struct xkb_context *context);
extern void
XkbcFreeKeyboard(struct xkb_keymap * xkb);
XkbcFreeKeyboard(struct xkb_keymap *keymap);
extern int
XkbcAllocClientMap(struct xkb_keymap * xkb, unsigned which, unsigned nTotalTypes);
XkbcAllocClientMap(struct xkb_keymap *keymap, unsigned which,
unsigned nTotalTypes);
extern int
XkbcAllocServerMap(struct xkb_keymap * xkb, unsigned which, unsigned nNewActions);
XkbcAllocServerMap(struct xkb_keymap *keymap, unsigned which,
unsigned nNewActions);
extern int
XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type *into);
XkbcCopyKeyType(struct xkb_key_type *from, struct xkb_key_type *into);
extern bool
XkbcResizeKeySyms(struct xkb_keymap * xkb, xkb_keycode_t key, uint32_t needed);
XkbcResizeKeySyms(struct xkb_keymap *keymap, xkb_keycode_t key,
uint32_t needed);
extern union xkb_action *
XkbcResizeKeyActions(struct xkb_keymap * xkb, xkb_keycode_t key, uint32_t needed);
XkbcResizeKeyActions(struct xkb_keymap *keymap, xkb_keycode_t key,
uint32_t needed);
extern void
XkbcFreeClientMap(struct xkb_keymap * xkb);
XkbcFreeClientMap(struct xkb_keymap *keymap);
extern void
XkbcFreeServerMap(struct xkb_keymap * xkb);
XkbcFreeServerMap(struct xkb_keymap *keymap);
#endif /* ALLOC_H */

View File

@ -55,12 +55,12 @@
* Returns the total number of modifiers active in the keymap.
*/
_X_EXPORT xkb_mod_index_t
xkb_map_num_mods(struct xkb_keymap *xkb)
xkb_map_num_mods(struct xkb_keymap *keymap)
{
xkb_mod_index_t i;
for (i = 0; i < XkbNumVirtualMods; i++)
if (!xkb->names->vmods[i])
if (!keymap->names->vmods[i])
break;
/* We always have all the core modifiers (for now), plus any virtual
@ -72,9 +72,9 @@ xkb_map_num_mods(struct xkb_keymap *xkb)
* Return the name for a given modifier.
*/
_X_EXPORT const char *
xkb_map_mod_get_name(struct xkb_keymap *xkb, xkb_mod_index_t idx)
xkb_map_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx)
{
if (idx >= xkb_map_num_mods(xkb))
if (idx >= xkb_map_num_mods(keymap))
return NULL;
/* First try to find a legacy modifier name. */
@ -100,14 +100,14 @@ xkb_map_mod_get_name(struct xkb_keymap *xkb, xkb_mod_index_t idx)
}
/* If that fails, try to find a virtual mod name. */
return xkb->names->vmods[idx - Mod5MapIndex];
return keymap->names->vmods[idx - Mod5MapIndex];
}
/**
* Returns the index for a named modifier.
*/
_X_EXPORT xkb_mod_index_t
xkb_map_mod_get_index(struct xkb_keymap *xkb, const char *name)
xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_mod_index_t i;
@ -128,8 +128,8 @@ xkb_map_mod_get_index(struct xkb_keymap *xkb, const char *name)
if (strcasecmp(name, "Mod5") == 0)
return Mod5MapIndex;
for (i = 0; i < XkbNumVirtualMods && xkb->names->vmods[i]; i++) {
if (strcasecmp(name, xkb->names->vmods[i]) == 0)
for (i = 0; i < XkbNumVirtualMods && keymap->names->vmods[i]; i++) {
if (strcasecmp(name, keymap->names->vmods[i]) == 0)
return i + Mod5MapIndex;
}
@ -140,13 +140,13 @@ xkb_map_mod_get_index(struct xkb_keymap *xkb, const char *name)
* Return the total number of active groups in the keymap.
*/
_X_EXPORT xkb_group_index_t
xkb_map_num_groups(struct xkb_keymap *xkb)
xkb_map_num_groups(struct xkb_keymap *keymap)
{
xkb_group_index_t ret = 0;
xkb_group_index_t i;
for (i = 0; i < XkbNumKbdGroups; i++)
if (xkb->compat->groups[i].mask)
if (keymap->compat->groups[i].mask)
ret++;
return ret;
@ -156,25 +156,25 @@ xkb_map_num_groups(struct xkb_keymap *xkb)
* Returns the name for a given group.
*/
_X_EXPORT const char *
xkb_map_group_get_name(struct xkb_keymap *xkb, xkb_group_index_t idx)
xkb_map_group_get_name(struct xkb_keymap *keymap, xkb_group_index_t idx)
{
if (idx >= xkb_map_num_groups(xkb))
if (idx >= xkb_map_num_groups(keymap))
return NULL;
return xkb->names->groups[idx];
return keymap->names->groups[idx];
}
/**
* Returns the index for a named group.
*/
_X_EXPORT xkb_group_index_t
xkb_map_group_get_index(struct xkb_keymap *xkb, const char *name)
xkb_map_group_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_group_index_t num_groups = xkb_map_num_groups(xkb);
xkb_group_index_t num_groups = xkb_map_num_groups(keymap);
xkb_group_index_t i;
for (i = 0; i < num_groups; i++) {
if (strcasecmp(xkb->names->groups[i], name) == 0)
if (strcasecmp(keymap->names->groups[i], name) == 0)
return i;
}
@ -185,24 +185,24 @@ xkb_map_group_get_index(struct xkb_keymap *xkb, const char *name)
* Returns the number of groups active for a particular key.
*/
_X_EXPORT xkb_group_index_t
xkb_key_num_groups(struct xkb_keymap *xkb, xkb_keycode_t key)
xkb_key_num_groups(struct xkb_keymap *keymap, xkb_keycode_t key)
{
return XkbKeyNumGroups(xkb, key);
return XkbKeyNumGroups(keymap, key);
}
/**
* Return the total number of active LEDs in the keymap.
*/
_X_EXPORT xkb_led_index_t
xkb_map_num_leds(struct xkb_keymap *xkb)
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++)
if (xkb->indicators->maps[i].which_groups ||
xkb->indicators->maps[i].which_mods ||
xkb->indicators->maps[i].ctrls)
if (keymap->indicators->maps[i].which_groups ||
keymap->indicators->maps[i].which_mods ||
keymap->indicators->maps[i].ctrls)
ret++;
return ret;
@ -212,25 +212,25 @@ xkb_map_num_leds(struct xkb_keymap *xkb)
* Returns the name for a given group.
*/
_X_EXPORT const char *
xkb_map_led_get_name(struct xkb_keymap *xkb, xkb_led_index_t idx)
xkb_map_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx)
{
if (idx >= xkb_map_num_leds(xkb))
if (idx >= xkb_map_num_leds(keymap))
return NULL;
return xkb->names->indicators[idx];
return keymap->names->indicators[idx];
}
/**
* Returns the index for a named group.
*/
_X_EXPORT xkb_group_index_t
xkb_map_led_get_index(struct xkb_keymap *xkb, const char *name)
xkb_map_led_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_led_index_t num_leds = xkb_map_num_leds(xkb);
xkb_led_index_t num_leds = xkb_map_num_leds(keymap);
xkb_led_index_t i;
for (i = 0; i < num_leds; i++) {
if (strcasecmp(xkb->names->indicators[i], name) == 0)
if (strcasecmp(keymap->names->indicators[i], name) == 0)
return i;
}
@ -244,7 +244,8 @@ _X_EXPORT unsigned int
xkb_key_get_level(struct xkb_state *state, xkb_keycode_t key,
unsigned int group)
{
struct xkb_key_type *type = XkbKeyType(state->xkb, key, group);
struct xkb_keymap *keymap = state->keymap;
struct xkb_key_type *type = XkbKeyType(keymap, key, group);
unsigned int active_mods = state->mods & type->mods.mask;
int i;
@ -265,11 +266,12 @@ xkb_key_get_level(struct xkb_state *state, xkb_keycode_t key,
_X_EXPORT unsigned int
xkb_key_get_group(struct xkb_state *state, xkb_keycode_t key)
{
unsigned int info = XkbKeyGroupInfo(state->xkb, key);
unsigned int num_groups = XkbKeyNumGroups(state->xkb, key);
struct xkb_keymap *keymap = state->keymap;
unsigned int info = XkbKeyGroupInfo(keymap, key);
unsigned int num_groups = XkbKeyNumGroups(keymap, key);
unsigned int ret = state->group;
if (ret < XkbKeyNumGroups(state->xkb, key))
if (ret < XkbKeyNumGroups(keymap, key))
return ret;
switch (XkbOutOfRangeGroupAction(info)) {
@ -294,21 +296,22 @@ xkb_key_get_group(struct xkb_state *state, xkb_keycode_t key)
* As below, but takes an explicit group/level rather than state.
*/
unsigned int
xkb_key_get_syms_by_level(struct xkb_keymap *xkb, xkb_keycode_t key, unsigned int group,
unsigned int level, const xkb_keysym_t **syms_out)
xkb_key_get_syms_by_level(struct xkb_keymap *keymap, xkb_keycode_t key,
unsigned int group, unsigned int level,
const xkb_keysym_t **syms_out)
{
int num_syms;
if (group >= XkbKeyNumGroups(xkb, key))
if (group >= XkbKeyNumGroups(keymap, key))
goto err;
if (level >= XkbKeyGroupWidth(xkb, key, group))
if (level >= XkbKeyGroupWidth(keymap, key, group))
goto err;
num_syms = XkbKeyNumSyms(xkb, key, group, level);
num_syms = XkbKeyNumSyms(keymap, key, group, level);
if (num_syms == 0)
goto err;
*syms_out = XkbKeySymEntry(xkb, key, group, level);
*syms_out = XkbKeySymEntry(keymap, key, group, level);
return num_syms;
err:
@ -324,11 +327,11 @@ _X_EXPORT unsigned int
xkb_key_get_syms(struct xkb_state *state, xkb_keycode_t key,
const xkb_keysym_t **syms_out)
{
struct xkb_keymap *xkb = state->xkb;
struct xkb_keymap *keymap = state->keymap;
int group;
int level;
if (!state || key < xkb->min_key_code || key > xkb->max_key_code)
if (!state || key < keymap->min_key_code || key > keymap->max_key_code)
return -1;
group = xkb_key_get_group(state, key);
@ -338,7 +341,7 @@ xkb_key_get_syms(struct xkb_state *state, xkb_keycode_t key,
if (level == -1)
goto err;
return xkb_key_get_syms_by_level(xkb, key, group, level, syms_out);
return xkb_key_get_syms_by_level(keymap, key, group, level, syms_out);
err:
*syms_out = NULL;

View File

@ -78,20 +78,21 @@ static struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
};
int
XkbcInitCanonicalKeyTypes(struct xkb_keymap * xkb, unsigned which, int keypadVMod)
XkbcInitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which,
int keypadVMod)
{
struct xkb_client_map * map;
struct xkb_key_type *from, *to;
int rtrn;
if (!xkb)
if (!keymap)
return BadMatch;
rtrn= XkbcAllocClientMap(xkb, XkbKeyTypesMask, XkbNumRequiredTypes);
rtrn = XkbcAllocClientMap(keymap, XkbKeyTypesMask, XkbNumRequiredTypes);
if (rtrn != Success)
return rtrn;
map= xkb->map;
map = keymap->map;
if ((which & XkbAllRequiredTypes) == 0)
return Success;

View File

@ -79,8 +79,8 @@ xkb_key_get_action(struct xkb_state *state, xkb_keycode_t key)
{
int group, level;
if (!XkbKeyHasActions(state->xkb, key) ||
!XkbKeycodeInRange(state->xkb, key)) {
if (!XkbKeyHasActions(state->keymap, key) ||
!XkbKeycodeInRange(state->keymap, key)) {
static union xkb_action fake;
memset(&fake, 0, sizeof(fake));
fake.type = XkbSA_NoAction;
@ -90,7 +90,7 @@ xkb_key_get_action(struct xkb_state *state, xkb_keycode_t key)
group = xkb_key_get_group(state, key);
level = xkb_key_get_level(state, key, group);
return XkbKeyActionEntry(state->xkb, key, level, group);
return XkbKeyActionEntry(state->keymap, key, level, group);
}
static struct xkb_filter *
@ -456,11 +456,11 @@ xkb_filter_apply_all(struct xkb_state *state, xkb_keycode_t key,
}
_X_EXPORT struct xkb_state *
xkb_state_new(struct xkb_keymap *xkb)
xkb_state_new(struct xkb_keymap *keymap)
{
struct xkb_state *ret;
if (!xkb)
if (!keymap)
return NULL;
ret = calloc(sizeof(*ret), 1);
@ -468,7 +468,7 @@ xkb_state_new(struct xkb_keymap *xkb)
return NULL;
ret->refcnt = 1;
ret->xkb = xkb_map_ref(xkb);
ret->keymap = xkb_map_ref(keymap);
return ret;
}
@ -488,7 +488,7 @@ xkb_state_unref(struct xkb_state *state)
if (state->refcnt > 0)
return;
xkb_map_unref(state->xkb);
xkb_map_unref(state->keymap);
free(state->filters);
free(state);
}
@ -496,7 +496,7 @@ xkb_state_unref(struct xkb_state *state)
_X_EXPORT struct xkb_keymap *
xkb_state_get_map(struct xkb_state *state)
{
return state->xkb;
return state->keymap;
}
/**
@ -510,7 +510,7 @@ xkb_state_led_update_all(struct xkb_state *state)
state->leds = 0;
for (led = 0; led < XkbNumIndicators; led++) {
struct xkb_indicator_map *map = &state->xkb->indicators->maps[led];
struct xkb_indicator_map *map = &state->keymap->indicators->maps[led];
uint32_t mod_mask = 0;
uint32_t group_mask = 0;
@ -542,7 +542,7 @@ xkb_state_led_update_all(struct xkb_state *state)
state->leds |= (1 << led);
}
else if (map->ctrls) {
if ((map->ctrls & state->xkb->ctrls->enabled_ctrls))
if ((map->ctrls & state->keymap->ctrls->enabled_ctrls))
state->leds |= (1 << led);
}
}
@ -597,7 +597,7 @@ xkb_state_update_mask(struct xkb_state *state,
state->base_mods = 0;
state->latched_mods = 0;
state->locked_mods = 0;
for (mod = 0; mod < xkb_map_num_mods(state->xkb); mod++) {
for (mod = 0; mod < xkb_map_num_mods(state->keymap); mod++) {
xkb_mod_mask_t idx = (1 << mod);
if (base_mods & idx)
state->base_mods |= idx;
@ -671,7 +671,7 @@ xkb_state_mod_index_is_active(struct xkb_state *state,
{
int ret = 0;
if (idx >= xkb_map_num_mods(state->xkb))
if (idx >= xkb_map_num_mods(state->keymap))
return -1;
if (type & XKB_STATE_DEPRESSED)
@ -723,7 +723,8 @@ xkb_state_mod_indices_are_active(struct xkb_state *state,
va_start(ap, match);
while (1) {
idx = va_arg(ap, xkb_mod_index_t);
if (idx == XKB_MOD_INVALID || idx >= xkb_map_num_mods(state->xkb)) {
if (idx == XKB_MOD_INVALID ||
idx >= xkb_map_num_mods(state->keymap)) {
ret = -1;
break;
}
@ -745,7 +746,7 @@ _X_EXPORT int
xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type)
{
xkb_mod_index_t idx = xkb_map_mod_get_index(state->xkb, name);
xkb_mod_index_t idx = xkb_map_mod_get_index(state->keymap, name);
if (idx == XKB_MOD_INVALID)
return -1;
@ -774,7 +775,7 @@ xkb_state_mod_names_are_active(struct xkb_state *state,
str = va_arg(ap, const char *);
if (str == NULL)
break;
idx = xkb_map_mod_get_index(state->xkb, str);
idx = xkb_map_mod_get_index(state->keymap, str);
if (idx == XKB_MOD_INVALID) {
ret = -1;
break;
@ -800,7 +801,7 @@ xkb_state_group_index_is_active(struct xkb_state *state,
{
int ret = 0;
if (idx >= xkb_map_num_groups(state->xkb))
if (idx >= xkb_map_num_groups(state->keymap))
return -1;
if (type & XKB_STATE_DEPRESSED)
@ -821,7 +822,7 @@ _X_EXPORT int
xkb_state_group_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type)
{
xkb_group_index_t idx = xkb_map_group_get_index(state->xkb, name);
xkb_group_index_t idx = xkb_map_group_get_index(state->keymap, name);
if (idx == XKB_GROUP_INVALID)
return -1;
@ -835,7 +836,7 @@ xkb_state_group_name_is_active(struct xkb_state *state, const char *name,
_X_EXPORT int
xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
{
if (idx >= xkb_map_num_leds(state->xkb))
if (idx >= xkb_map_num_leds(state->keymap))
return -1;
return !!(state->leds & (1 << idx));
@ -847,7 +848,7 @@ xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
_X_EXPORT int
xkb_state_led_name_is_active(struct xkb_state *state, const char *name)
{
xkb_led_index_t idx = xkb_map_led_get_index(state->xkb, name);
xkb_led_index_t idx = xkb_map_led_get_index(state->keymap, name);
if (idx == XKB_LED_INVALID)
return -1;

View File

@ -48,7 +48,7 @@ tbGetBuffer(unsigned int size)
}
static const char *
XkbcVModIndexText(struct xkb_keymap * xkb, unsigned ndx)
XkbcVModIndexText(struct xkb_keymap *keymap, unsigned ndx)
{
int len;
char *rtrn;
@ -57,8 +57,8 @@ XkbcVModIndexText(struct xkb_keymap * xkb, unsigned ndx)
if (ndx >= XkbNumVirtualMods)
tmp = "illegal";
else if (xkb && xkb->names)
tmp = xkb->names->vmods[ndx];
else if (keymap && keymap->names)
tmp = keymap->names->vmods[ndx];
if (!tmp) {
snprintf(buf, sizeof(buf) - 1, "%d", ndx);
@ -76,7 +76,7 @@ XkbcVModIndexText(struct xkb_keymap * xkb, unsigned ndx)
}
const char *
XkbcVModMaskText(struct xkb_keymap * xkb, unsigned modMask, unsigned mask)
XkbcVModMaskText(struct xkb_keymap *keymap, unsigned modMask, unsigned mask)
{
int i, bit, len, rem;
const char *mm = NULL;
@ -101,7 +101,7 @@ XkbcVModMaskText(struct xkb_keymap * xkb, unsigned modMask, unsigned mask)
len = snprintf(str, rem, "%s%s",
(str != buf) ? "+" : "",
XkbcVModIndexText(xkb, i));
XkbcVModIndexText(keymap, i));
rem -= len;
str += len;
}

View File

@ -30,7 +30,7 @@ authorization from the authors.
#include "xkb-priv.h"
extern const char *
XkbcVModMaskText(struct xkb_keymap * xkb, unsigned modMask, unsigned mask);
XkbcVModMaskText(struct xkb_keymap *keymap, unsigned modMask, unsigned mask);
extern const char *
XkbcModIndexText(unsigned ndx);

View File

@ -423,7 +423,7 @@ struct xkb_state {
int refcnt;
void *filters;
int num_filters;
struct xkb_keymap *xkb;
struct xkb_keymap *keymap;
};
extern unsigned int
@ -434,15 +434,15 @@ xkb_key_get_level(struct xkb_state *state, xkb_keycode_t key,
unsigned int group);
extern unsigned int
xkb_key_get_syms_by_level(struct xkb_keymap *xkb, xkb_keycode_t key,
xkb_key_get_syms_by_level(struct xkb_keymap *keymap, xkb_keycode_t key,
unsigned int group, unsigned int level,
const xkb_keysym_t **syms_out);
extern bool
XkbcComputeEffectiveMap(struct xkb_keymap * xkb, struct xkb_key_type * type,
XkbcComputeEffectiveMap(struct xkb_keymap *keymap, struct xkb_key_type *type,
unsigned char *map_rtrn);
extern int
XkbcInitCanonicalKeyTypes(struct xkb_keymap * xkb, unsigned which,
XkbcInitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which,
int keypadVMod);
extern unsigned

View File

@ -91,24 +91,24 @@ xkb_canonicalise_components(struct xkb_component_names * names,
}
static bool
VirtualModsToReal(struct xkb_keymap *xkb, unsigned virtual_mask,
VirtualModsToReal(struct xkb_keymap *keymap, unsigned virtual_mask,
unsigned *mask_rtrn)
{
int i, bit;
unsigned mask;
if (!xkb)
if (!keymap)
return false;
if (virtual_mask == 0) {
*mask_rtrn = 0;
return true;
}
if (!xkb->server)
if (!keymap->server)
return false;
for (i = mask = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
if (virtual_mask & bit)
mask |= xkb->server->vmods[i];
mask |= keymap->server->vmods[i];
}
*mask_rtrn = mask;
@ -116,18 +116,18 @@ VirtualModsToReal(struct xkb_keymap *xkb, unsigned virtual_mask,
}
bool
XkbcComputeEffectiveMap(struct xkb_keymap * xkb, struct xkb_key_type * type,
XkbcComputeEffectiveMap(struct xkb_keymap *keymap, struct xkb_key_type *type,
unsigned char *map_rtrn)
{
int i;
unsigned tmp;
struct xkb_kt_map_entry * entry = NULL;
if (!xkb || !type || !xkb->server)
if (!keymap || !type || !keymap->server)
return false;
if (type->mods.vmods != 0) {
if (!VirtualModsToReal(xkb, type->mods.vmods, &tmp))
if (!VirtualModsToReal(keymap, type->mods.vmods, &tmp))
return false;
type->mods.mask = tmp | type->mods.real_mods;
@ -135,7 +135,7 @@ XkbcComputeEffectiveMap(struct xkb_keymap * xkb, struct xkb_key_type * type,
for (i = 0; i < type->map_count; i++, entry++) {
tmp = 0;
if (entry->mods.vmods != 0) {
if (!VirtualModsToReal(xkb, entry->mods.vmods, &tmp))
if (!VirtualModsToReal(keymap, entry->mods.vmods, &tmp))
return false;
if (tmp == 0) {
entry->active = false;

View File

@ -203,9 +203,8 @@ ReportNotFound(unsigned action, unsigned field, const char *what,
}
static bool
HandleNoAction(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleNoAction(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
return ReportIllegal(action->type, field);
}
@ -233,9 +232,7 @@ CheckLatchLockFlags(unsigned action,
}
static bool
CheckModifierField(struct xkb_keymap * xkb,
unsigned action,
ExprDef * value,
CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
unsigned *flags_inout, unsigned *mods_rtrn)
{
ExprResult rtrn;
@ -253,7 +250,7 @@ CheckModifierField(struct xkb_keymap * xkb,
return true;
}
}
if (!ExprResolveVModMask(value, &rtrn, xkb))
if (!ExprResolveVModMask(value, &rtrn, keymap))
return ReportMismatch(action, F_Modifiers, "modifier mask");
*mods_rtrn = rtrn.uval;
*flags_inout &= ~XkbSA_UseModMapMods;
@ -261,9 +258,8 @@ CheckModifierField(struct xkb_keymap * xkb,
}
static bool
HandleSetLatchMods(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
struct xkb_mod_action *act;
unsigned rtrn;
@ -293,7 +289,7 @@ HandleSetLatchMods(struct xkb_keymap * xkb,
return false;
case F_Modifiers:
t1 = act->flags;
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
if (CheckModifierField(keymap, action->type, value, &t1, &t2))
{
act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff);
@ -306,9 +302,8 @@ HandleSetLatchMods(struct xkb_keymap * xkb,
}
static bool
HandleLockMods(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
struct xkb_mod_action *act;
unsigned t1, t2;
@ -320,7 +315,7 @@ HandleLockMods(struct xkb_keymap * xkb,
{
case F_Modifiers:
t1 = act->flags;
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
if (CheckModifierField(keymap, action->type, value, &t1, &t2))
{
act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff);
@ -362,9 +357,8 @@ CheckGroupField(unsigned action,
}
static bool
HandleSetLatchGroup(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
struct xkb_group_action *act;
unsigned rtrn;
@ -407,9 +401,8 @@ HandleSetLatchGroup(struct xkb_keymap * xkb,
}
static bool
HandleLockGroup(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
struct xkb_group_action *act;
unsigned t1;
@ -433,9 +426,8 @@ HandleLockGroup(struct xkb_keymap * xkb,
}
static bool
HandleMovePtr(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
struct xkb_pointer_action *act;
@ -488,9 +480,8 @@ static const LookupEntry lockWhich[] = {
};
static bool
HandlePtrBtn(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
struct xkb_pointer_button_action *act;
@ -548,9 +539,8 @@ static const LookupEntry ptrDflts[] = {
};
static bool
HandleSetPtrDflt(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
struct xkb_pointer_default_action *act;
@ -620,9 +610,8 @@ static const LookupEntry isoNames[] = {
};
static bool
HandleISOLock(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
struct xkb_iso_action *act;
@ -636,7 +625,7 @@ HandleISOLock(struct xkb_keymap * xkb,
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
flags = act->flags;
if (CheckModifierField(xkb, action->type, value, &flags, &mods))
if (CheckModifierField(keymap, action->type, value, &flags, &mods))
{
act->flags = flags & (~XkbSA_ISODfltIsGroup);
act->real_mods = mods & 0xff;
@ -667,9 +656,8 @@ HandleISOLock(struct xkb_keymap * xkb,
}
static bool
HandleSwitchScreen(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
struct xkb_switch_screen_action *act;
@ -742,9 +730,8 @@ const LookupEntry ctrlNames[] = {
};
static bool
HandleSetLockControls(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleSetLockControls(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
struct xkb_controls_action *act;
@ -773,9 +760,8 @@ static const LookupEntry evNames[] = {
};
static bool
HandleActionMessage(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
struct xkb_message_action *act;
@ -851,9 +837,8 @@ HandleActionMessage(struct xkb_keymap * xkb,
}
static bool
HandleRedirectKey(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
struct xkb_redirect_key_action *act;
@ -871,7 +856,7 @@ HandleRedirectKey(struct xkb_keymap * xkb,
if (!ExprResolveKeyName(value, &rtrn))
return ReportMismatch(action->type, field, "key name");
tmp = KeyNameToLong(rtrn.keyName.name);
if (!FindNamedKey(xkb, tmp, &kc, true, CreateKeyNames(xkb), 0))
if (!FindNamedKey(keymap, tmp, &kc, true, CreateKeyNames(keymap), 0))
{
return ReportNotFound(action->type, field, "Key",
XkbcKeyNameText(rtrn.keyName.name));
@ -881,7 +866,7 @@ HandleRedirectKey(struct xkb_keymap * xkb,
case F_ModsToClear:
case F_Modifiers:
t1 = 0;
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
if (CheckModifierField(keymap, action->type, value, &t1, &t2))
{
act->mods_mask |= (t2 & 0xff);
if (field == F_Modifiers)
@ -903,9 +888,8 @@ HandleRedirectKey(struct xkb_keymap * xkb,
}
static bool
HandleDeviceBtn(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
struct xkb_device_button_action *act;
@ -972,9 +956,8 @@ HandleDeviceBtn(struct xkb_keymap * xkb,
}
static bool
HandleDeviceValuator(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandleDeviceValuator(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
#if 0
ExprResult rtrn;
@ -987,9 +970,8 @@ HandleDeviceValuator(struct xkb_keymap * xkb,
}
static bool
HandlePrivate(struct xkb_keymap * xkb,
struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
ExprResult rtrn;
@ -1056,7 +1038,7 @@ HandlePrivate(struct xkb_keymap * xkb,
return ReportIllegal(PrivateAction, field);
}
typedef bool (*actionHandler) (struct xkb_keymap *xkb,
typedef bool (*actionHandler) (struct xkb_keymap *keymap,
struct xkb_any_action *action, unsigned field,
ExprDef *array_ndx, ExprDef *value);
@ -1107,8 +1089,8 @@ ActionsInit(void);
int
HandleActionDef(ExprDef * def,
struct xkb_keymap * xkb,
struct xkb_any_action * action, ActionInfo * info)
struct xkb_keymap *keymap,
struct xkb_any_action *action, ActionInfo *info)
{
ExprDef *arg;
const char *str;
@ -1143,7 +1125,7 @@ HandleActionDef(ExprDef * def,
if ((info->action == XkbSA_NoAction)
|| (info->action == hndlrType))
{
if (!(*handleAction[hndlrType]) (xkb, action,
if (!(*handleAction[hndlrType]) (keymap, action,
info->field,
info->array_ndx,
info->value))
@ -1202,19 +1184,17 @@ HandleActionDef(ExprDef * def,
}
free(elemRtrn.str);
free(fieldRtrn.str);
if (!(*handleAction[hndlrType])
(xkb, action, fieldNdx, arrayRtrn, value))
{
if (!(*handleAction[hndlrType])(keymap, action, fieldNdx, arrayRtrn,
value))
return false;
}
}
return true;
}
/***====================================================================***/
int
SetActionField(struct xkb_keymap * xkb,
SetActionField(struct xkb_keymap *keymap,
char *elem,
char *field,
ExprDef * array_ndx, ExprDef * value, ActionInfo ** info_rtrn)

View File

@ -68,11 +68,11 @@ typedef struct _ActionInfo
} ActionInfo;
extern int
HandleActionDef(ExprDef *def, struct xkb_keymap *xkb,
HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
struct xkb_any_action *action, ActionInfo *info);
extern int
SetActionField(struct xkb_keymap *xkb, char *elem, char *field,
SetActionField(struct xkb_keymap *keymap, char *elem, char *field,
ExprDef *index, ExprDef *value, ActionInfo **info_rtrn);
extern const LookupEntry ctrlNames[];

View File

@ -147,7 +147,7 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge, unsigned how_merge)
}
int
ApplyAliases(struct xkb_keymap * xkb, AliasInfo ** info_in)
ApplyAliases(struct xkb_keymap *keymap, AliasInfo ** info_in)
{
int i;
struct xkb_key_alias *old, *a;
@ -157,8 +157,8 @@ ApplyAliases(struct xkb_keymap * xkb, AliasInfo ** info_in)
if (*info_in == NULL)
return true;
nOld = (xkb->names ? xkb->names->num_key_aliases : 0);
old = (xkb->names ? xkb->names->key_aliases : NULL);
nOld = (keymap->names ? keymap->names->num_key_aliases : 0);
old = (keymap->names ? keymap->names->key_aliases : NULL);
for (nNew = 0, info = *info_in; info != NULL;
info = (AliasInfo *) info->def.next)
{
@ -166,7 +166,7 @@ ApplyAliases(struct xkb_keymap * xkb, AliasInfo ** info_in)
xkb_keycode_t kc;
lname = KeyNameToLong(info->real);
if (!FindNamedKey(xkb, lname, &kc, false, CreateKeyNames(xkb), 0))
if (!FindNamedKey(keymap, lname, &kc, false, CreateKeyNames(keymap), 0))
{
if (warningLevel > 4)
{
@ -178,7 +178,7 @@ ApplyAliases(struct xkb_keymap * xkb, AliasInfo ** info_in)
continue;
}
lname = KeyNameToLong(info->alias);
if (FindNamedKey(xkb, lname, &kc, false, false, 0))
if (FindNamedKey(keymap, lname, &kc, false, false, 0))
{
if (warningLevel > 4)
{
@ -214,15 +214,15 @@ ApplyAliases(struct xkb_keymap * xkb, AliasInfo ** info_in)
*info_in = NULL;
return true;
}
status = XkbcAllocNames(xkb, XkbKeyAliasesMask, nOld + nNew);
if (xkb->names)
old = xkb->names->key_aliases;
status = XkbcAllocNames(keymap, XkbKeyAliasesMask, nOld + nNew);
if (keymap->names)
old = keymap->names->key_aliases;
if (status != Success)
{
WSGO("Allocation failure in ApplyAliases\n");
return false;
}
a = xkb->names ? &xkb->names->key_aliases[nOld] : NULL;
a = keymap->names ? &keymap->names->key_aliases[nOld] : NULL;
for (info = *info_in; info != NULL; info = (AliasInfo *) info->def.next)
{
if (info->alias[0] != '\0')

View File

@ -47,6 +47,6 @@ extern bool
MergeAliases(AliasInfo **into, AliasInfo **merge, unsigned how_merge);
extern int
ApplyAliases(struct xkb_keymap *xkb, AliasInfo **info);
ApplyAliases(struct xkb_keymap *keymap, AliasInfo **info);
#endif /* ALIAS_H */

View File

@ -64,7 +64,7 @@ typedef struct _CompatInfo
LEDInfo *leds;
VModInfo vmods;
ActionInfo *act;
struct xkb_keymap * xkb;
struct xkb_keymap *keymap;
} CompatInfo;
/***====================================================================***/
@ -96,11 +96,11 @@ siText(SymInterpInfo * si, CompatInfo * info)
}
static void
InitCompatInfo(CompatInfo * info, struct xkb_keymap * xkb)
InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
{
unsigned int i;
info->xkb = xkb;
info->keymap = keymap;
info->name = NULL;
info->fileID = 0;
info->errorCount = 0;
@ -122,11 +122,11 @@ InitCompatInfo(CompatInfo * info, struct xkb_keymap * xkb)
memset(&info->groupCompat[0], 0,
XkbNumKbdGroups * sizeof(GroupCompatInfo));
info->leds = NULL;
InitVModInfo(&info->vmods, xkb);
InitVModInfo(&info->vmods, keymap);
}
static void
ClearCompatInfo(CompatInfo * info, struct xkb_keymap * xkb)
ClearCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
{
unsigned int i;
ActionInfo *next;
@ -151,7 +151,7 @@ ClearCompatInfo(CompatInfo * info, struct xkb_keymap * xkb)
free(info->act);
info->act = next;
}
ClearVModInfo(&info->vmods, xkb);
ClearVModInfo(&info->vmods, keymap);
}
static SymInterpInfo *
@ -384,12 +384,12 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
}
}
typedef void (*FileHandler) (XkbFile *rtrn, struct xkb_keymap *xkb,
typedef void (*FileHandler) (XkbFile *rtrn, struct xkb_keymap *keymap,
unsigned merge, CompatInfo *info);
static bool
HandleIncludeCompatMap(IncludeStmt * stmt,
struct xkb_keymap * xkb, CompatInfo * info, FileHandler hndlr)
HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
CompatInfo *info, FileHandler hndlr)
{
unsigned newMerge;
XkbFile *rtrn;
@ -403,10 +403,10 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
included = *info;
memset(info, 0, sizeof(CompatInfo));
}
else if (ProcessIncludeFile(xkb->context, stmt, XkmCompatMapIndex, &rtrn,
&newMerge))
else if (ProcessIncludeFile(keymap->context, stmt, XkmCompatMapIndex,
&rtrn, &newMerge))
{
InitCompatInfo(&included, xkb);
InitCompatInfo(&included, keymap);
included.fileID = rtrn->id;
included.dflt = info->dflt;
included.dflt.defs.fileID = rtrn->id;
@ -414,7 +414,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
included.ledDflt.defs.fileID = rtrn->id;
included.ledDflt.defs.merge = newMerge;
included.act = info->act;
(*hndlr) (rtrn, xkb, MergeOverride, &included);
(*hndlr) (rtrn, keymap, MergeOverride, &included);
if (stmt->stmt != NULL)
{
free(included.name);
@ -442,12 +442,12 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
{
haveSelf = true;
MergeIncludedCompatMaps(&included, info, next->merge);
ClearCompatInfo(info, xkb);
ClearCompatInfo(info, keymap);
}
else if (ProcessIncludeFile(xkb->context, next, XkmCompatMapIndex,
&rtrn, &op))
else if (ProcessIncludeFile(keymap->context, next,
XkmCompatMapIndex, &rtrn, &op))
{
InitCompatInfo(&next_incl, xkb);
InitCompatInfo(&next_incl, keymap);
next_incl.fileID = rtrn->id;
next_incl.dflt = info->dflt;
next_incl.dflt.defs.fileID = rtrn->id;
@ -455,11 +455,11 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
next_incl.ledDflt.defs.fileID = rtrn->id;
next_incl.ledDflt.defs.merge = op;
next_incl.act = info->act;
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
(*hndlr) (rtrn, keymap, MergeOverride, &next_incl);
MergeIncludedCompatMaps(&included, &next_incl, op);
if (info->act != NULL)
next_incl.act = NULL;
ClearCompatInfo(&next_incl, xkb);
ClearCompatInfo(&next_incl, keymap);
FreeXKBFile(rtrn);
}
else
@ -474,7 +474,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
else
{
MergeIncludedCompatMaps(info, &included, newMerge);
ClearCompatInfo(&included, xkb);
ClearCompatInfo(&included, keymap);
}
return (info->errorCount == 0);
}
@ -488,10 +488,8 @@ static const LookupEntry useModMapValues[] = {
};
static int
SetInterpField(SymInterpInfo * si,
struct xkb_keymap * xkb,
char *field,
ExprDef * arrayNdx, ExprDef * value, CompatInfo * info)
SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
ExprDef *arrayNdx, ExprDef *value, CompatInfo *info)
{
int ok = 1;
ExprResult tmp;
@ -500,7 +498,7 @@ SetInterpField(SymInterpInfo * si,
{
if (arrayNdx != NULL)
return ReportSINotArray(si, field, info);
ok = HandleActionDef(value, xkb, &si->interp.act.any, info->act);
ok = HandleActionDef(value, keymap, &si->interp.act.any, info->act);
if (ok)
si->defs.defined |= _SI_Action;
}
@ -509,7 +507,7 @@ SetInterpField(SymInterpInfo * si,
{
if (arrayNdx != NULL)
return ReportSINotArray(si, field, info);
ok = ResolveVirtualModifier(value, xkb, &tmp, &info->vmods);
ok = ResolveVirtualModifier(value, keymap, &tmp, &info->vmods);
if (ok)
{
si->interp.virtual_mod = tmp.uval;
@ -575,7 +573,7 @@ SetInterpField(SymInterpInfo * si,
}
static int
HandleInterpVar(VarDef * stmt, struct xkb_keymap * xkb, CompatInfo * info)
HandleInterpVar(VarDef * stmt, struct xkb_keymap *keymap, CompatInfo * info)
{
ExprResult elem, field;
ExprDef *ndx;
@ -584,13 +582,13 @@ HandleInterpVar(VarDef * stmt, struct xkb_keymap * xkb, CompatInfo * info)
if (ExprResolveLhs(stmt->name, &elem, &field, &ndx) == 0)
ret = 0; /* internal error, already reported */
else if (elem.str && (strcasecmp(elem.str, "interpret") == 0))
ret = SetInterpField(&info->dflt, xkb, field.str, ndx, stmt->value,
ret = SetInterpField(&info->dflt, keymap, field.str, ndx, stmt->value,
info);
else if (elem.str && (strcasecmp(elem.str, "indicator") == 0))
ret = SetIndicatorMapField(&info->ledDflt, xkb, field.str, ndx,
ret = SetIndicatorMapField(&info->ledDflt, keymap, field.str, ndx,
stmt->value);
else
ret = SetActionField(xkb, elem.str, field.str, ndx, stmt->value,
ret = SetActionField(keymap, elem.str, field.str, ndx, stmt->value,
&info->act);
free(elem.str);
free(field.str);
@ -598,8 +596,8 @@ HandleInterpVar(VarDef * stmt, struct xkb_keymap * xkb, CompatInfo * info)
}
static int
HandleInterpBody(VarDef * def, struct xkb_keymap * xkb, SymInterpInfo * si,
CompatInfo * info)
HandleInterpBody(VarDef *def, struct xkb_keymap *keymap, SymInterpInfo *si,
CompatInfo *info)
{
int ok = 1;
ExprResult tmp, field;
@ -609,12 +607,12 @@ HandleInterpBody(VarDef * def, struct xkb_keymap * xkb, SymInterpInfo * si,
{
if ((def->name) && (def->name->type == ExprFieldRef))
{
ok = HandleInterpVar(def, xkb, info);
ok = HandleInterpVar(def, keymap, info);
continue;
}
ok = ExprResolveLhs(def->name, &tmp, &field, &arrayNdx);
if (ok) {
ok = SetInterpField(si, xkb, field.str, arrayNdx, def->value,
ok = SetInterpField(si, keymap, field.str, arrayNdx, def->value,
info);
free(field.str);
}
@ -623,8 +621,8 @@ HandleInterpBody(VarDef * def, struct xkb_keymap * xkb, SymInterpInfo * si,
}
static int
HandleInterpDef(InterpDef * def, struct xkb_keymap * xkb, unsigned merge,
CompatInfo * info)
HandleInterpDef(InterpDef *def, struct xkb_keymap *keymap, unsigned merge,
CompatInfo *info)
{
unsigned pred, mods;
SymInterpInfo si;
@ -648,7 +646,7 @@ HandleInterpDef(InterpDef * def, struct xkb_keymap * xkb, unsigned merge,
}
si.interp.match = pred & XkbSI_OpMask;
si.interp.mods = mods;
if (!HandleInterpBody(def->def, xkb, &si, info))
if (!HandleInterpBody(def->def, keymap, &si, info))
{
info->errorCount++;
return false;
@ -663,8 +661,8 @@ HandleInterpDef(InterpDef * def, struct xkb_keymap * xkb, unsigned merge,
}
static int
HandleGroupCompatDef(GroupCompatDef * def,
struct xkb_keymap * xkb, unsigned merge, CompatInfo * info)
HandleGroupCompatDef(GroupCompatDef *def, struct xkb_keymap *keymap,
unsigned merge, CompatInfo *info)
{
ExprResult val;
GroupCompatInfo tmp;
@ -681,7 +679,7 @@ HandleGroupCompatDef(GroupCompatDef * def,
}
tmp.fileID = info->fileID;
tmp.merge = merge;
if (!ExprResolveVModMask(def->def, &val, xkb))
if (!ExprResolveVModMask(def->def, &val, keymap))
{
ERROR("Expected a modifier mask in group compatibility definition\n");
ACTION("Ignoring illegal compatibility map for group %d\n",
@ -695,8 +693,8 @@ HandleGroupCompatDef(GroupCompatDef * def,
}
static void
HandleCompatMapFile(XkbFile * file,
struct xkb_keymap * xkb, unsigned merge, CompatInfo * info)
HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, unsigned merge,
CompatInfo *info)
{
ParseCommon *stmt;
@ -710,23 +708,23 @@ HandleCompatMapFile(XkbFile * file,
switch (stmt->stmtType)
{
case StmtInclude:
if (!HandleIncludeCompatMap((IncludeStmt *) stmt, xkb, info,
if (!HandleIncludeCompatMap((IncludeStmt *) stmt, keymap, info,
HandleCompatMapFile))
info->errorCount++;
break;
case StmtInterpDef:
if (!HandleInterpDef((InterpDef *) stmt, xkb, merge, info))
if (!HandleInterpDef((InterpDef *) stmt, keymap, merge, info))
info->errorCount++;
break;
case StmtGroupCompatDef:
if (!HandleGroupCompatDef
((GroupCompatDef *) stmt, xkb, merge, info))
((GroupCompatDef *) stmt, keymap, merge, info))
info->errorCount++;
break;
case StmtIndicatorMapDef:
{
LEDInfo *rtrn;
rtrn = HandleIndicatorMapDef((IndicatorMapDef *) stmt, xkb,
rtrn = HandleIndicatorMapDef((IndicatorMapDef *) stmt, keymap,
&info->ledDflt, info->leds, merge);
if (rtrn != NULL)
info->leds = rtrn;
@ -735,11 +733,11 @@ HandleCompatMapFile(XkbFile * file,
}
break;
case StmtVarDef:
if (!HandleInterpVar((VarDef *) stmt, xkb, info))
if (!HandleInterpVar((VarDef *) stmt, keymap, info))
info->errorCount++;
break;
case StmtVModDef:
if (!HandleVModDef((VModDef *) stmt, xkb, merge, &info->vmods))
if (!HandleVModDef((VModDef *) stmt, keymap, merge, &info->vmods))
info->errorCount++;
break;
case StmtKeycodeDef:
@ -787,62 +785,62 @@ CopyInterps(CompatInfo * info,
}
bool
CompileCompatMap(XkbFile *file, struct xkb_keymap *xkb, unsigned merge,
CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, unsigned merge,
LEDInfoPtr *unboundLEDs)
{
int i;
CompatInfo info;
GroupCompatInfo *gcm;
InitCompatInfo(&info, xkb);
InitCompatInfo(&info, keymap);
info.dflt.defs.merge = merge;
info.ledDflt.defs.merge = merge;
HandleCompatMapFile(file, xkb, merge, &info);
HandleCompatMapFile(file, keymap, merge, &info);
if (info.errorCount != 0)
goto err_info;
if (XkbcAllocCompatMap(xkb, info.nInterps) != Success) {
if (XkbcAllocCompatMap(keymap, info.nInterps) != Success) {
WSGO("Couldn't allocate compatibility map\n");
goto err_info;
}
if (info.nInterps > 0) {
CopyInterps(&info, xkb->compat, true, XkbSI_Exactly);
CopyInterps(&info, xkb->compat, true, XkbSI_AllOf | XkbSI_NoneOf);
CopyInterps(&info, xkb->compat, true, XkbSI_AnyOf);
CopyInterps(&info, xkb->compat, true, XkbSI_AnyOfOrNone);
CopyInterps(&info, xkb->compat, false, XkbSI_Exactly);
CopyInterps(&info, xkb->compat, false, XkbSI_AllOf | XkbSI_NoneOf);
CopyInterps(&info, xkb->compat, false, XkbSI_AnyOf);
CopyInterps(&info, xkb->compat, false, XkbSI_AnyOfOrNone);
CopyInterps(&info, keymap->compat, true, XkbSI_Exactly);
CopyInterps(&info, keymap->compat, true, XkbSI_AllOf | XkbSI_NoneOf);
CopyInterps(&info, keymap->compat, true, XkbSI_AnyOf);
CopyInterps(&info, keymap->compat, true, XkbSI_AnyOfOrNone);
CopyInterps(&info, keymap->compat, false, XkbSI_Exactly);
CopyInterps(&info, keymap->compat, false, XkbSI_AllOf | XkbSI_NoneOf);
CopyInterps(&info, keymap->compat, false, XkbSI_AnyOf);
CopyInterps(&info, keymap->compat, false, XkbSI_AnyOfOrNone);
}
for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups; i++, gcm++) {
if ((gcm->fileID != 0) || (gcm->real_mods != 0) || (gcm->vmods != 0)) {
xkb->compat->groups[i].mask = gcm->real_mods;
xkb->compat->groups[i].real_mods = gcm->real_mods;
xkb->compat->groups[i].vmods = gcm->vmods;
keymap->compat->groups[i].mask = gcm->real_mods;
keymap->compat->groups[i].real_mods = gcm->real_mods;
keymap->compat->groups[i].vmods = gcm->vmods;
}
}
if (info.leds != NULL) {
if (!CopyIndicatorMapDefs(xkb, info.leds, unboundLEDs))
if (!CopyIndicatorMapDefs(keymap, info.leds, unboundLEDs))
info.errorCount++;
info.leds = NULL;
}
ClearCompatInfo(&info, xkb);
ClearCompatInfo(&info, keymap);
return true;
err_info:
ClearCompatInfo(&info, xkb);
ClearCompatInfo(&info, keymap);
return false;
}
static uint32_t
VModsToReal(struct xkb_keymap *xkb, uint32_t vmodmask)
VModsToReal(struct xkb_keymap *keymap, uint32_t vmodmask)
{
uint32_t ret = 0;
int i;
@ -853,14 +851,15 @@ VModsToReal(struct xkb_keymap *xkb, uint32_t vmodmask)
for (i = 0; i < XkbNumVirtualMods; i++) {
if (!(vmodmask & (1 << i)))
continue;
ret |= xkb->server->vmods[i];
ret |= keymap->server->vmods[i];
}
return ret;
}
static void
UpdateActionMods(struct xkb_keymap *xkb, union xkb_action *act, uint32_t rmodmask)
UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act,
uint32_t rmodmask)
{
switch (act->type) {
case XkbSA_SetMods:
@ -869,13 +868,13 @@ UpdateActionMods(struct xkb_keymap *xkb, union xkb_action *act, uint32_t rmodmas
if (act->mods.flags & XkbSA_UseModMapMods)
act->mods.real_mods = rmodmask;
act->mods.mask = act->mods.real_mods;
act->mods.mask |= VModsToReal(xkb, act->mods.vmods);
act->mods.mask |= VModsToReal(keymap, act->mods.vmods);
break;
case XkbSA_ISOLock:
if (act->iso.flags & XkbSA_UseModMapMods)
act->iso.real_mods = rmodmask;
act->iso.mask = act->iso.real_mods;
act->iso.mask |= VModsToReal(xkb, act->iso.vmods);
act->iso.mask |= VModsToReal(keymap, act->iso.vmods);
break;
default:
break;
@ -888,19 +887,20 @@ UpdateActionMods(struct xkb_keymap *xkb, union xkb_action *act, uint32_t rmodmas
* generic XKB_KEYSYM_NO_SYMBOL match.
*/
static struct xkb_sym_interpret *
FindInterpForKey(struct xkb_keymap *xkb, xkb_keycode_t key, uint32_t group, uint32_t level)
FindInterpForKey(struct xkb_keymap *keymap, xkb_keycode_t key,
uint32_t group, uint32_t level)
{
struct xkb_sym_interpret *ret = NULL;
const xkb_keysym_t *syms;
int num_syms;
int i;
num_syms = xkb_key_get_syms_by_level(xkb, key, group, level, &syms);
num_syms = xkb_key_get_syms_by_level(keymap, key, group, level, &syms);
if (num_syms == 0)
return NULL;
for (i = 0; i < xkb->compat->num_si; i++) {
struct xkb_sym_interpret *interp = &xkb->compat->sym_interpret[i];
for (i = 0; i < keymap->compat->num_si; i++) {
struct xkb_sym_interpret *interp = &keymap->compat->sym_interpret[i];
uint32_t mods;
bool found;
@ -909,7 +909,7 @@ FindInterpForKey(struct xkb_keymap *xkb, xkb_keycode_t key, uint32_t group, uint
continue;
if (level == 0 || !(interp->match & XkbSI_LevelOneOnly))
mods = xkb->map->modmap[key];
mods = keymap->map->modmap[key];
else
mods = 0;
@ -946,7 +946,7 @@ FindInterpForKey(struct xkb_keymap *xkb, xkb_keycode_t key, uint32_t group, uint
/**
*/
static bool
ApplyInterpsToKey(struct xkb_keymap *xkb, xkb_keycode_t key)
ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
{
#define INTERP_SIZE (8 * 4)
struct xkb_sym_interpret *interps[INTERP_SIZE];
@ -954,37 +954,37 @@ ApplyInterpsToKey(struct xkb_keymap *xkb, xkb_keycode_t key)
uint32_t vmodmask = 0;
int num_acts = 0;
int group, level;
int width = XkbKeyGroupsWidth(xkb, key);
int width = XkbKeyGroupsWidth(keymap, key);
int i;
/* If we've been told not to bind interps to this key, then don't. */
if (xkb->server->explicit[key] & XkbExplicitInterpretMask)
if (keymap->server->explicit[key] & XkbExplicitInterpretMask)
return true;
for (i = 0; i < INTERP_SIZE; i++)
interps[i] = NULL;
for (group = 0; group < XkbKeyNumGroups(xkb, key); group++) {
for (level = 0; level < XkbKeyGroupWidth(xkb, key, group); level++) {
for (group = 0; group < XkbKeyNumGroups(keymap, key); group++) {
for (level = 0; level < XkbKeyGroupWidth(keymap, key, group); level++) {
i = (group * width) + level;
if (i >= INTERP_SIZE) /* XXX FIXME */
return false;
interps[i] = FindInterpForKey(xkb, key, group, level);
interps[i] = FindInterpForKey(keymap, key, group, level);
if (interps[i])
num_acts++;
}
}
if (num_acts)
num_acts = XkbKeyNumGroups(xkb, key) * width;
acts = XkbcResizeKeyActions(xkb, key, num_acts);
num_acts = XkbKeyNumGroups(keymap, key) * width;
acts = XkbcResizeKeyActions(keymap, key, num_acts);
if (!num_acts)
return true;
else if (!acts)
return false;
for (group = 0; group < XkbKeyNumGroups(xkb, key); group++) {
for (level = 0; level < XkbKeyGroupWidth(xkb, key, group); level++) {
for (group = 0; group < XkbKeyNumGroups(keymap, key); group++) {
for (level = 0; level < XkbKeyGroupWidth(keymap, key, group); level++) {
struct xkb_sym_interpret *interp;
i = (group * width) + level;
@ -992,12 +992,12 @@ ApplyInterpsToKey(struct xkb_keymap *xkb, xkb_keycode_t key)
/* Infer default key behaviours from the base level. */
if (group == 0 && level == 0) {
if (!(xkb->server->explicit[key] & XkbExplicitAutoRepeatMask) &&
if (!(keymap->server->explicit[key] & XkbExplicitAutoRepeatMask) &&
(!interp || interp->flags & XkbSI_AutoRepeat))
xkb->ctrls->per_key_repeat[key / 8] |= (1 << (key % 8));
if (!(xkb->server->explicit[key] & XkbExplicitBehaviorMask) &&
keymap->ctrls->per_key_repeat[key / 8] |= (1 << (key % 8));
if (!(keymap->server->explicit[key] & XkbExplicitBehaviorMask) &&
interp && (interp->flags & XkbSI_LockingKey))
xkb->server->behaviors[key].type = XkbKB_Lock;
keymap->server->behaviors[key].type = XkbKB_Lock;
}
if (!interp)
@ -1012,8 +1012,8 @@ ApplyInterpsToKey(struct xkb_keymap *xkb, xkb_keycode_t key)
}
}
if (!(xkb->server->explicit[key] & XkbExplicitVModMapMask))
xkb->server->vmodmap[key] = vmodmask;
if (!(keymap->server->explicit[key] & XkbExplicitVModMapMask))
keymap->server->vmodmap[key] = vmodmask;
return true;
#undef INTERP_SIZE
@ -1026,68 +1026,68 @@ ApplyInterpsToKey(struct xkb_keymap *xkb, xkb_keycode_t key)
* other than Shift actually do something ...
*/
bool
UpdateModifiersFromCompat(struct xkb_keymap *xkb)
UpdateModifiersFromCompat(struct xkb_keymap *keymap)
{
xkb_keycode_t key;
int i;
/* Find all the interprets for the key and bind them to actions,
* which will also update the vmodmap. */
for (key = xkb->min_key_code; key <= xkb->max_key_code; key++)
if (!ApplyInterpsToKey(xkb, key))
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++)
if (!ApplyInterpsToKey(keymap, key))
return false;
/* Update xkb->server->vmods, the virtual -> real mod mapping. */
/* Update keymap->server->vmods, the virtual -> real mod mapping. */
for (i = 0; i < XkbNumVirtualMods; i++)
xkb->server->vmods[i] = 0;
for (key = xkb->min_key_code; key <= xkb->max_key_code; key++) {
if (!xkb->server->vmodmap[key])
keymap->server->vmods[i] = 0;
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
if (!keymap->server->vmodmap[key])
continue;
for (i = 0; i < XkbNumVirtualMods; i++) {
if (!(xkb->server->vmodmap[key] & (1 << i)))
if (!(keymap->server->vmodmap[key] & (1 << i)))
continue;
xkb->server->vmods[i] |= xkb->map->modmap[key];
keymap->server->vmods[i] |= keymap->map->modmap[key];
}
}
/* Now update the level masks for all the types to reflect the vmods. */
for (i = 0; i < xkb->map->num_types; i++) {
struct xkb_key_type *type = &xkb->map->types[i];
for (i = 0; i < keymap->map->num_types; i++) {
struct xkb_key_type *type = &keymap->map->types[i];
uint32_t mask = 0;
int j;
type->mods.mask = type->mods.real_mods;
type->mods.mask |= VModsToReal(xkb, type->mods.vmods);
type->mods.mask |= VModsToReal(keymap, type->mods.vmods);
for (j = 0; j < XkbNumVirtualMods; j++) {
if (!(type->mods.vmods & (1 << j)))
continue;
mask |= xkb->server->vmods[j];
mask |= keymap->server->vmods[j];
}
for (j = 0; j < type->map_count; j++) {
struct xkb_mods *mods = &type->map[j].mods;
mods->mask = mods->real_mods | VModsToReal(xkb, mods->vmods);
mods->mask = mods->real_mods | VModsToReal(keymap, mods->vmods);
}
}
/* Update action modifiers. */
for (key = xkb->min_key_code; key <= xkb->max_key_code; key++) {
union xkb_action *acts = XkbKeyActionsPtr(xkb, key);
for (i = 0; i < XkbKeyNumActions(xkb, key); i++) {
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
union xkb_action *acts = XkbKeyActionsPtr(keymap, key);
for (i = 0; i < XkbKeyNumActions(keymap, key); i++) {
if (acts[i].any.type == XkbSA_NoAction)
continue;
UpdateActionMods(xkb, &acts[i], xkb->map->modmap[key]);
UpdateActionMods(keymap, &acts[i], keymap->map->modmap[key]);
}
}
/* Update group modifiers. */
for (i = 0; i < XkbNumKbdGroups; i++) {
struct xkb_mods *group = &xkb->compat->groups[i];
group->mask = group->real_mods | VModsToReal(xkb, group->vmods);
struct xkb_mods *group = &keymap->compat->groups[i];
group->mask = group->real_mods | VModsToReal(keymap, group->vmods);
}
/* Update vmod -> indicator maps. */
for (i = 0; i < XkbNumIndicators; i++) {
struct xkb_mods *led = &xkb->indicators->maps[i].mods;
led->mask = led->real_mods | VModsToReal(xkb, led->vmods);
struct xkb_mods *led = &keymap->indicators->maps[i].mods;
led->mask = led->real_mods | VModsToReal(keymap, led->vmods);
}
return true;

View File

@ -943,31 +943,27 @@ ExprResolveMaskLookup(ExprDef * expr,
}
int
ExprResolveMask(ExprDef * expr,
ExprResult * val_rtrn,
ExprResolveMask(ExprDef *expr, ExprResult *val_rtrn,
const LookupEntry * values)
{
return ExprResolveMaskLookup(expr, val_rtrn, SimpleLookup, values);
}
int
ExprResolveModMask(ExprDef * expr,
ExprResult * val_rtrn)
ExprResolveModMask(ExprDef *expr, ExprResult *val_rtrn)
{
return ExprResolveMaskLookup(expr, val_rtrn, LookupModMask, NULL);
}
int
ExprResolveVModMask(ExprDef * expr,
ExprResult * val_rtrn,
struct xkb_keymap *xkb)
ExprResolveVModMask(ExprDef *expr, ExprResult *val_rtrn,
struct xkb_keymap *keymap)
{
return ExprResolveMaskLookup(expr, val_rtrn, LookupVModMask, xkb);
return ExprResolveMaskLookup(expr, val_rtrn, LookupVModMask, keymap);
}
int
ExprResolveKeySym(ExprDef * expr,
ExprResult * val_rtrn)
ExprResolveKeySym(ExprDef *expr, ExprResult *val_rtrn)
{
int ok = 0;
xkb_keysym_t sym;

View File

@ -68,7 +68,7 @@ ExprResolveModMask(ExprDef *expr, ExprResult *val_rtrn);
extern int
ExprResolveVModMask(ExprDef *expr, ExprResult *val_rtrn,
struct xkb_keymap *xkb);
struct xkb_keymap *keymap);
extern int
ExprResolveBoolean(ExprDef *expr, ExprResult *val_rtrn);

View File

@ -191,9 +191,8 @@ static const LookupEntry groupNames[] = {
};
int
SetIndicatorMapField(LEDInfo * led,
struct xkb_keymap * xkb,
char *field, ExprDef * arrayNdx, ExprDef * value)
SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
char *field, ExprDef *arrayNdx, ExprDef *value)
{
ExprResult rtrn;
bool ok;
@ -204,7 +203,7 @@ SetIndicatorMapField(LEDInfo * led,
{
if (arrayNdx != NULL)
return ReportIndicatorNotArray(led, field);
if (!ExprResolveVModMask(value, &rtrn, xkb))
if (!ExprResolveVModMask(value, &rtrn, keymap))
return ReportIndicatorBadType(led, field, "modifier mask");
led->real_mods = rtrn.uval & 0xff;
led->vmods = (rtrn.uval >> 8) & 0xff;
@ -311,9 +310,8 @@ SetIndicatorMapField(LEDInfo * led,
}
LEDInfo *
HandleIndicatorMapDef(IndicatorMapDef * def,
struct xkb_keymap * xkb,
LEDInfo * dflt, LEDInfo * oldLEDs, unsigned merge)
HandleIndicatorMapDef(IndicatorMapDef *def, struct xkb_keymap *keymap,
LEDInfo *dflt, LEDInfo *oldLEDs, unsigned merge)
{
LEDInfo led, *rtrn;
VarDef *var;
@ -346,7 +344,7 @@ HandleIndicatorMapDef(IndicatorMapDef * def,
}
else
{
ok = SetIndicatorMapField(&led, xkb, field.str, arrayNdx,
ok = SetIndicatorMapField(&led, keymap, field.str, arrayNdx,
var->value) && ok;
}
free(elem.str);
@ -361,17 +359,18 @@ HandleIndicatorMapDef(IndicatorMapDef * def,
}
bool
CopyIndicatorMapDefs(struct xkb_keymap * xkb, LEDInfo *leds, LEDInfo **unboundRtrn)
CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds,
LEDInfo **unboundRtrn)
{
LEDInfo *led, *next;
LEDInfo *unbound, *last;
if (XkbcAllocNames(xkb, XkbIndicatorNamesMask, 0) != Success)
if (XkbcAllocNames(keymap, XkbIndicatorNamesMask, 0) != Success)
{
WSGO("Couldn't allocate names\n");
ACTION("Indicator names may be incorrect\n");
}
if (XkbcAllocIndicatorMaps(xkb) != Success)
if (XkbcAllocIndicatorMaps(keymap) != Success)
{
WSGO("Can't allocate indicator maps\n");
ACTION("Indicator map definitions may be lost\n");
@ -389,7 +388,7 @@ CopyIndicatorMapDefs(struct xkb_keymap * xkb, LEDInfo *leds, LEDInfo **unboundRt
led->which_groups = XkbIM_UseEffective;
if ((led->which_mods == 0) && ((led->real_mods) || (led->vmods)))
led->which_mods = XkbIM_UseEffective;
if ((led->indicator == _LED_NotBound) || (!xkb->indicators))
if ((led->indicator == _LED_NotBound) || (!keymap->indicators))
{
if (unboundRtrn != NULL)
{
@ -406,7 +405,7 @@ CopyIndicatorMapDefs(struct xkb_keymap * xkb, LEDInfo *leds, LEDInfo **unboundRt
else
{
struct xkb_indicator_map * im;
im = &xkb->indicators->maps[led->indicator - 1];
im = &keymap->indicators->maps[led->indicator - 1];
im->flags = led->flags;
im->which_groups = led->which_groups;
im->groups = led->groups;
@ -415,10 +414,11 @@ CopyIndicatorMapDefs(struct xkb_keymap * xkb, LEDInfo *leds, LEDInfo **unboundRt
im->mods.real_mods = led->real_mods;
im->mods.vmods = led->vmods;
im->ctrls = led->ctrls;
if (xkb->names != NULL)
if (keymap->names != NULL)
{
free(UNCONSTIFY(xkb->names->indicators[led->indicator - 1]));
xkb->names->indicators[led->indicator-1] = XkbcAtomGetString(led->name);
free(UNCONSTIFY(keymap->names->indicators[led->indicator - 1]));
keymap->names->indicators[led->indicator-1] =
XkbcAtomGetString(led->name);
}
free(led);
}
@ -431,13 +431,13 @@ CopyIndicatorMapDefs(struct xkb_keymap * xkb, LEDInfo *leds, LEDInfo **unboundRt
}
bool
BindIndicators(struct xkb_keymap * xkb, bool force, LEDInfo *unbound,
BindIndicators(struct xkb_keymap *keymap, bool force, LEDInfo *unbound,
LEDInfo **unboundRtrn)
{
int i;
LEDInfo *led, *next, *last;
if (xkb->names != NULL)
if (keymap->names != NULL)
{
for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next)
{
@ -445,8 +445,8 @@ BindIndicators(struct xkb_keymap * xkb, bool force, LEDInfo *unbound,
{
for (i = 0; i < XkbNumIndicators; i++)
{
if (xkb->names->indicators[i] &&
strcmp(xkb->names->indicators[i],
if (keymap->names->indicators[i] &&
strcmp(keymap->names->indicators[i],
XkbcAtomText(led->name)) == 0)
{
led->indicator = i + 1;
@ -463,9 +463,10 @@ BindIndicators(struct xkb_keymap * xkb, bool force, LEDInfo *unbound,
{
for (i = 0; i < XkbNumIndicators; i++)
{
if (xkb->names->indicators[i] == NULL)
if (keymap->names->indicators[i] == NULL)
{
xkb->names->indicators[i] = XkbcAtomGetString(led->name);
keymap->names->indicators[i] =
XkbcAtomGetString(led->name);
led->indicator = i + 1;
break;
}
@ -503,11 +504,11 @@ BindIndicators(struct xkb_keymap * xkb, bool force, LEDInfo *unbound,
}
else
{
if ((xkb->names != NULL) &&
(strcmp(xkb->names->indicators[led->indicator - 1],
if ((keymap->names != NULL) &&
(strcmp(keymap->names->indicators[led->indicator - 1],
XkbcAtomText(led->name)) != 0))
{
const char *old = xkb->names->indicators[led->indicator - 1];
const char *old = keymap->names->indicators[led->indicator - 1];
ERROR("Multiple names bound to indicator %d\n",
(unsigned int) led->indicator);
ACTION("Using %s, ignoring %s\n", old, XkbcAtomText(led->name));
@ -529,7 +530,7 @@ BindIndicators(struct xkb_keymap * xkb, bool force, LEDInfo *unbound,
else
{
struct xkb_indicator_map * map;
map = &xkb->indicators->maps[led->indicator - 1];
map = &keymap->indicators->maps[led->indicator - 1];
map->flags = led->flags;
map->which_groups = led->which_groups;
map->groups = led->groups;

View File

@ -61,19 +61,19 @@ extern LEDInfo *
AddIndicatorMap(LEDInfo *oldLEDs, LEDInfo *newLED);
extern int
SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *xkb, char *field,
SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap, char *field,
ExprDef *arrayNdx, ExprDef *value);
extern LEDInfo *
HandleIndicatorMapDef(IndicatorMapDef *stmt, struct xkb_keymap *xkb,
HandleIndicatorMapDef(IndicatorMapDef *stmt, struct xkb_keymap *keymap,
LEDInfo *dflt, LEDInfo *oldLEDs, unsigned mergeMode);
extern bool
CopyIndicatorMapDefs(struct xkb_keymap *xkb, LEDInfo *leds,
CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds,
LEDInfo **unboundRtrn);
extern bool
BindIndicators(struct xkb_keymap *xkb, bool force, LEDInfo *unbound,
BindIndicators(struct xkb_keymap *keymap, bool force, LEDInfo *unbound,
LEDInfo **unboundRtrn);
#endif /* INDICATORS_H */

View File

@ -77,10 +77,8 @@ typedef struct _KeyNamesInfo
AliasInfo *aliases;
} KeyNamesInfo;
static void HandleKeycodesFile(XkbFile * file,
struct xkb_keymap * xkb,
unsigned merge,
KeyNamesInfo * info);
static void HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
unsigned merge, KeyNamesInfo *info);
static int
ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
@ -537,11 +535,12 @@ MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
* Handle the given include statement (e.g. "include "evdev+aliases(qwerty)").
*
* @param stmt The include statement from the keymap file.
* @param xkb Unused for all but the xkb->flags.
* @param keymap Unused for all but the keymap->flags.
* @param info Struct to store the key info in.
*/
static bool
HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_keymap * xkb, KeyNamesInfo * info)
HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
KeyNamesInfo *info)
{
unsigned newMerge;
XkbFile *rtrn;
@ -559,16 +558,16 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_keymap * xkb, KeyNamesInfo
}
else if (stmt->file && strcmp(stmt->file, "computed") == 0)
{
xkb->flags |= AutoKeyNames;
keymap->flags |= AutoKeyNames;
info->explicitMin = 0;
info->explicitMax = XKB_KEYCODE_MAX;
return (info->errorCount == 0);
} /* parse file, store returned info in the xkb struct */
else if (ProcessIncludeFile(xkb->context, stmt, XkmKeyNamesIndex, &rtrn,
&newMerge))
else if (ProcessIncludeFile(keymap->context, stmt, XkmKeyNamesIndex,
&rtrn, &newMerge))
{
InitKeyNamesInfo(&included);
HandleKeycodesFile(rtrn, xkb, MergeOverride, &included);
HandleKeycodesFile(rtrn, keymap, MergeOverride, &included);
if (stmt->stmt != NULL)
{
free(included.name);
@ -597,11 +596,11 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_keymap * xkb, KeyNamesInfo
MergeIncludedKeycodes(&included, info, next->merge);
ClearKeyNamesInfo(info);
}
else if (ProcessIncludeFile(xkb->context, next, XkmKeyNamesIndex,
&rtrn, &op))
else if (ProcessIncludeFile(keymap->context, next,
XkmKeyNamesIndex, &rtrn, &op))
{
InitKeyNamesInfo(&next_incl);
HandleKeycodesFile(rtrn, xkb, MergeOverride, &next_incl);
HandleKeycodesFile(rtrn, keymap, MergeOverride, &next_incl);
MergeIncludedKeycodes(&included, &next_incl, op);
ClearKeyNamesInfo(&next_incl);
FreeXKBFile(rtrn);
@ -629,7 +628,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_keymap * xkb, KeyNamesInfo
* e.g. <ESC> = 9
*/
static int
HandleKeycodeDef(KeycodeDef * stmt, unsigned merge, KeyNamesInfo * info)
HandleKeycodeDef(KeycodeDef *stmt, unsigned merge, KeyNamesInfo *info)
{
if ((info->explicitMin != 0 && stmt->value < info->explicitMin) ||
(info->explicitMax != 0 && stmt->value > info->explicitMax))
@ -661,7 +660,7 @@ HandleKeycodeDef(KeycodeDef * stmt, unsigned merge, KeyNamesInfo * info)
* @return 1 on success, 0 otherwise.
*/
static int
HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
HandleKeyNameVar(VarDef *stmt, KeyNamesInfo *info)
{
ExprResult tmp, field;
ExprDef *arrayNdx;
@ -798,8 +797,8 @@ HandleIndicatorNameDef(IndicatorNameDef *def, KeyNamesInfo *info)
* @param info Struct to contain the fully parsed key information.
*/
static void
HandleKeycodesFile(XkbFile * file,
struct xkb_keymap * xkb, unsigned merge, KeyNamesInfo * info)
HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
unsigned merge, KeyNamesInfo *info)
{
ParseCommon *stmt;
@ -811,7 +810,7 @@ HandleKeycodesFile(XkbFile * file,
switch (stmt->stmtType)
{
case StmtInclude: /* e.g. include "evdev+aliases(qwerty)" */
if (!HandleIncludeKeycodes((IncludeStmt *) stmt, xkb, info))
if (!HandleIncludeKeycodes((IncludeStmt *) stmt, keymap, info))
info->errorCount++;
break;
case StmtKeycodeDef: /* e.g. <ESC> = 9; */
@ -819,8 +818,8 @@ HandleKeycodesFile(XkbFile * file,
info->errorCount++;
break;
case StmtKeyAliasDef: /* e.g. alias <MENU> = <COMP>; */
if (!HandleAliasDef((KeyAliasDef *) stmt,
merge, info->fileID, &info->aliases))
if (!HandleAliasDef((KeyAliasDef *) stmt, merge, info->fileID,
&info->aliases))
info->errorCount++;
break;
case StmtVarDef: /* e.g. minimum, maximum */
@ -829,9 +828,7 @@ HandleKeycodesFile(XkbFile * file,
break;
case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */
if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, info))
{
info->errorCount++;
}
break;
case StmtInterpDef:
case StmtVModDef:
@ -870,13 +867,13 @@ HandleKeycodesFile(XkbFile * file,
* @return true on success, false otherwise.
*/
bool
CompileKeycodes(XkbFile *file, struct xkb_keymap *xkb, unsigned merge)
CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge)
{
KeyNamesInfo info; /* contains all the info after parsing */
InitKeyNamesInfo(&info);
HandleKeycodesFile(file, xkb, merge, &info);
HandleKeycodesFile(file, keymap, merge, &info);
/* all the keys are now stored in info */
@ -884,20 +881,20 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *xkb, unsigned merge)
goto err_info;
if (info.explicitMin > 0) /* if "minimum" statement was present */
xkb->min_key_code = info.explicitMin;
keymap->min_key_code = info.explicitMin;
else
xkb->min_key_code = info.computedMin;
keymap->min_key_code = info.computedMin;
if (info.explicitMax > 0) /* if "maximum" statement was present */
xkb->max_key_code = info.explicitMax;
keymap->max_key_code = info.explicitMax;
else
xkb->max_key_code = info.computedMax;
keymap->max_key_code = info.computedMax;
if (XkbcAllocNames(xkb, XkbKeyNamesMask | XkbIndicatorNamesMask, 0)
if (XkbcAllocNames(keymap, XkbKeyNamesMask | XkbIndicatorNamesMask, 0)
== Success) {
uint64_t i;
for (i = info.computedMin; i <= info.computedMax; i++)
LongToKeyName(info.names[i], xkb->names->keys[i].name);
LongToKeyName(info.names[i], keymap->names->keys[i].name);
} else {
WSGO("Cannot create struct xkb_names in CompileKeycodes\n");
goto err_info;
@ -905,18 +902,18 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *xkb, unsigned merge)
if (info.leds) {
IndicatorNameInfo *ii;
if (XkbcAllocIndicatorMaps(xkb) != Success) {
if (XkbcAllocIndicatorMaps(keymap) != Success) {
WSGO("Couldn't allocate IndicatorRec in CompileKeycodes\n");
ACTION("Physical indicators not set\n");
}
for (ii = info.leds; ii; ii = (IndicatorNameInfo *)ii->defs.next) {
free(UNCONSTIFY(xkb->names->indicators[ii->ndx - 1]));
xkb->names->indicators[ii->ndx - 1] = XkbcAtomGetString(ii->name);
free(UNCONSTIFY(keymap->names->indicators[ii->ndx - 1]));
keymap->names->indicators[ii->ndx - 1] = XkbcAtomGetString(ii->name);
}
}
ApplyAliases(xkb, &info.aliases);
ApplyAliases(keymap, &info.aliases);
ClearKeyNamesInfo(&info);
return true;

View File

@ -41,7 +41,7 @@ CompileKeymap(struct xkb_context *context, XkbFile *file)
unsigned mainType;
const char *mainName;
LEDInfo *unbound = NULL, *next;
struct xkb_keymap *xkb = XkbcAllocKeyboard(context);
struct xkb_keymap *keymap = XkbcAllocKeyboard(context);
struct {
XkbFile *keycodes;
XkbFile *types;
@ -49,7 +49,7 @@ CompileKeymap(struct xkb_context *context, XkbFile *file)
XkbFile *symbols;
} sections;
if (!xkb)
if (!keymap)
return NULL;
memset(&sections, 0, sizeof(sections));
@ -149,43 +149,43 @@ CompileKeymap(struct xkb_context *context, XkbFile *file)
/* compile the sections we have in the file one-by-one, or fail. */
if (sections.keycodes == NULL ||
!CompileKeycodes(sections.keycodes, xkb, MergeOverride))
!CompileKeycodes(sections.keycodes, keymap, MergeOverride))
{
ERROR("Failed to compile keycodes\n");
goto err;
}
if (sections.types == NULL ||
!CompileKeyTypes(sections.types, xkb, MergeOverride))
!CompileKeyTypes(sections.types, keymap, MergeOverride))
{
ERROR("Failed to compile key types\n");
goto err;
}
if (sections.compat == NULL ||
!CompileCompatMap(sections.compat, xkb, MergeOverride, &unbound))
!CompileCompatMap(sections.compat, keymap, MergeOverride, &unbound))
{
ERROR("Failed to compile compat map\n");
goto err;
}
if (sections.symbols == NULL ||
!CompileSymbols(sections.symbols, xkb, MergeOverride))
!CompileSymbols(sections.symbols, keymap, MergeOverride))
{
ERROR("Failed to compile symbols\n");
goto err;
}
ok = BindIndicators(xkb, true, unbound, NULL);
ok = BindIndicators(keymap, true, unbound, NULL);
if (!ok)
goto err;
ok = UpdateModifiersFromCompat(xkb);
ok = UpdateModifiersFromCompat(keymap);
if (!ok)
goto err;
return xkb;
return keymap;
err:
ACTION("Failed to compile keymap\n");
xkb_map_unref(xkb);
xkb_map_unref(keymap);
while (unbound) {
next = (LEDInfo *) unbound->defs.next;
free(unbound);

View File

@ -101,7 +101,8 @@ static xkb_atom_t tok_KEYPAD;
/***====================================================================***/
static void
InitKeyTypesInfo(KeyTypesInfo * info, struct xkb_keymap * xkb, KeyTypesInfo * from)
InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap,
KeyTypesInfo *from)
{
tok_ONE_LEVEL = xkb_intern_atom("ONE_LEVEL");
tok_TWO_LEVEL = xkb_intern_atom("TWO_LEVEL");
@ -126,7 +127,7 @@ InitKeyTypesInfo(KeyTypesInfo * info, struct xkb_keymap * xkb, KeyTypesInfo * fr
info->dflt.szNames = 0;
info->dflt.lvlNames = NULL;
info->dflt.preserve = NULL;
InitVModInfo(&info->vmods, xkb);
InitVModInfo(&info->vmods, keymap);
if (from != NULL)
{
info->dflt = from->dflt;
@ -241,7 +242,7 @@ ReportTypeBadWidth(const char *type, int has, int needs)
}
static bool
AddKeyType(struct xkb_keymap * xkb, KeyTypesInfo * info, KeyTypeInfo * new)
AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
{
KeyTypeInfo *old;
@ -326,8 +327,8 @@ AddKeyType(struct xkb_keymap * xkb, KeyTypesInfo * info, KeyTypeInfo * new)
/***====================================================================***/
static void
MergeIncludedKeyTypes(KeyTypesInfo * into,
KeyTypesInfo * from, unsigned merge, struct xkb_keymap * xkb)
MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from,
unsigned merge, struct xkb_keymap *keymap)
{
KeyTypeInfo *type;
@ -345,18 +346,18 @@ MergeIncludedKeyTypes(KeyTypesInfo * into,
{
if (merge != MergeDefault)
type->defs.merge = merge;
if (!AddKeyType(xkb, into, type))
if (!AddKeyType(keymap, into, type))
into->errorCount++;
}
into->stdPresent |= from->stdPresent;
}
typedef void (*FileHandler) (XkbFile *file, struct xkb_keymap *xkb,
typedef void (*FileHandler) (XkbFile *file, struct xkb_keymap *keymap,
unsigned merge, KeyTypesInfo *included);
static bool
HandleIncludeKeyTypes(IncludeStmt * stmt,
struct xkb_keymap * xkb, KeyTypesInfo * info, FileHandler hndlr)
HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
KeyTypesInfo *info, FileHandler hndlr)
{
unsigned newMerge;
XkbFile *rtrn;
@ -370,14 +371,14 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
included = *info;
memset(info, 0, sizeof(KeyTypesInfo));
}
else if (ProcessIncludeFile(xkb->context, stmt, XkmTypesIndex, &rtrn,
else if (ProcessIncludeFile(keymap->context, stmt, XkmTypesIndex, &rtrn,
&newMerge))
{
InitKeyTypesInfo(&included, xkb, info);
InitKeyTypesInfo(&included, keymap, info);
included.fileID = included.dflt.defs.fileID = rtrn->id;
included.dflt.defs.merge = newMerge;
(*hndlr) (rtrn, xkb, newMerge, &included);
(*hndlr) (rtrn, keymap, newMerge, &included);
if (stmt->stmt != NULL)
{
free(included.name);
@ -402,17 +403,17 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
if ((next->file == NULL) && (next->map == NULL))
{
haveSelf = true;
MergeIncludedKeyTypes(&included, info, next->merge, xkb);
MergeIncludedKeyTypes(&included, info, next->merge, keymap);
FreeKeyTypesInfo(info);
}
else if (ProcessIncludeFile(xkb->context, next, XkmTypesIndex,
else if (ProcessIncludeFile(keymap->context, next, XkmTypesIndex,
&rtrn, &op))
{
InitKeyTypesInfo(&next_incl, xkb, &included);
InitKeyTypesInfo(&next_incl, keymap, &included);
next_incl.fileID = next_incl.dflt.defs.fileID = rtrn->id;
next_incl.dflt.defs.merge = op;
(*hndlr) (rtrn, xkb, op, &next_incl);
MergeIncludedKeyTypes(&included, &next_incl, op, xkb);
(*hndlr) (rtrn, keymap, op, &next_incl);
MergeIncludedKeyTypes(&included, &next_incl, op, keymap);
FreeKeyTypesInfo(&next_incl);
FreeXKBFile(rtrn);
}
@ -428,7 +429,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
*info = included;
else
{
MergeIncludedKeyTypes(info, &included, newMerge, xkb);
MergeIncludedKeyTypes(info, &included, newMerge, keymap);
FreeKeyTypesInfo(&included);
}
return (info->errorCount == 0);
@ -504,8 +505,8 @@ NextMapEntry(KeyTypeInfo * type)
}
static bool
AddPreserve(struct xkb_keymap * xkb,
KeyTypeInfo * type, PreserveInfo * new, bool clobber, bool report)
AddPreserve(struct xkb_keymap *keymap, KeyTypeInfo *type,
PreserveInfo *new, bool clobber, bool report)
{
PreserveInfo *old;
@ -524,7 +525,7 @@ AddPreserve(struct xkb_keymap * xkb,
if (warningLevel > 9)
{
WARN("Identical definitions for preserve[%s] in %s\n",
PreserveIndexTxt(xkb, old), TypeTxt(type));
PreserveIndexTxt(keymap, old), TypeTxt(type));
ACTION("Ignored\n");
}
return true;
@ -533,17 +534,17 @@ AddPreserve(struct xkb_keymap * xkb,
{
const char *str;
WARN("Multiple definitions for preserve[%s] in %s\n",
PreserveIndexTxt(xkb, old), TypeTxt(type));
PreserveIndexTxt(keymap, old), TypeTxt(type));
if (clobber)
str = PreserveTxt(xkb, new);
str = PreserveTxt(keymap, new);
else
str = PreserveTxt(xkb, old);
str = PreserveTxt(keymap, old);
ACTION("Using %s, ", str);
if (clobber)
str = PreserveTxt(xkb, old);
str = PreserveTxt(keymap, old);
else
str = PreserveTxt(xkb, new);
str = PreserveTxt(keymap, new);
INFO("ignoring %s\n", str);
}
if (clobber)
@ -557,7 +558,7 @@ AddPreserve(struct xkb_keymap * xkb,
if (!old)
{
WSGO("Couldn't allocate preserve in %s\n", TypeTxt(type));
ACTION("Preserve[%s] lost\n", PreserveIndexTxt(xkb, new));
ACTION("Preserve[%s] lost\n", PreserveIndexTxt(keymap, new));
return false;
}
*old = *new;
@ -576,9 +577,8 @@ AddPreserve(struct xkb_keymap * xkb,
* @param report true if a warning is to be printed on.
*/
static bool
AddMapEntry(struct xkb_keymap * xkb,
KeyTypeInfo * type,
struct xkb_kt_map_entry * new, bool clobber, bool report)
AddMapEntry(struct xkb_keymap *keymap, KeyTypeInfo *type,
struct xkb_kt_map_entry *new, bool clobber, bool report)
{
struct xkb_kt_map_entry * old;
@ -599,13 +599,13 @@ AddMapEntry(struct xkb_keymap * xkb,
ignore = new->level + 1;
}
WARN("Multiple map entries for %s in %s\n",
MapEntryTxt(xkb, new), TypeTxt(type));
MapEntryTxt(keymap, new), TypeTxt(type));
ACTION("Using %d, ignoring %d\n", use, ignore);
}
else if (warningLevel > 9)
{
WARN("Multiple occurences of map[%s]= %d in %s\n",
MapEntryTxt(xkb, new), new->level + 1, TypeTxt(type));
MapEntryTxt(keymap, new), new->level + 1, TypeTxt(type));
ACTION("Ignored\n");
return true;
}
@ -629,15 +629,15 @@ AddMapEntry(struct xkb_keymap * xkb,
}
static bool
SetMapEntry(KeyTypeInfo * type,
struct xkb_keymap * xkb, ExprDef * arrayNdx, ExprDef * value)
SetMapEntry(KeyTypeInfo *type, struct xkb_keymap *keymap, ExprDef *arrayNdx,
ExprDef *value)
{
ExprResult rtrn;
struct xkb_kt_map_entry entry;
if (arrayNdx == NULL)
return ReportTypeShouldBeArray(type, "map entry");
if (!ExprResolveVModMask(arrayNdx, &rtrn, xkb))
if (!ExprResolveVModMask(arrayNdx, &rtrn, keymap))
return ReportTypeBadType(type, "map entry", "modifier mask");
entry.mods.real_mods = rtrn.uval & 0xff; /* modifiers < 512 */
entry.mods.vmods = (rtrn.uval >> 8) & 0xffff; /* modifiers > 512 */
@ -648,10 +648,10 @@ SetMapEntry(KeyTypeInfo * type,
{
WARN("Map entry for unused modifiers in %s\n", TypeTxt(type));
ACTION("Using %s instead of ",
XkbcVModMaskText(xkb,
XkbcVModMaskText(keymap,
entry.mods.real_mods & type->mask,
entry.mods.vmods & type->vmask));
INFO("%s\n", MapEntryTxt(xkb, &entry));
INFO("%s\n", MapEntryTxt(keymap, &entry));
}
entry.mods.real_mods &= type->mask;
entry.mods.vmods &= type->vmask;
@ -663,19 +663,19 @@ SetMapEntry(KeyTypeInfo * type,
return false;
}
entry.level = rtrn.ival - 1;
return AddMapEntry(xkb, type, &entry, true, true);
return AddMapEntry(keymap, type, &entry, true, true);
}
static bool
SetPreserve(KeyTypeInfo * type,
struct xkb_keymap * xkb, ExprDef * arrayNdx, ExprDef * value)
SetPreserve(KeyTypeInfo *type, struct xkb_keymap *keymap,
ExprDef *arrayNdx, ExprDef *value)
{
ExprResult rtrn;
PreserveInfo new;
if (arrayNdx == NULL)
return ReportTypeShouldBeArray(type, "preserve entry");
if (!ExprResolveVModMask(arrayNdx, &rtrn, xkb))
if (!ExprResolveVModMask(arrayNdx, &rtrn, keymap))
return ReportTypeBadType(type, "preserve entry", "modifier mask");
new.defs = type->defs;
new.defs.next = NULL;
@ -687,18 +687,18 @@ SetPreserve(KeyTypeInfo * type,
{
WARN("Preserve for modifiers not used by the %s type\n",
TypeTxt(type));
ACTION("Index %s converted to ", PreserveIndexTxt(xkb, &new));
ACTION("Index %s converted to ", PreserveIndexTxt(keymap, &new));
}
new.indexMods &= type->mask;
new.indexVMods &= type->vmask;
if (warningLevel > 0)
INFO("%s\n", PreserveIndexTxt(xkb, &new));
INFO("%s\n", PreserveIndexTxt(keymap, &new));
}
if (!ExprResolveVModMask(value, &rtrn, xkb))
if (!ExprResolveVModMask(value, &rtrn, keymap))
{
ERROR("Preserve value in a key type is not a modifier mask\n");
ACTION("Ignoring preserve[%s] in type %s\n",
PreserveIndexTxt(xkb, &new), TypeTxt(type));
PreserveIndexTxt(keymap, &new), TypeTxt(type));
return false;
}
new.preMods = rtrn.uval & 0xff;
@ -709,24 +709,23 @@ SetPreserve(KeyTypeInfo * type,
if (warningLevel > 0)
{
WARN("Illegal value for preserve[%s] in type %s\n",
PreserveTxt(xkb, &new), TypeTxt(type));
ACTION("Converted %s to ", PreserveIndexTxt(xkb, &new));
PreserveTxt(keymap, &new), TypeTxt(type));
ACTION("Converted %s to ", PreserveIndexTxt(keymap, &new));
}
new.preMods &= new.indexMods;
new.preVMods &= new.indexVMods;
if (warningLevel > 0)
{
INFO("%s\n", PreserveIndexTxt(xkb, &new));
INFO("%s\n", PreserveIndexTxt(keymap, &new));
}
}
return AddPreserve(xkb, type, &new, true, true);
return AddPreserve(keymap, type, &new, true, true);
}
/***====================================================================***/
static bool
AddLevelName(KeyTypeInfo * type,
unsigned level, xkb_atom_t name, bool clobber)
AddLevelName(KeyTypeInfo *type, unsigned level, xkb_atom_t name, bool clobber)
{
if ((type->lvlNames == NULL) || (type->szNames <= level))
{
@ -807,10 +806,9 @@ SetLevelName(KeyTypeInfo * type, ExprDef * arrayNdx, ExprDef * value)
* @param field The field to parse (e.g. modifiers, map, level_name)
*/
static bool
SetKeyTypeField(KeyTypeInfo * type,
struct xkb_keymap * xkb,
char *field,
ExprDef * arrayNdx, ExprDef * value, KeyTypesInfo * info)
SetKeyTypeField(KeyTypeInfo *type, struct xkb_keymap *keymap,
char *field, ExprDef *arrayNdx, ExprDef *value,
KeyTypesInfo *info)
{
ExprResult tmp;
@ -823,7 +821,7 @@ SetKeyTypeField(KeyTypeInfo * type,
ACTION("Illegal array subscript ignored\n");
}
/* get modifier mask for current type */
if (!ExprResolveVModMask(value, &tmp, xkb))
if (!ExprResolveVModMask(value, &tmp, keymap))
{
ERROR("Key type mask field must be a modifier mask\n");
ACTION("Key type definition ignored\n");
@ -835,8 +833,8 @@ SetKeyTypeField(KeyTypeInfo * type,
{
WARN("Multiple modifier mask definitions for key type %s\n",
XkbcAtomText(type->name));
ACTION("Using %s, ", TypeMaskTxt(type, xkb));
INFO("ignoring %s\n", XkbcVModMaskText(xkb, mods, vmods));
ACTION("Using %s, ", TypeMaskTxt(type, keymap));
INFO("ignoring %s\n", XkbcVModMaskText(keymap, mods, vmods));
return false;
}
type->mask = mods;
@ -847,12 +845,12 @@ SetKeyTypeField(KeyTypeInfo * type,
else if (strcasecmp(field, "map") == 0)
{
type->defs.defined |= _KT_Map;
return SetMapEntry(type, xkb, arrayNdx, value);
return SetMapEntry(type, keymap, arrayNdx, value);
}
else if (strcasecmp(field, "preserve") == 0)
{
type->defs.defined |= _KT_Preserve;
return SetPreserve(type, xkb, arrayNdx, value);
return SetPreserve(type, keymap, arrayNdx, value);
}
else if ((strcasecmp(field, "levelname") == 0) ||
(strcasecmp(field, "level_name") == 0))
@ -866,7 +864,7 @@ SetKeyTypeField(KeyTypeInfo * type,
}
static bool
HandleKeyTypeVar(VarDef * stmt, struct xkb_keymap * xkb, KeyTypesInfo * info)
HandleKeyTypeVar(VarDef *stmt, struct xkb_keymap *keymap, KeyTypesInfo *info)
{
ExprResult elem, field;
ExprDef *arrayNdx;
@ -874,7 +872,7 @@ HandleKeyTypeVar(VarDef * stmt, struct xkb_keymap * xkb, KeyTypesInfo * info)
if (!ExprResolveLhs(stmt->name, &elem, &field, &arrayNdx))
return false; /* internal error, already reported */
if (elem.str && (strcasecmp(elem.str, "type") == 0))
return SetKeyTypeField(&info->dflt, xkb, field.str, arrayNdx,
return SetKeyTypeField(&info->dflt, keymap, field.str, arrayNdx,
stmt->value, info);
if (elem.str != NULL)
{
@ -891,8 +889,8 @@ HandleKeyTypeVar(VarDef * stmt, struct xkb_keymap * xkb, KeyTypesInfo * info)
}
static int
HandleKeyTypeBody(VarDef * def,
struct xkb_keymap * xkb, KeyTypeInfo * type, KeyTypesInfo * info)
HandleKeyTypeBody(VarDef *def, struct xkb_keymap *keymap,
KeyTypeInfo *type, KeyTypesInfo *info)
{
int ok = 1;
ExprResult tmp, field;
@ -902,13 +900,13 @@ HandleKeyTypeBody(VarDef * def,
{
if ((def->name) && (def->name->type == ExprFieldRef))
{
ok = HandleKeyTypeVar(def, xkb, info);
ok = HandleKeyTypeVar(def, keymap, info);
continue;
}
ok = ExprResolveLhs(def->name, &tmp, &field, &arrayNdx);
if (ok) {
ok = SetKeyTypeField(type, xkb, field.str, arrayNdx, def->value,
info);
ok = SetKeyTypeField(type, keymap, field.str, arrayNdx,
def->value, info);
free(field.str);
}
}
@ -920,8 +918,8 @@ HandleKeyTypeBody(VarDef * def,
*
*/
static int
HandleKeyTypeDef(KeyTypeDef * def,
struct xkb_keymap * xkb, unsigned merge, KeyTypesInfo * info)
HandleKeyTypeDef(KeyTypeDef *def, struct xkb_keymap *keymap,
unsigned merge, KeyTypesInfo *info)
{
unsigned int i;
KeyTypeInfo type;
@ -945,7 +943,7 @@ HandleKeyTypeDef(KeyTypeDef * def,
type.preserve = NULL;
/* Parse the actual content. */
if (!HandleKeyTypeBody(def->body, xkb, &type, info))
if (!HandleKeyTypeBody(def->body, keymap, &type, info))
{
info->errorCount++;
return false;
@ -960,7 +958,7 @@ HandleKeyTypeDef(KeyTypeDef * def,
if (((dflt->mods.real_mods & type.mask) == dflt->mods.real_mods) &&
((dflt->mods.vmods & type.vmask) == dflt->mods.vmods))
{
AddMapEntry(xkb, &type, dflt, false, false);
AddMapEntry(keymap, &type, dflt, false, false);
}
}
if (info->dflt.preserve)
@ -971,7 +969,7 @@ HandleKeyTypeDef(KeyTypeDef * def,
if (((dflt->indexMods & type.mask) == dflt->indexMods) &&
((dflt->indexVMods & type.vmask) == dflt->indexVMods))
{
AddPreserve(xkb, &type, dflt, false, false);
AddPreserve(keymap, &type, dflt, false, false);
}
dflt = (PreserveInfo *) dflt->defs.next;
}
@ -984,7 +982,7 @@ HandleKeyTypeDef(KeyTypeDef * def,
}
}
/* Now add the new keytype to the info struct */
if (!AddKeyType(xkb, info, &type))
if (!AddKeyType(keymap, info, &type))
{
info->errorCount++;
return false;
@ -1000,8 +998,8 @@ HandleKeyTypeDef(KeyTypeDef * def,
* @param info Pointer to memory where the outcome will be stored.
*/
static void
HandleKeyTypesFile(XkbFile * file,
struct xkb_keymap * xkb, unsigned merge, KeyTypesInfo * info)
HandleKeyTypesFile(XkbFile *file, struct xkb_keymap *keymap,
unsigned merge, KeyTypesInfo *info)
{
ParseCommon *stmt;
@ -1013,20 +1011,20 @@ HandleKeyTypesFile(XkbFile * file,
switch (stmt->stmtType)
{
case StmtInclude:
if (!HandleIncludeKeyTypes((IncludeStmt *) stmt, xkb, info,
if (!HandleIncludeKeyTypes((IncludeStmt *) stmt, keymap, info,
HandleKeyTypesFile))
info->errorCount++;
break;
case StmtKeyTypeDef: /* e.g. type "ONE_LEVEL" */
if (!HandleKeyTypeDef((KeyTypeDef *) stmt, xkb, merge, info))
if (!HandleKeyTypeDef((KeyTypeDef *) stmt, keymap, merge, info))
info->errorCount++;
break;
case StmtVarDef:
if (!HandleKeyTypeVar((VarDef *) stmt, xkb, info))
if (!HandleKeyTypeVar((VarDef *) stmt, keymap, info))
info->errorCount++;
break;
case StmtVModDef: /* virtual_modifiers NumLock, ... */
if (!HandleVModDef((VModDef *) stmt, xkb, merge, &info->vmods))
if (!HandleVModDef((VModDef *) stmt, keymap, merge, &info->vmods))
info->errorCount++;
break;
case StmtKeyAliasDef:
@ -1062,7 +1060,8 @@ HandleKeyTypesFile(XkbFile * file,
}
static bool
CopyDefToKeyType(struct xkb_keymap * xkb, struct xkb_key_type * type, KeyTypeInfo * def)
CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
KeyTypeInfo *def)
{
unsigned int i;
PreserveInfo *pre;
@ -1075,7 +1074,7 @@ CopyDefToKeyType(struct xkb_keymap * xkb, struct xkb_key_type * type, KeyTypeInf
tmp.mods.real_mods = pre->indexMods;
tmp.mods.vmods = pre->indexVMods;
tmp.level = 0;
AddMapEntry(xkb, def, &tmp, false, false);
AddMapEntry(keymap, def, &tmp, false, false);
match = FindMatchingMapEntry(def, pre->indexMods, pre->indexVMods);
if (!match)
{
@ -1131,21 +1130,21 @@ CopyDefToKeyType(struct xkb_keymap * xkb, struct xkb_key_type * type, KeyTypeInf
def->nEntries = def->szEntries = 0;
def->entries = NULL;
return XkbcComputeEffectiveMap(xkb, type, NULL);
return XkbcComputeEffectiveMap(keymap, type, NULL);
}
bool
CompileKeyTypes(XkbFile *file, struct xkb_keymap * xkb, unsigned merge)
CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge)
{
unsigned int i;
struct xkb_key_type *type, *next;
KeyTypesInfo info;
KeyTypeInfo *def;
InitKeyTypesInfo(&info, xkb, NULL);
InitKeyTypesInfo(&info, keymap, NULL);
info.fileID = file->id;
HandleKeyTypesFile(file, xkb, merge, &info);
HandleKeyTypesFile(file, keymap, merge, &info);
if (info.errorCount != 0)
goto err_info;
@ -1160,54 +1159,54 @@ CompileKeyTypes(XkbFile *file, struct xkb_keymap * xkb, unsigned merge)
if ((info.stdPresent & XkbAlphabeticMask) == 0)
i++;
if (XkbcAllocClientMap(xkb, XkbKeyTypesMask, i) != Success) {
if (XkbcAllocClientMap(keymap, XkbKeyTypesMask, i) != Success) {
WSGO("Couldn't allocate client map\n");
goto err_info;
}
xkb->map->num_types = i;
keymap->map->num_types = i;
if (XkbAllRequiredTypes & (~info.stdPresent)) {
unsigned missing, keypadVMod;
missing = XkbAllRequiredTypes & (~info.stdPresent);
keypadVMod = FindKeypadVMod(xkb);
keypadVMod = FindKeypadVMod(keymap);
if (XkbcInitCanonicalKeyTypes(xkb, missing, keypadVMod) != Success) {
if (XkbcInitCanonicalKeyTypes(keymap, missing, keypadVMod) != Success) {
WSGO("Couldn't initialize canonical key types\n");
goto err_info;
}
if (missing & XkbOneLevelMask)
xkb->map->types[XkbOneLevelIndex].name =
keymap->map->types[XkbOneLevelIndex].name =
XkbcAtomGetString(tok_ONE_LEVEL);
if (missing & XkbTwoLevelMask)
xkb->map->types[XkbTwoLevelIndex].name =
keymap->map->types[XkbTwoLevelIndex].name =
XkbcAtomGetString(tok_TWO_LEVEL);
if (missing & XkbAlphabeticMask)
xkb->map->types[XkbAlphabeticIndex].name =
keymap->map->types[XkbAlphabeticIndex].name =
XkbcAtomGetString(tok_ALPHABETIC);
if (missing & XkbKeypadMask)
xkb->map->types[XkbKeypadIndex].name =
keymap->map->types[XkbKeypadIndex].name =
XkbcAtomGetString(tok_KEYPAD);
}
next = &xkb->map->types[XkbLastRequiredType + 1];
next = &keymap->map->types[XkbLastRequiredType + 1];
for (i = 0, def = info.types; i < info.nTypes; i++) {
if (def->name == tok_ONE_LEVEL)
type = &xkb->map->types[XkbOneLevelIndex];
type = &keymap->map->types[XkbOneLevelIndex];
else if (def->name == tok_TWO_LEVEL)
type = &xkb->map->types[XkbTwoLevelIndex];
type = &keymap->map->types[XkbTwoLevelIndex];
else if (def->name == tok_ALPHABETIC)
type = &xkb->map->types[XkbAlphabeticIndex];
type = &keymap->map->types[XkbAlphabeticIndex];
else if (def->name == tok_KEYPAD)
type = &xkb->map->types[XkbKeypadIndex];
type = &keymap->map->types[XkbKeypadIndex];
else
type = next++;
DeleteLevel1MapEntries(def);
if (!CopyDefToKeyType(xkb, type, def))
if (!CopyDefToKeyType(keymap, type, def))
goto err_info;
def = (KeyTypeInfo *)def->defs.next;

View File

@ -215,39 +215,39 @@ AddCommonInfo(CommonInfo * old, CommonInfo * new)
/**
* Find the key with the given name and return its keycode in kc_rtrn.
*
* @param keymap The keymap to search in.
* @param name The 4-letter name of the key as a long.
* @param kc_rtrn Set to the keycode if the key was found, otherwise 0.
* @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
* xkb->names at the first free keycode.
* keymap->names at the first free keycode.
* @param start_from Keycode to start searching from.
*
* @return true if found, false otherwise.
*/
bool
FindNamedKey(struct xkb_keymap * xkb,
unsigned long name,
xkb_keycode_t *kc_rtrn,
bool use_aliases, bool create, xkb_keycode_t start_from)
FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
xkb_keycode_t *kc_rtrn, bool use_aliases, bool create,
xkb_keycode_t start_from)
{
unsigned n;
if (start_from < xkb->min_key_code)
if (start_from < keymap->min_key_code)
{
start_from = xkb->min_key_code;
start_from = keymap->min_key_code;
}
else if (start_from > xkb->max_key_code)
else if (start_from > keymap->max_key_code)
{
return false;
}
*kc_rtrn = 0; /* some callers rely on this */
if (xkb && xkb->names && xkb->names->keys)
if (keymap && keymap->names && keymap->names->keys)
{
for (n = start_from; n <= xkb->max_key_code; n++)
for (n = start_from; n <= keymap->max_key_code; n++)
{
unsigned long tmp;
tmp = KeyNameToLong(xkb->names->keys[n].name);
tmp = KeyNameToLong(keymap->names->keys[n].name);
if (tmp == name)
{
*kc_rtrn = n;
@ -257,15 +257,16 @@ FindNamedKey(struct xkb_keymap * xkb,
if (use_aliases)
{
unsigned long new_name;
if (FindKeyNameForAlias(xkb, name, &new_name))
return FindNamedKey(xkb, new_name, kc_rtrn, false, create, 0);
if (FindKeyNameForAlias(keymap, name, &new_name))
return FindNamedKey(keymap, new_name, kc_rtrn, false,
create, 0);
}
}
if (create)
{
if ((!xkb->names) || (!xkb->names->keys))
if ((!keymap->names) || (!keymap->names->keys))
{
if (XkbcAllocNames(xkb, XkbKeyNamesMask, 0) != Success)
if (XkbcAllocNames(keymap, XkbKeyNamesMask, 0) != Success)
{
if (warningLevel > 0)
{
@ -277,13 +278,13 @@ FindNamedKey(struct xkb_keymap * xkb,
}
}
/* Find first unused keycode and store our key here */
for (n = xkb->min_key_code; n <= xkb->max_key_code; n++)
for (n = keymap->min_key_code; n <= keymap->max_key_code; n++)
{
if (xkb->names->keys[n].name[0] == '\0')
if (keymap->names->keys[n].name[0] == '\0')
{
char buf[XkbKeyNameLength + 1];
LongToKeyName(name, buf);
memcpy(xkb->names->keys[n].name, buf, XkbKeyNameLength);
memcpy(keymap->names->keys[n].name, buf, XkbKeyNameLength);
*kc_rtrn = n;
return true;
}
@ -293,19 +294,19 @@ FindNamedKey(struct xkb_keymap * xkb,
}
bool
FindKeyNameForAlias(struct xkb_keymap * xkb, unsigned long lname,
FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,
unsigned long *real_name)
{
unsigned int i;
char name[XkbKeyNameLength + 1];
if (xkb && xkb->names && xkb->names->key_aliases)
if (keymap && keymap->names && keymap->names->key_aliases)
{
struct xkb_key_alias * a;
a = xkb->names->key_aliases;
a = keymap->names->key_aliases;
LongToKeyName(lname, name);
name[XkbKeyNameLength] = '\0';
for (i = 0; i < xkb->names->num_key_aliases; i++, a++)
for (i = 0; i < keymap->names->num_key_aliases; i++, a++)
{
if (strncmp(name, a->alias, XkbKeyNameLength) == 0)
{

View File

@ -284,7 +284,7 @@ typedef struct _SymbolsInfo
} SymbolsInfo;
static void
InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap * xkb)
InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap *keymap)
{
int i;
@ -301,7 +301,7 @@ InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap * xkb)
for (i = 0; i < XkbNumKbdGroups; i++)
info->groupNames[i] = XKB_ATOM_NONE;
InitKeyInfo(&info->dflt);
InitVModInfo(&info->vmods, xkb);
InitVModInfo(&info->vmods, keymap);
info->action = NULL;
info->aliases = NULL;
}
@ -708,7 +708,7 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
}
static bool
AddKeySymbols(SymbolsInfo * info, KeyInfo * key, struct xkb_keymap * xkb)
AddKeySymbols(SymbolsInfo *info, KeyInfo *key, struct xkb_keymap *keymap)
{
unsigned int i;
unsigned long real_name;
@ -718,7 +718,7 @@ AddKeySymbols(SymbolsInfo * info, KeyInfo * key, struct xkb_keymap * xkb)
if (info->keys[i].name == key->name)
return MergeKeys(info, &info->keys[i], key);
}
if (FindKeyNameForAlias(xkb, key->name, &real_name))
if (FindKeyNameForAlias(keymap, key->name, &real_name))
{
for (i = 0; i < info->nKeys; i++)
{
@ -819,8 +819,8 @@ AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
/***====================================================================***/
static void
MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
unsigned merge, struct xkb_keymap * xkb)
MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
unsigned merge, struct xkb_keymap *keymap)
{
unsigned int i;
KeyInfo *key;
@ -848,7 +848,7 @@ MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
{
if (merge != MergeDefault)
key->defs.merge = merge;
if (!AddKeySymbols(into, key, xkb))
if (!AddKeySymbols(into, key, keymap))
into->errorCount++;
}
if (from->modMap != NULL)
@ -869,12 +869,12 @@ MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
into->errorCount++;
}
typedef void (*FileHandler) (XkbFile *rtrn, struct xkb_keymap *xkb,
typedef void (*FileHandler) (XkbFile *rtrn, struct xkb_keymap *keymap,
unsigned merge, SymbolsInfo *included);
static bool
HandleIncludeSymbols(IncludeStmt * stmt,
struct xkb_keymap * xkb, SymbolsInfo * info, FileHandler hndlr)
HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap,
SymbolsInfo *info, FileHandler hndlr)
{
unsigned newMerge;
XkbFile *rtrn;
@ -888,10 +888,10 @@ HandleIncludeSymbols(IncludeStmt * stmt,
included = *info;
memset(info, 0, sizeof(SymbolsInfo));
}
else if (ProcessIncludeFile(xkb->context, stmt, XkmSymbolsIndex, &rtrn,
&newMerge))
else if (ProcessIncludeFile(keymap->context, stmt, XkmSymbolsIndex,
&rtrn, &newMerge))
{
InitSymbolsInfo(&included, xkb);
InitSymbolsInfo(&included, keymap);
included.fileID = included.dflt.defs.fileID = rtrn->id;
included.merge = included.dflt.defs.merge = MergeOverride;
if (stmt->modifier)
@ -902,7 +902,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
{
included.explicit_group = info->explicit_group;
}
(*hndlr) (rtrn, xkb, MergeOverride, &included);
(*hndlr) (rtrn, keymap, MergeOverride, &included);
if (stmt->stmt != NULL)
{
free(included.name);
@ -927,13 +927,13 @@ HandleIncludeSymbols(IncludeStmt * stmt,
if ((next->file == NULL) && (next->map == NULL))
{
haveSelf = true;
MergeIncludedSymbols(&included, info, next->merge, xkb);
MergeIncludedSymbols(&included, info, next->merge, keymap);
FreeSymbolsInfo(info);
}
else if (ProcessIncludeFile(xkb->context, next, XkmSymbolsIndex,
&rtrn, &op))
else if (ProcessIncludeFile(keymap->context, next,
XkmSymbolsIndex, &rtrn, &op))
{
InitSymbolsInfo(&next_incl, xkb);
InitSymbolsInfo(&next_incl, keymap);
next_incl.fileID = next_incl.dflt.defs.fileID = rtrn->id;
next_incl.merge = next_incl.dflt.defs.merge = MergeOverride;
if (next->modifier)
@ -944,8 +944,8 @@ HandleIncludeSymbols(IncludeStmt * stmt,
{
next_incl.explicit_group = info->explicit_group;
}
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
MergeIncludedSymbols(&included, &next_incl, op, xkb);
(*hndlr) (rtrn, keymap, MergeOverride, &next_incl);
MergeIncludedSymbols(&included, &next_incl, op, keymap);
FreeSymbolsInfo(&next_incl);
FreeXKBFile(rtrn);
}
@ -965,7 +965,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
*info = included;
else
{
MergeIncludedSymbols(info, &included, newMerge, xkb);
MergeIncludedSymbols(info, &included, newMerge, keymap);
FreeSymbolsInfo(&included);
}
return (info->errorCount == 0);
@ -1020,9 +1020,8 @@ GetGroupIndex(KeyInfo * key,
}
static bool
AddSymbolsToKey(KeyInfo * key,
struct xkb_keymap * xkb,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
AddSymbolsToKey(KeyInfo *key, struct xkb_keymap *keymap,
ExprDef *arrayNdx, ExprDef *value, SymbolsInfo *info)
{
unsigned ndx, nSyms, nLevels;
unsigned int i;
@ -1086,9 +1085,8 @@ AddSymbolsToKey(KeyInfo * key,
}
static bool
AddActionsToKey(KeyInfo * key,
struct xkb_keymap * xkb,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
AddActionsToKey(KeyInfo *key, struct xkb_keymap *keymap, ExprDef *arrayNdx,
ExprDef *value, SymbolsInfo *info)
{
unsigned int i;
unsigned ndx, nActs;
@ -1139,7 +1137,7 @@ AddActionsToKey(KeyInfo * key,
act = value->value.child;
for (i = 0; i < nActs; i++, toAct++)
{
if (!HandleActionDef(act, xkb, toAct, info->action))
if (!HandleActionDef(act, keymap, toAct, info->action))
{
ERROR("Illegal action definition for %s\n",
longText(key->name));
@ -1173,10 +1171,8 @@ static const LookupEntry repeatEntries[] = {
};
static bool
SetSymbolsField(KeyInfo * key,
struct xkb_keymap * xkb,
char *field,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
ExprDef *arrayNdx, ExprDef *value, SymbolsInfo *info)
{
bool ok = true;
ExprResult tmp;
@ -1211,14 +1207,14 @@ SetSymbolsField(KeyInfo * key,
free(tmp.str);
}
else if (strcasecmp(field, "symbols") == 0)
return AddSymbolsToKey(key, xkb, arrayNdx, value, info);
return AddSymbolsToKey(key, keymap, arrayNdx, value, info);
else if (strcasecmp(field, "actions") == 0)
return AddActionsToKey(key, xkb, arrayNdx, value, info);
return AddActionsToKey(key, keymap, arrayNdx, value, info);
else if ((strcasecmp(field, "vmods") == 0) ||
(strcasecmp(field, "virtualmods") == 0) ||
(strcasecmp(field, "virtualmodifiers") == 0))
{
ok = ExprResolveVModMask(value, &tmp, xkb);
ok = ExprResolveVModMask(value, &tmp, keymap);
if (ok)
{
key->vmodmap = (tmp.uval >> 8);
@ -1358,7 +1354,7 @@ SetGroupName(SymbolsInfo * info, ExprDef * arrayNdx, ExprDef * value)
}
static int
HandleSymbolsVar(VarDef * stmt, struct xkb_keymap * xkb, SymbolsInfo * info)
HandleSymbolsVar(VarDef *stmt, struct xkb_keymap *keymap, SymbolsInfo *info)
{
ExprResult elem, field, tmp;
ExprDef *arrayNdx;
@ -1368,7 +1364,7 @@ HandleSymbolsVar(VarDef * stmt, struct xkb_keymap * xkb, SymbolsInfo * info)
return 0; /* internal error, already reported */
if (elem.str && (strcasecmp(elem.str, "key") == 0))
{
ret = SetSymbolsField(&info->dflt, xkb, field.str, arrayNdx,
ret = SetSymbolsField(&info->dflt, keymap, field.str, arrayNdx,
stmt->value, info);
}
else if ((elem.str == NULL) && ((strcasecmp(field.str, "name") == 0) ||
@ -1436,8 +1432,8 @@ HandleSymbolsVar(VarDef * stmt, struct xkb_keymap * xkb, SymbolsInfo * info)
ret = false;
}
else {
ret = SetActionField(xkb, elem.str, field.str, arrayNdx, stmt->value,
&info->action);
ret = SetActionField(keymap, elem.str, field.str, arrayNdx,
stmt->value, &info->action);
}
free(elem.str);
@ -1446,8 +1442,8 @@ HandleSymbolsVar(VarDef * stmt, struct xkb_keymap * xkb, SymbolsInfo * info)
}
static bool
HandleSymbolsBody(VarDef * def,
struct xkb_keymap * xkb, KeyInfo * key, SymbolsInfo * info)
HandleSymbolsBody(VarDef *def, struct xkb_keymap *keymap, KeyInfo *key,
SymbolsInfo *info)
{
bool ok = true;
ExprResult tmp, field;
@ -1457,7 +1453,7 @@ HandleSymbolsBody(VarDef * def,
{
if ((def->name) && (def->name->type == ExprFieldRef))
{
ok = HandleSymbolsVar(def, xkb, info);
ok = HandleSymbolsVar(def, keymap, info);
continue;
}
else
@ -1476,7 +1472,7 @@ HandleSymbolsBody(VarDef * def,
ok = ExprResolveLhs(def->name, &tmp, &field, &arrayNdx);
}
if (ok)
ok = SetSymbolsField(key, xkb, field.str, arrayNdx,
ok = SetSymbolsField(key, keymap, field.str, arrayNdx,
def->value, info);
free(field.str);
}
@ -1485,7 +1481,7 @@ HandleSymbolsBody(VarDef * def,
}
static bool
SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
SetExplicitGroup(SymbolsInfo *info, KeyInfo *key)
{
unsigned group = info->explicit_group;
@ -1529,8 +1525,8 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
}
static int
HandleSymbolsDef(SymbolsDef * stmt,
struct xkb_keymap *xkb, SymbolsInfo *info)
HandleSymbolsDef(SymbolsDef *stmt, struct xkb_keymap *keymap,
SymbolsInfo *info)
{
KeyInfo key;
@ -1538,7 +1534,7 @@ HandleSymbolsDef(SymbolsDef * stmt,
CopyKeyInfo(&info->dflt, &key, false);
key.defs.merge = stmt->merge;
key.name = KeyNameToLong(stmt->keyName);
if (!HandleSymbolsBody((VarDef *) stmt->symbols, xkb, &key, info))
if (!HandleSymbolsBody((VarDef *) stmt->symbols, keymap, &key, info))
{
info->errorCount++;
return false;
@ -1550,7 +1546,7 @@ HandleSymbolsDef(SymbolsDef * stmt,
return false;
}
if (!AddKeySymbols(info, &key, xkb))
if (!AddKeySymbols(info, &key, keymap))
{
info->errorCount++;
return false;
@ -1559,8 +1555,7 @@ HandleSymbolsDef(SymbolsDef * stmt,
}
static bool
HandleModMapDef(ModMapDef * def,
struct xkb_keymap * xkb, SymbolsInfo * info)
HandleModMapDef(ModMapDef *def, struct xkb_keymap *keymap, SymbolsInfo *info)
{
ExprDef *key;
ModMapEntry tmp;
@ -1602,8 +1597,8 @@ HandleModMapDef(ModMapDef * def,
}
static void
HandleSymbolsFile(XkbFile * file,
struct xkb_keymap * xkb, unsigned merge, SymbolsInfo * info)
HandleSymbolsFile(XkbFile *file, struct xkb_keymap *keymap,
unsigned merge, SymbolsInfo *info)
{
ParseCommon *stmt;
@ -1615,20 +1610,20 @@ HandleSymbolsFile(XkbFile * file,
switch (stmt->stmtType)
{
case StmtInclude:
if (!HandleIncludeSymbols((IncludeStmt *) stmt, xkb, info,
if (!HandleIncludeSymbols((IncludeStmt *) stmt, keymap, info,
HandleSymbolsFile))
info->errorCount++;
break;
case StmtSymbolsDef:
if (!HandleSymbolsDef((SymbolsDef *) stmt, xkb, info))
if (!HandleSymbolsDef((SymbolsDef *) stmt, keymap, info))
info->errorCount++;
break;
case StmtVarDef:
if (!HandleSymbolsVar((VarDef *) stmt, xkb, info))
if (!HandleSymbolsVar((VarDef *) stmt, keymap, info))
info->errorCount++;
break;
case StmtVModDef:
if (!HandleVModDef((VModDef *) stmt, xkb, merge, &info->vmods))
if (!HandleVModDef((VModDef *) stmt, keymap, merge, &info->vmods))
info->errorCount++;
break;
case StmtInterpDef:
@ -1642,7 +1637,7 @@ HandleSymbolsFile(XkbFile * file,
info->errorCount++;
break;
case StmtModMapDef:
if (!HandleModMapDef((ModMapDef *) stmt, xkb, info))
if (!HandleModMapDef((ModMapDef *) stmt, keymap, info))
info->errorCount++;
break;
default:
@ -1663,19 +1658,21 @@ HandleSymbolsFile(XkbFile * file,
}
static bool
FindKeyForSymbol(struct xkb_keymap * xkb, xkb_keysym_t sym, xkb_keycode_t *kc_rtrn)
FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym,
xkb_keycode_t *kc_rtrn)
{
xkb_keycode_t key;
unsigned int group, level;
for (key = xkb->min_key_code; key <= xkb->max_key_code; key++)
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++)
{
for (group = 0; group < XkbKeyNumGroups(xkb, key); group++)
for (group = 0; group < XkbKeyNumGroups(keymap, key); group++)
{
for (level = 0; level < XkbKeyGroupWidth(xkb, key, group); level++)
for (level = 0; level < XkbKeyGroupWidth(keymap, key, group);
level++)
{
if (XkbKeyNumSyms(xkb, key, group, level) != 1 ||
(XkbKeySymEntry(xkb, key, group, level))[0] != sym)
if (XkbKeyNumSyms(keymap, key, group, level) != 1 ||
(XkbKeySymEntry(keymap, key, group, level))[0] != sym)
continue;
*kc_rtrn = key;
return true;
@ -1695,16 +1692,16 @@ FindKeyForSymbol(struct xkb_keymap * xkb, xkb_keysym_t sym, xkb_keycode_t *kc_rt
* @return true if found, false otherwise.
*/
static bool
FindNamedType(struct xkb_keymap * xkb, xkb_atom_t atom, unsigned *type_rtrn)
FindNamedType(struct xkb_keymap *keymap, xkb_atom_t atom, unsigned *type_rtrn)
{
unsigned n;
const char *name = XkbcAtomText(atom);
if (xkb && xkb->map && xkb->map->types)
if (keymap && keymap->map && keymap->map->types)
{
for (n = 0; n < xkb->map->num_types; n++)
for (n = 0; n < keymap->map->num_types; n++)
{
if (strcmp(xkb->map->types[n].name, name) == 0)
if (strcmp(keymap->map->types[n].name, name) == 0)
{
*type_rtrn = n;
return true;
@ -1931,7 +1928,7 @@ PrepareKeyDef(KeyInfo * key)
* This function recurses.
*/
static bool
CopySymbolsDef(struct xkb_keymap * xkb, KeyInfo *key, int start_from)
CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
{
unsigned int i;
xkb_keycode_t kc;
@ -1946,8 +1943,8 @@ CopySymbolsDef(struct xkb_keymap * xkb, KeyInfo *key, int start_from)
useAlias = (start_from == 0);
/* get the keycode for the key. */
if (!FindNamedKey(xkb, key->name, &kc, useAlias, CreateKeyNames(xkb),
start_from))
if (!FindNamedKey(keymap, key->name, &kc, useAlias,
CreateKeyNames(keymap), start_from))
{
if ((start_from == 0) && (warningLevel >= 5))
{
@ -1988,10 +1985,10 @@ CopySymbolsDef(struct xkb_keymap * xkb, KeyInfo *key, int start_from)
}
}
}
if (FindNamedType(xkb, key->types[i], &types[i]))
if (FindNamedType(keymap, key->types[i], &types[i]))
{
if (!autoType || key->numLevels[i] > 2)
xkb->server->explicit[kc] |= (1 << i);
keymap->server->explicit[kc] |= (1 << i);
}
else
{
@ -2005,7 +2002,7 @@ CopySymbolsDef(struct xkb_keymap * xkb, KeyInfo *key, int start_from)
types[i] = XkbTwoLevelIndex;
}
/* if the type specifies fewer levels than the key has, shrink the key */
type = &xkb->map->types[types[i]];
type = &keymap->map->types[types[i]];
if (type->num_levels < key->numLevels[i])
{
if (warningLevel > 0)
@ -2024,7 +2021,7 @@ CopySymbolsDef(struct xkb_keymap * xkb, KeyInfo *key, int start_from)
sizeSyms += key->sizeSyms[i];
}
if (!XkbcResizeKeySyms(xkb, kc, sizeSyms))
if (!XkbcResizeKeySyms(keymap, kc, sizeSyms))
{
WSGO("Could not enlarge symbols for %s (keycode %d)\n",
longText(key->name), kc);
@ -2032,26 +2029,27 @@ CopySymbolsDef(struct xkb_keymap * xkb, KeyInfo *key, int start_from)
}
if (haveActions)
{
outActs = XkbcResizeKeyActions(xkb, kc, width * nGroups);
outActs = XkbcResizeKeyActions(keymap, kc, width * nGroups);
if (outActs == NULL)
{
WSGO("Could not enlarge actions for %s (key %d)\n",
longText(key->name), kc);
return false;
}
xkb->server->explicit[kc] |= XkbExplicitInterpretMask;
keymap->server->explicit[kc] |= XkbExplicitInterpretMask;
}
else
outActs = NULL;
if (key->defs.defined & _Key_GroupInfo)
i = key->groupInfo;
else
i = xkb->map->key_sym_map[kc].group_info;
i = keymap->map->key_sym_map[kc].group_info;
xkb->map->key_sym_map[kc].group_info = XkbSetNumGroups(i, nGroups);
xkb->map->key_sym_map[kc].width = width;
xkb->map->key_sym_map[kc].sym_index = uTypedCalloc(nGroups * width, int);
xkb->map->key_sym_map[kc].num_syms = uTypedCalloc(nGroups * width,
keymap->map->key_sym_map[kc].group_info = XkbSetNumGroups(i, nGroups);
keymap->map->key_sym_map[kc].width = width;
keymap->map->key_sym_map[kc].sym_index = uTypedCalloc(nGroups * width,
int);
keymap->map->key_sym_map[kc].num_syms = uTypedCalloc(nGroups * width,
unsigned int);
for (i = 0; i < nGroups; i++)
{
@ -2063,7 +2061,7 @@ CopySymbolsDef(struct xkb_keymap * xkb, KeyInfo *key, int start_from)
* FIXME: There should be a better fix for this.
*/
if (key->numLevels[i])
xkb->map->key_sym_map[kc].kt_index[i] = types[i];
keymap->map->key_sym_map[kc].kt_index[i] = types[i];
if (key->sizeSyms[i] != 0)
{
/* fill key to "width" symbols*/
@ -2071,21 +2069,21 @@ CopySymbolsDef(struct xkb_keymap * xkb, KeyInfo *key, int start_from)
{
if (tmp < key->numLevels[i] && key->symsMapNumEntries[i][tmp])
{
memcpy(&xkb->map->key_sym_map[kc].syms[symIndex],
memcpy(&keymap->map->key_sym_map[kc].syms[symIndex],
&key->syms[i][key->symsMapIndex[i][tmp]],
key->symsMapNumEntries[i][tmp] *
sizeof(xkb_keysym_t));
xkb->map->key_sym_map[kc].sym_index[(i * width) + tmp] =
keymap->map->key_sym_map[kc].sym_index[(i * width) + tmp] =
symIndex;
xkb->map->key_sym_map[kc].num_syms[(i * width) + tmp] =
keymap->map->key_sym_map[kc].num_syms[(i * width) + tmp] =
key->symsMapNumEntries[i][tmp];
symIndex +=
xkb->map->key_sym_map[kc].num_syms[(i * width) + tmp];
keymap->map->key_sym_map[kc].num_syms[(i * width) + tmp];
}
else
{
xkb->map->key_sym_map[kc].sym_index[(i * width) + tmp] = -1;
xkb->map->key_sym_map[kc].num_syms[(i * width) + tmp] = 0;
keymap->map->key_sym_map[kc].sym_index[(i * width) + tmp] = -1;
keymap->map->key_sym_map[kc].num_syms[(i * width) + tmp] = 0;
}
if ((outActs != NULL) && (key->acts[i] != NULL))
{
@ -2102,41 +2100,40 @@ CopySymbolsDef(struct xkb_keymap * xkb, KeyInfo *key, int start_from)
case XkbKB_Default:
break;
default:
xkb->server->behaviors[kc] = key->behavior;
xkb->server->explicit[kc] |= XkbExplicitBehaviorMask;
keymap->server->behaviors[kc] = key->behavior;
keymap->server->explicit[kc] |= XkbExplicitBehaviorMask;
break;
}
if (key->defs.defined & _Key_VModMap)
{
xkb->server->vmodmap[kc] = key->vmodmap;
xkb->server->explicit[kc] |= XkbExplicitVModMapMask;
keymap->server->vmodmap[kc] = key->vmodmap;
keymap->server->explicit[kc] |= XkbExplicitVModMapMask;
}
if (key->repeat != RepeatUndefined)
{
if (key->repeat == RepeatYes)
xkb->ctrls->per_key_repeat[kc / 8] |= (1 << (kc % 8));
keymap->ctrls->per_key_repeat[kc / 8] |= (1 << (kc % 8));
else
xkb->ctrls->per_key_repeat[kc / 8] &= ~(1 << (kc % 8));
xkb->server->explicit[kc] |= XkbExplicitAutoRepeatMask;
keymap->ctrls->per_key_repeat[kc / 8] &= ~(1 << (kc % 8));
keymap->server->explicit[kc] |= XkbExplicitAutoRepeatMask;
}
if (nGroups > xkb->ctrls->num_groups)
xkb->ctrls->num_groups = nGroups;
if (nGroups > keymap->ctrls->num_groups)
keymap->ctrls->num_groups = nGroups;
/* do the same thing for the next key */
CopySymbolsDef(xkb, key, kc + 1);
CopySymbolsDef(keymap, key, kc + 1);
return true;
}
static bool
CopyModMapDef(struct xkb_keymap * xkb, ModMapEntry *entry)
CopyModMapDef(struct xkb_keymap *keymap, ModMapEntry *entry)
{
xkb_keycode_t kc;
if ((!entry->haveSymbol)
&&
(!FindNamedKey
(xkb, entry->u.keyName, &kc, true, CreateKeyNames(xkb), 0)))
if (!entry->haveSymbol &&
!FindNamedKey(keymap, entry->u.keyName, &kc, true,
CreateKeyNames(keymap), 0))
{
if (warningLevel >= 5)
{
@ -2147,8 +2144,8 @@ CopyModMapDef(struct xkb_keymap * xkb, ModMapEntry *entry)
}
return false;
}
else if (entry->haveSymbol
&& (!FindKeyForSymbol(xkb, entry->u.keySym, &kc)))
else if (entry->haveSymbol &&
!FindKeyForSymbol(keymap, entry->u.keySym, &kc))
{
if (warningLevel > 5)
{
@ -2159,7 +2156,7 @@ CopyModMapDef(struct xkb_keymap * xkb, ModMapEntry *entry)
}
return false;
}
xkb->map->modmap[kc] |= (1 << entry->modifier);
keymap->map->modmap[kc] |= (1 << entry->modifier);
return true;
}
@ -2167,21 +2164,21 @@ CopyModMapDef(struct xkb_keymap * xkb, ModMapEntry *entry)
* Handle the xkb_symbols section of an xkb file.
*
* @param file The parsed xkb_symbols section of the xkb file.
* @param xkb Handle to the keyboard description to store the symbols in.
* @param keymap Handle to the keyboard description to store the symbols in.
* @param merge Merge strategy (e.g. MergeOverride).
*/
bool
CompileSymbols(XkbFile *file, struct xkb_keymap *xkb, unsigned merge)
CompileSymbols(XkbFile *file, struct xkb_keymap *keymap, unsigned merge)
{
unsigned int i;
SymbolsInfo info;
KeyInfo *key;
InitSymbolsInfo(&info, xkb);
InitSymbolsInfo(&info, keymap);
info.dflt.defs.fileID = file->id;
info.dflt.defs.merge = merge;
HandleSymbolsFile(file, xkb, merge, &info);
HandleSymbolsFile(file, keymap, merge, &info);
if (info.nKeys == 0)
goto err_info;
@ -2190,38 +2187,38 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *xkb, unsigned merge)
goto err_info;
/* alloc memory in the xkb struct */
if (XkbcAllocNames(xkb, XkbGroupNamesMask, 0) != Success) {
if (XkbcAllocNames(keymap, XkbGroupNamesMask, 0) != Success) {
WSGO("Can not allocate names in CompileSymbols\n");
ACTION("Symbols not added\n");
goto err_info;
}
if (XkbcAllocClientMap(xkb, XkbKeySymsMask | XkbModifierMapMask, 0)
if (XkbcAllocClientMap(keymap, XkbKeySymsMask | XkbModifierMapMask, 0)
!= Success) {
WSGO("Could not allocate client map in CompileSymbols\n");
ACTION("Symbols not added\n");
goto err_info;
}
if (XkbcAllocServerMap(xkb, XkbAllServerInfoMask, 32) != Success) {
if (XkbcAllocServerMap(keymap, XkbAllServerInfoMask, 32) != Success) {
WSGO("Could not allocate server map in CompileSymbols\n");
ACTION("Symbols not added\n");
goto err_info;
}
if (XkbcAllocControls(xkb) != Success) {
if (XkbcAllocControls(keymap) != Success) {
WSGO("Could not allocate controls in CompileSymbols\n");
ACTION("Symbols not added\n");
goto err_info;
}
/* now copy info into xkb. */
ApplyAliases(xkb, &info.aliases);
ApplyAliases(keymap, &info.aliases);
for (i = 0; i < XkbNumKbdGroups; i++) {
if (info.groupNames[i] != XKB_ATOM_NONE) {
free(UNCONSTIFY(xkb->names->groups[i]));
xkb->names->groups[i] = XkbcAtomGetString(info.groupNames[i]);
free(UNCONSTIFY(keymap->names->groups[i]));
keymap->names->groups[i] = XkbcAtomGetString(info.groupNames[i]);
}
}
@ -2231,17 +2228,17 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *xkb, unsigned merge)
/* copy! */
for (key = info.keys, i = 0; i < info.nKeys; i++, key++)
if (!CopySymbolsDef(xkb, key, 0))
if (!CopySymbolsDef(keymap, key, 0))
info.errorCount++;
if (warningLevel > 3) {
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
if (xkb->names->keys[i].name[0] == '\0')
for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) {
if (keymap->names->keys[i].name[0] == '\0')
continue;
if (XkbKeyNumGroups(xkb, i) < 1) {
if (XkbKeyNumGroups(keymap, i) < 1) {
char buf[5];
memcpy(buf, xkb->names->keys[i].name, 4);
memcpy(buf, keymap->names->keys[i].name, 4);
buf[4] = '\0';
WARN("No symbols defined for <%s> (keycode %d)\n", buf, i);
}
@ -2251,9 +2248,9 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *xkb, unsigned merge)
if (info.modMap) {
ModMapEntry *mm, *next;
for (mm = info.modMap; mm != NULL; mm = next) {
if (!CopyModMapDef(xkb, mm))
if (!CopyModMapDef(keymap, mm))
info.errorCount++;
next = (ModMapEntry *)mm->defs.next;
next = (ModMapEntry *) mm->defs.next;
}
}

View File

@ -27,32 +27,32 @@
#include "vmod.h"
void
InitVModInfo(VModInfo * info, struct xkb_keymap * xkb)
InitVModInfo(VModInfo *info, struct xkb_keymap *keymap)
{
ClearVModInfo(info, xkb);
ClearVModInfo(info, keymap);
info->errorCount = 0;
}
void
ClearVModInfo(VModInfo * info, struct xkb_keymap * xkb)
ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
{
int i;
info->newlyDefined = info->defined = info->available = 0;
if (XkbcAllocNames(xkb, 0, 0) != Success)
if (XkbcAllocNames(keymap, 0, 0) != Success)
return;
if (XkbcAllocServerMap(xkb, 0, 0) != Success)
if (XkbcAllocServerMap(keymap, 0, 0) != Success)
return;
info->xkb = xkb;
if (xkb && xkb->names)
info->keymap = keymap;
if (keymap && keymap->names)
{
int bit;
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
{
if (xkb->names->vmods[i] != NULL)
if (keymap->names->vmods[i] != NULL)
info->defined |= bit;
}
}
@ -69,16 +69,14 @@ ClearVModInfo(VModInfo * info, struct xkb_keymap * xkb)
* @param mergeMode Merge strategy (e.g. MergeOverride)
*/
bool
HandleVModDef(VModDef * stmt, struct xkb_keymap *xkb, unsigned mergeMode,
VModInfo * info)
HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, unsigned mergeMode,
VModInfo *info)
{
int i, bit, nextFree;
ExprResult mod;
struct xkb_server_map * srv;
struct xkb_names * names;
struct xkb_server_map *srv = keymap->server;
struct xkb_names *names = keymap->names;
srv = xkb->server;
names = xkb->names;
for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<= 1)
{
if (info->defined & bit)
@ -144,7 +142,7 @@ HandleVModDef(VModDef * stmt, struct xkb_keymap *xkb, unsigned mergeMode,
/**
* Returns the index of the given modifier in the xkb->names->vmods array.
*
* @param priv Pointer to the xkb data structure.
* @param keymap Pointer to the xkb data structure.
* @param field The Atom of the modifier's name (e.g. Atom for LAlt)
* @param type Must be TypeInt, otherwise return false.
* @param val_rtrn Set to the index of the modifier that matches.
@ -153,13 +151,13 @@ HandleVModDef(VModDef * stmt, struct xkb_keymap *xkb, unsigned mergeMode,
* undefined.
*/
static int
LookupVModIndex(const struct xkb_keymap *xkb, xkb_atom_t field, unsigned type,
ExprResult * val_rtrn)
LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
unsigned type, ExprResult * val_rtrn)
{
int i;
const char *name = XkbcAtomText(field);
if ((xkb == NULL) || (xkb->names == NULL) || (type != TypeInt))
if ((keymap == NULL) || (keymap->names == NULL) || (type != TypeInt))
{
return false;
}
@ -170,7 +168,8 @@ LookupVModIndex(const struct xkb_keymap *xkb, xkb_atom_t field, unsigned type,
*/
for (i = 0; i < XkbNumVirtualMods; i++)
{
if (xkb->names->vmods[i] && strcmp(xkb->names->vmods[i], name) == 0)
if (keymap->names->vmods[i] &&
strcmp(keymap->names->vmods[i], name) == 0)
{
val_rtrn->uval = i;
return true;
@ -207,13 +206,13 @@ LookupVModMask(const void * priv, xkb_atom_t field, unsigned type,
}
int
FindKeypadVMod(struct xkb_keymap * xkb)
FindKeypadVMod(struct xkb_keymap *keymap)
{
xkb_atom_t name;
ExprResult rtrn;
name = xkb_intern_atom("NumLock");
if ((xkb) && LookupVModIndex(xkb, name, TypeInt, &rtrn))
if (keymap && LookupVModIndex(keymap, name, TypeInt, &rtrn))
{
return rtrn.ival;
}
@ -221,12 +220,11 @@ FindKeypadVMod(struct xkb_keymap * xkb)
}
bool
ResolveVirtualModifier(ExprDef * def, struct xkb_keymap *xkb,
ExprResult * val_rtrn, VModInfo * info)
ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
ExprResult *val_rtrn, VModInfo *info)
{
struct xkb_names * names;
struct xkb_names *names = keymap->names;
names = xkb->names;
if (def->op == ExprIdent)
{
int i, bit;

View File

@ -32,7 +32,7 @@
typedef struct _VModInfo
{
struct xkb_keymap *xkb;
struct xkb_keymap *keymap;
unsigned defined;
unsigned available;
unsigned newlyDefined;
@ -40,23 +40,23 @@ typedef struct _VModInfo
} VModInfo;
extern void
InitVModInfo(VModInfo *info, struct xkb_keymap *xkb);
InitVModInfo(VModInfo *info, struct xkb_keymap *keymap);
extern void
ClearVModInfo(VModInfo *info, struct xkb_keymap *xkb);
ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap);
extern bool
HandleVModDef(VModDef *stmt, struct xkb_keymap *xkb, unsigned mergeMode,
HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, unsigned mergeMode,
VModInfo *info);
extern bool
ApplyVModDefs(VModInfo *info, struct xkb_keymap *xkb);
ApplyVModDefs(VModInfo *info, struct xkb_keymap *keymap);
extern int
FindKeypadVMod(struct xkb_keymap *xkb);
FindKeypadVMod(struct xkb_keymap *keymap);
extern bool
ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *xkb,
ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
ExprResult *value_rtrn, VModInfo *info);
#endif /* VMOD_H */

View File

@ -69,15 +69,16 @@ ProcessIncludeFile(struct xkb_context *context,
unsigned *merge_rtrn);
extern bool
FindNamedKey(struct xkb_keymap *xkb, unsigned long name, xkb_keycode_t *kc_rtrn,
bool use_aliases, bool create, xkb_keycode_t start_from);
FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
xkb_keycode_t *kc_rtrn, bool use_aliases, bool create,
xkb_keycode_t start_from);
extern bool
FindKeyNameForAlias(struct xkb_keymap *xkb, unsigned long lname,
FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,
unsigned long *real_name);
extern bool
UpdateModifiersFromCompat(struct xkb_keymap *xkb);
UpdateModifiersFromCompat(struct xkb_keymap *keymap);
extern const char *
XkbDirectoryForInclude(unsigned type);

View File

@ -121,7 +121,7 @@ xkb_map_new_from_names(struct xkb_context *context,
{
XkbRF_VarDefsRec defs;
struct xkb_component_names *names;
struct xkb_keymap *xkb;
struct xkb_keymap *keymap;
if (!rmlvo || ISEMPTY(rmlvo->rules) || ISEMPTY(rmlvo->layout)) {
ERROR("rules and layout required to generate XKB keymap\n");
@ -140,7 +140,7 @@ xkb_map_new_from_names(struct xkb_context *context,
return NULL;
}
xkb = xkb_map_new_from_kccgst(context, names, 0);
keymap = xkb_map_new_from_kccgst(context, names, 0);
free(names->keymap);
free(names->keycodes);
@ -149,7 +149,7 @@ xkb_map_new_from_names(struct xkb_context *context,
free(names->symbols);
free(names);
return xkb;
return keymap;
}
static XkbFile *
@ -190,7 +190,7 @@ static struct xkb_keymap *
compile_keymap(struct xkb_context *context, XkbFile *file)
{
XkbFile *mapToUse;
struct xkb_keymap * xkb = NULL;
struct xkb_keymap *keymap = NULL;
/* Find map to use */
mapToUse = XkbChooseMap(file, NULL);
@ -207,14 +207,14 @@ compile_keymap(struct xkb_context *context, XkbFile *file)
goto err;
}
xkb = CompileKeymap(context, mapToUse);
if (!xkb)
keymap = CompileKeymap(context, mapToUse);
if (!keymap)
goto err;
err:
FreeXKBFile(file);
XkbcFreeAllAtoms();
return xkb;
return keymap;
}
_X_EXPORT struct xkb_keymap *
@ -317,17 +317,17 @@ xkb_map_new_from_fd(struct xkb_context *context,
}
_X_EXPORT struct xkb_keymap *
xkb_map_ref(struct xkb_keymap *xkb)
xkb_map_ref(struct xkb_keymap *keymap)
{
xkb->refcnt++;
return xkb;
keymap->refcnt++;
return keymap;
}
_X_EXPORT void
xkb_map_unref(struct xkb_keymap *xkb)
xkb_map_unref(struct xkb_keymap *keymap)
{
if (--xkb->refcnt > 0)
if (--keymap->refcnt > 0)
return;
XkbcFreeKeyboard(xkb);
XkbcFreeKeyboard(keymap);
}

View File

@ -254,18 +254,18 @@ extern struct xkb_keymap *
CompileKeymap(struct xkb_context *context, XkbFile *file);
extern bool
CompileKeycodes(XkbFile *file, struct xkb_keymap * xkb, unsigned merge);
CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge);
extern bool
CompileKeyTypes(XkbFile *file, struct xkb_keymap * xkb, unsigned merge);
CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge);
typedef struct _LEDInfo *LEDInfoPtr;
extern bool
CompileCompatMap(XkbFile *file, struct xkb_keymap * xkb, unsigned merge,
CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, unsigned merge,
LEDInfoPtr *unboundLEDs);
extern bool
CompileSymbols(XkbFile *file, struct xkb_keymap * xkb, unsigned merge);
CompileSymbols(XkbFile *file, struct xkb_keymap *keymap, unsigned merge);
#endif /* XKBCOMP_H */

View File

@ -41,7 +41,7 @@ test_file(const char *path)
{
int fd;
struct xkb_context *context;
struct xkb_keymap *xkb;
struct xkb_keymap *keymap;
fd = open(path, O_RDONLY);
assert(fd >= 0);
@ -51,16 +51,16 @@ test_file(const char *path)
fprintf(stderr, "\nCompiling path: %s\n", path);
xkb = xkb_map_new_from_fd(context, fd, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
keymap = xkb_map_new_from_fd(context, fd, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
close(fd);
if (!xkb) {
if (!keymap) {
fprintf(stderr, "Failed to compile keymap\n");
xkb_context_unref(context);
return 0;
}
xkb_map_unref(xkb);
xkb_map_unref(keymap);
xkb_context_unref(context);
return 1;
}
@ -79,20 +79,21 @@ static int
test_string(const char *string)
{
struct xkb_context *context;
struct xkb_keymap *xkb;
struct xkb_keymap *keymap;
context = xkb_context_new(0);
assert(context);
fprintf(stderr, "\nCompiling string\n");
xkb = xkb_map_new_from_string(context, string, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
if (!xkb) {
keymap = xkb_map_new_from_string(context, string,
XKB_KEYMAP_FORMAT_TEXT_V1, 0);
if (!keymap) {
xkb_context_unref(context);
return 0;
}
xkb_map_unref(xkb);
xkb_map_unref(keymap);
xkb_context_unref(context);
return 1;
}

View File

@ -37,7 +37,7 @@ test_names(const char *keycodes, const char *types,
{
int ret = 1;
struct xkb_context *context;
struct xkb_keymap *xkb;
struct xkb_keymap *keymap;
struct xkb_component_names kccgst = {
.keymap = NULL,
.keycodes = strdup(keycodes),
@ -52,13 +52,13 @@ test_names(const char *keycodes, const char *types,
fprintf(stderr, "\nCompiling %s %s %s %s\n", kccgst.keycodes, kccgst.types,
kccgst.compat, kccgst.symbols);
xkb = xkb_map_new_from_kccgst(context, &kccgst, 0);
if (!xkb) {
keymap = xkb_map_new_from_kccgst(context, &kccgst, 0);
if (!keymap) {
ret = 0;
goto err_ctx;
}
xkb_map_unref(xkb);
xkb_map_unref(keymap);
err_ctx:
xkb_context_unref(context);
free(kccgst.keycodes);

View File

@ -34,7 +34,7 @@ test_rmlvo(const char *rules, const char *model, const char *layout,
const char *variant, const char *options)
{
struct xkb_context *context;
struct xkb_keymap *xkb;
struct xkb_keymap *keymap;
struct xkb_rule_names rmlvo = {
.rules = rules,
.model = model,
@ -49,13 +49,13 @@ test_rmlvo(const char *rules, const char *model, const char *layout,
fprintf(stderr, "\nCompiling %s %s %s %s %s\n", rmlvo.rules, rmlvo.model,
rmlvo.layout, rmlvo.variant, rmlvo.options);
xkb = xkb_map_new_from_names(context, &rmlvo, 0);
if (!xkb) {
keymap = xkb_map_new_from_names(context, &rmlvo, 0);
if (!keymap) {
xkb_context_unref(context);
return 0;
}
xkb_map_unref(xkb);
xkb_map_unref(keymap);
xkb_context_unref(context);
return 1;
}

View File

@ -49,11 +49,11 @@ print_state(struct xkb_state *state)
return;
}
for (group = 0; group < xkb_map_num_groups(state->xkb); group++) {
for (group = 0; group < xkb_map_num_groups(state->keymap); group++) {
if (!xkb_state_group_index_is_active(state, group, XKB_STATE_EFFECTIVE))
continue;
fprintf(stderr, "\tgroup %s (%d): %s%s%s%s\n",
xkb_map_group_get_name(state->xkb, group),
xkb_map_group_get_name(state->keymap, group),
group,
xkb_state_group_index_is_active(state, group, XKB_STATE_EFFECTIVE) ?
"effective " : "",
@ -65,11 +65,11 @@ print_state(struct xkb_state *state)
"locked " : "");
}
for (mod = 0; mod < xkb_map_num_mods(state->xkb); mod++) {
for (mod = 0; mod < xkb_map_num_mods(state->keymap); mod++) {
if (!xkb_state_mod_index_is_active(state, mod, XKB_STATE_EFFECTIVE))
continue;
fprintf(stderr, "\tmod %s (%d): %s%s%s\n",
xkb_map_mod_get_name(state->xkb, mod),
xkb_map_mod_get_name(state->keymap, mod),
mod,
xkb_state_mod_index_is_active(state, mod, XKB_STATE_DEPRESSED) ?
"depressed " : "",
@ -79,19 +79,19 @@ print_state(struct xkb_state *state)
"locked " : "");
}
for (led = 0; led < xkb_map_num_leds(state->xkb); led++) {
for (led = 0; led < xkb_map_num_leds(state->keymap); led++) {
if (!xkb_state_led_index_is_active(state, led))
continue;
fprintf(stderr, "\tled %s (%d): active\n",
xkb_map_led_get_name(state->xkb, led),
xkb_map_led_get_name(state->keymap, led),
led);
}
}
static void
test_update_key(struct xkb_keymap *xkb)
test_update_key(struct xkb_keymap *keymap)
{
struct xkb_state *state = xkb_state_new(xkb);
struct xkb_state *state = xkb_state_new(keymap);
const xkb_keysym_t *syms;
int num_syms;
@ -170,9 +170,9 @@ test_update_key(struct xkb_keymap *xkb)
}
static void
test_serialisation(struct xkb_keymap *xkb)
test_serialisation(struct xkb_keymap *keymap)
{
struct xkb_state *state = xkb_state_new(xkb);
struct xkb_state *state = xkb_state_new(keymap);
xkb_mod_mask_t base_mods;
xkb_mod_mask_t latched_mods;
xkb_mod_mask_t locked_mods;
@ -184,11 +184,11 @@ test_serialisation(struct xkb_keymap *xkb)
assert(state);
caps = xkb_map_mod_get_index(state->xkb, XKB_MOD_NAME_CAPS);
caps = xkb_map_mod_get_index(state->keymap, XKB_MOD_NAME_CAPS);
assert(caps != XKB_MOD_INVALID);
shift = xkb_map_mod_get_index(state->xkb, XKB_MOD_NAME_SHIFT);
shift = xkb_map_mod_get_index(state->keymap, XKB_MOD_NAME_SHIFT);
assert(shift != XKB_MOD_INVALID);
ctrl = xkb_map_mod_get_index(state->xkb, XKB_MOD_NAME_CTRL);
ctrl = xkb_map_mod_get_index(state->keymap, XKB_MOD_NAME_CTRL);
assert(ctrl != XKB_MOD_INVALID);
xkb_state_update_key(state, KEY_CAPSLOCK + EVDEV_OFFSET, XKB_KEY_DOWN);
@ -226,7 +226,7 @@ int
main(void)
{
struct xkb_context *context;
struct xkb_keymap *xkb;
struct xkb_keymap *keymap;
struct xkb_rule_names rmlvo = {
.rules = "evdev",
.model = "pc104",
@ -238,12 +238,12 @@ main(void)
context = xkb_context_new(0);
assert(context);
xkb = xkb_map_new_from_names(context, &rmlvo, 0);
assert(xkb);
keymap = xkb_map_new_from_names(context, &rmlvo, 0);
assert(keymap);
test_update_key(xkb);
test_serialisation(xkb);
test_update_key(keymap);
test_serialisation(keymap);
xkb_map_unref(xkb);
xkb_map_unref(keymap);
xkb_context_unref(context);
}