}
static const char *
-XkbcVModIndexText(struct xkb_keymap *keymap, unsigned ndx)
+XkbcVModIndexText(struct xkb_keymap *keymap, xkb_mod_index_t ndx)
{
int len;
char *rtrn;
}
const char *
-XkbcVModMaskText(struct xkb_keymap *keymap, unsigned modMask, unsigned mask)
+XkbcVModMaskText(struct xkb_keymap *keymap, xkb_mod_mask_t modMask,
+ xkb_mod_mask_t mask)
{
- int i, bit, len, rem;
+ xkb_mod_index_t i;
+ xkb_mod_mask_t bit;
+ int len, rem;
const char *mm = NULL;
char *rtrn, *str;
char buf[BUFFER_SIZE];
- if ((modMask == 0) && (mask == 0))
+ if (modMask == 0 && mask == 0)
return "none";
if (modMask != 0)
else
str = NULL;
- len = ((str) ? strlen(str) : 0) + ((mm) ? strlen(mm) : 0) +
- ((str && mm) ? 1 : 0);
+ len = (str ? strlen(str) : 0) + (mm ? strlen(mm) : 0) +
+ (str && mm ? 1 : 0);
if (len >= BUFFER_SIZE)
len = BUFFER_SIZE - 1;
rtrn = tbGetBuffer(len + 1);
rtrn[0] = '\0';
- snprintf(rtrn, len + 1, "%s%s%s", (mm) ? mm : "",
- (mm && str) ? "+" : "", (str) ? str : "");
+ snprintf(rtrn, len + 1, "%s%s%s", (mm ? mm : ""),
+ (mm && str ? "+" : ""), (str ? str : ""));
return rtrn;
}
};
const char *
-XkbcModIndexText(unsigned ndx)
+XkbcModIndexText(xkb_mod_index_t ndx)
{
char *buf;
}
const char *
-XkbcModMaskText(unsigned mask, bool cFormat)
+XkbcModMaskText(xkb_mod_mask_t mask, bool cFormat)
{
- int i, rem, bit;
+ int i, rem;
+ xkb_mod_index_t bit;
char *str, *buf;
if ((mask & 0xff) == 0xff)
#include "xkb-priv.h"
-extern const char *
-XkbcVModMaskText(struct xkb_keymap *keymap, unsigned modMask, unsigned mask);
+const char *
+XkbcVModMaskText(struct xkb_keymap *keymap, xkb_mod_mask_t modMask,
+ xkb_mod_mask_t mask);
-extern const char *
-XkbcModIndexText(unsigned ndx);
+const char *
+XkbcModIndexText(xkb_mod_index_t ndx);
-extern const char *
-XkbcModMaskText(unsigned mask, bool cFormat);
+const char *
+XkbcModMaskText(xkb_mod_mask_t mask, bool cFormat);
extern const char *
XkbcFileTypeText(enum xkb_file_type type);
};
struct xkb_mods {
- uint32_t mask; /* effective mods */
- uint32_t vmods;
+ xkb_mod_mask_t mask; /* effective mods */
+ xkb_mod_mask_t vmods;
uint8_t real_mods;
};
unsigned char flags;
unsigned char match;
uint8_t mods;
- uint32_t virtual_mod;
+ xkb_mod_index_t virtual_mod;
union xkb_action act;
};
unsigned char explicit;
unsigned char modmap;
- uint32_t vmodmap;
+ xkb_mod_mask_t vmodmap;
struct xkb_behavior behavior;
darray(struct xkb_sym_interpret) sym_interpret;
/* vmod -> mod mapping */
- uint32_t vmods[XkbNumVirtualMods];
+ xkb_mod_index_t vmods[XkbNumVirtualMods];
const char *vmod_names[XkbNumVirtualMods];
struct xkb_mods groups[XkbNumKbdGroups];
const char *
xkb_atom_text(struct xkb_context *ctx, xkb_atom_t atom);
-extern unsigned int
+xkb_group_index_t
xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc);
extern unsigned int
static bool
CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
- unsigned *flags_inout, unsigned *mods_rtrn)
+ unsigned *flags_inout, xkb_mod_mask_t *mods_rtrn)
{
ExprResult rtrn;
return true;
}
}
+
if (!ExprResolveVModMask(keymap, value, &rtrn))
return ReportMismatch(keymap, action, F_Modifiers, "modifier mask");
- *mods_rtrn = rtrn.uval;
+
+ *mods_rtrn = (xkb_mod_mask_t) rtrn.ival;
*flags_inout &= ~XkbSA_UseModMapMods;
return true;
}
{
struct xkb_mod_action *act;
unsigned rtrn;
- unsigned t1, t2;
+ unsigned t1;
+ xkb_mod_mask_t t2;
act = (struct xkb_mod_action *) action;
if (array_ndx != NULL) {
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
struct xkb_mod_action *act;
- unsigned t1, t2;
+ unsigned t1;
+ xkb_mod_mask_t t2;
act = (struct xkb_mod_action *) action;
if ((array_ndx != NULL) && (field == F_Modifiers))
{
ExprResult rtrn;
struct xkb_iso_action *act;
- unsigned flags, mods;
+ unsigned flags;
+ xkb_mod_mask_t mods;
xkb_group_index_t group;
act = (struct xkb_iso_action *) action;
ExprResult rtrn;
struct xkb_key *key;
struct xkb_redirect_key_action *act;
- unsigned t1, t2;
+ unsigned t1;
+ xkb_mod_mask_t t2;
unsigned long tmp;
if (array_ndx != NULL)
unsigned char flags;
unsigned char which_mods;
unsigned char real_mods;
- unsigned short vmods;
+ xkb_mod_mask_t vmods;
unsigned char which_groups;
uint32_t groups;
unsigned int ctrls;
return false;
}
-uint32_t
-VModsToReal(struct xkb_keymap *keymap, uint32_t vmodmask)
+xkb_mod_mask_t
+VModsToReal(struct xkb_keymap *keymap, xkb_mod_mask_t vmodmask)
{
- uint32_t ret = 0;
- int i;
+ xkb_mod_mask_t ret = 0;
+ xkb_mod_index_t i;
if (!vmodmask)
return 0;
static void
UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act,
- uint32_t rmodmask)
+ xkb_mod_mask_t rmodmask)
{
switch (act->type) {
case XkbSA_SetMods:
#define INTERP_SIZE (8 * 4)
struct xkb_sym_interpret *interps[INTERP_SIZE];
union xkb_action *acts;
- uint32_t vmodmask = 0;
+ xkb_mod_mask_t vmodmask = 0;
int num_acts = 0;
xkb_group_index_t group;
int level;
bool
UpdateModifiersFromCompat(struct xkb_keymap *keymap)
{
- struct xkb_key *key;
+ xkb_mod_index_t vmod;
+ xkb_group_index_t grp;
+ xkb_led_index_t led;
int i;
+ struct xkb_key *key;
struct xkb_key_type *type;
struct xkb_kt_map_entry *entry;
return false;
/* Update keymap->vmods, the virtual -> real mod mapping. */
- for (i = 0; i < XkbNumVirtualMods; i++)
- keymap->vmods[i] = 0;
+ for (vmod = 0; vmod < XkbNumVirtualMods; vmod++)
+ keymap->vmods[vmod] = 0;
+
xkb_foreach_key(key, keymap) {
if (!key->vmodmap)
continue;
- for (i = 0; i < XkbNumVirtualMods; i++) {
- if (!(key->vmodmap & (1 << i)))
+ for (vmod = 0; vmod < XkbNumVirtualMods; vmod++) {
+ if (!(key->vmodmap & (1 << vmod)))
continue;
- keymap->vmods[i] |= key->modmap;
+ keymap->vmods[vmod] |= key->modmap;
}
}
/* Now update the level masks for all the types to reflect the vmods. */
darray_foreach(type, keymap->types) {
- uint32_t mask = 0;
- int j;
+ xkb_mod_mask_t mask = 0;
type->mods.mask = type->mods.real_mods;
type->mods.mask |= VModsToReal(keymap, type->mods.vmods);
- for (j = 0; j < XkbNumVirtualMods; j++) {
- if (!(type->mods.vmods & (1 << j)))
+
+ /* FIXME: We compute the mask with doing anything with it? */
+ for (vmod = 0; vmod < XkbNumVirtualMods; vmod++) {
+ if (!(type->mods.vmods & (1 << vmod)))
continue;
- mask |= keymap->vmods[j];
+ mask |= keymap->vmods[vmod];
}
darray_foreach(entry, type->map)
- entry->mods.mask = entry->mods.real_mods |
- VModsToReal(keymap, entry->mods.vmods);
+ entry->mods.mask = entry->mods.real_mods |
+ VModsToReal(keymap, entry->mods.vmods);
}
/* Update action modifiers. */
}
/* Update group modifiers. */
- for (i = 0; i < XkbNumKbdGroups; i++) {
- struct xkb_mods *group = &keymap->groups[i];
+ for (grp = 0; grp < XkbNumKbdGroups; grp++) {
+ struct xkb_mods *group = &keymap->groups[grp];
group->mask = group->real_mods | VModsToReal(keymap, group->vmods);
}
/* Update vmod -> indicator maps. */
- for (i = 0; i < XkbNumIndicators; i++) {
- struct xkb_mods *led = &keymap->indicators[i].mods;
- led->mask = led->real_mods | VModsToReal(keymap, led->vmods);
+ for (led = 0; led < XkbNumIndicators; led++) {
+ struct xkb_mods *mods = &keymap->indicators[led].mods;
+ mods->mask = mods->real_mods | VModsToReal(keymap, mods->vmods);
}
return true;
struct list entry;
xkb_atom_t name;
- unsigned mask;
- unsigned vmask;
+ xkb_mod_mask_t mask;
+ xkb_mod_mask_t vmask;
unsigned numLevels;
darray(struct xkb_kt_map_entry) entries;
struct list preserves;
void
ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
{
- int i, bit;
+ xkb_mod_index_t i;
+ xkb_mod_mask_t bit;
info->newlyDefined = info->defined = info->available = 0;
*/
bool
HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
- enum merge_mode mergeMode,
- VModInfo *info)
+ enum merge_mode mergeMode, VModInfo *info)
{
- int i, bit, nextFree;
+ xkb_mod_index_t i;
+ int nextFree;
+ xkb_mod_mask_t bit;
ExprResult mod;
- for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<=
- 1) {
+ nextFree = -1;
+ for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
+ const char *str1;
+ const char *str2 = "";
+
if (!(info->defined & bit)) {
if (nextFree < 0)
nextFree = i;
continue;
}
- if (keymap->vmod_names[i] &&
- strcmp(keymap->vmod_names[i],
- xkb_atom_text(keymap->ctx, stmt->name)) == 0) { /* already defined */
- info->available |= bit;
- if (stmt->value == NULL)
- return true;
- else {
- const char *str1;
- const char *str2 = "";
-
- if (!ExprResolveModMask(keymap->ctx, stmt->value,
- &mod)) {
- log_err(keymap->ctx, "Declaration of %s ignored\n",
- xkb_atom_text(keymap->ctx, stmt->name));
- return false;
- }
-
- if (mod.uval == keymap->vmods[i])
- return true;
-
- str1 = XkbcModMaskText(keymap->vmods[i], true);
- if (mergeMode == MERGE_OVERRIDE) {
- str2 = str1;
- str1 = XkbcModMaskText(mod.uval, true);
- }
- log_warn(keymap->ctx,
- "Virtual modifier %s multiply defined; "
- "Using %s, ignoring %s\n",
- xkb_atom_text(keymap->ctx, stmt->name), str1, str2);
-
- if (mergeMode == MERGE_OVERRIDE)
- keymap->vmods[i] = mod.uval;
- return true;
- }
+ /* already defined */
+ if (!keymap->vmod_names[i])
+ continue;
+
+ if (strcmp(keymap->vmod_names[i],
+ xkb_atom_text(keymap->ctx, stmt->name)) != 0)
+ continue;
+
+
+ info->available |= bit;
+
+ if (!stmt->value)
+ return true;
+
+ if (!ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
+ log_err(keymap->ctx, "Declaration of %s ignored\n",
+ xkb_atom_text(keymap->ctx, stmt->name));
+ return false;
+ }
+
+ if (mod.uval == keymap->vmods[i])
+ return true;
+
+ str1 = XkbcModMaskText(keymap->vmods[i], true);
+ if (mergeMode == MERGE_OVERRIDE) {
+ str2 = str1;
+ str1 = XkbcModMaskText(mod.uval, true);
}
+
+ log_warn(keymap->ctx,
+ "Virtual modifier %s defined multiple times; "
+ "Using %s, ignoring %s\n",
+ xkb_atom_text(keymap->ctx, stmt->name), str1, str2);
+
+ if (mergeMode == MERGE_OVERRIDE)
+ keymap->vmods[i] = mod.uval;
+
+ return true;
}
if (nextFree < 0) {
XkbNumVirtualMods);
return false;
}
+
info->defined |= (1 << nextFree);
info->newlyDefined |= (1 << nextFree);
info->available |= (1 << nextFree);
+
keymap->vmod_names[nextFree] = xkb_atom_text(keymap->ctx, stmt->name);
- if (stmt->value == NULL)
- return true;
- if (ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
- keymap->vmods[nextFree] = mod.uval;
+
+ if (!stmt->value)
return true;
+
+ if (!ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
+ log_err(keymap->ctx, "Declaration of %s ignored\n",
+ xkb_atom_text(keymap->ctx, stmt->name));
+ return false;
}
- log_err(keymap->ctx, "Declaration of %s ignored\n",
- xkb_atom_text(keymap->ctx, stmt->name));
- return false;
+
+ keymap->vmods[nextFree] = mod.uval;
+ return true;
}
/**
LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
unsigned type, ExprResult * val_rtrn)
{
- int i;
+ xkb_mod_index_t i;
const char *name = xkb_atom_text(keymap->ctx, field);
if (type != TypeInt)
ExprResult *val_rtrn, VModInfo *info)
{
if (def->op == ExprIdent) {
- int i, bit;
+ xkb_mod_index_t i;
+ xkb_mod_mask_t bit;
const char *name = xkb_atom_text(keymap->ctx, def->value.str);
+
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
if ((info->available & bit) && keymap->vmod_names[i] &&
strcmp(keymap->vmod_names[i], name) == 0) {
#include "expr.h"
typedef struct _VModInfo {
- unsigned defined;
- unsigned available;
- unsigned newlyDefined;
+ xkb_mod_mask_t defined;
+ xkb_mod_mask_t available;
+ xkb_mod_mask_t newlyDefined;
int errorCount;
} VModInfo;
#include "xkbcomp.h"
#include "text.h"
-#include "utils.h"
extern bool
ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
extern bool
UpdateModifiersFromCompat(struct xkb_keymap *keymap);
-uint32_t
-VModsToReal(struct xkb_keymap *keymap, uint32_t vmodmask);
+xkb_mod_mask_t
+VModsToReal(struct xkb_keymap *keymap, xkb_mod_mask_t vmodmask);
static inline unsigned long
KeyNameToLong(const char *name)