Use xkb_mod_mask_t and xkb_mask_index_t throughout
Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
74be17627e
commit
6cb9820000
26
src/text.c
26
src/text.c
|
@ -48,7 +48,7 @@ tbGetBuffer(unsigned int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
XkbcVModIndexText(struct xkb_keymap *keymap, unsigned ndx)
|
XkbcVModIndexText(struct xkb_keymap *keymap, xkb_mod_index_t ndx)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *rtrn;
|
char *rtrn;
|
||||||
|
@ -76,14 +76,17 @@ XkbcVModIndexText(struct xkb_keymap *keymap, unsigned ndx)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
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;
|
const char *mm = NULL;
|
||||||
char *rtrn, *str;
|
char *rtrn, *str;
|
||||||
char buf[BUFFER_SIZE];
|
char buf[BUFFER_SIZE];
|
||||||
|
|
||||||
if ((modMask == 0) && (mask == 0))
|
if (modMask == 0 && mask == 0)
|
||||||
return "none";
|
return "none";
|
||||||
|
|
||||||
if (modMask != 0)
|
if (modMask != 0)
|
||||||
|
@ -111,16 +114,16 @@ XkbcVModMaskText(struct xkb_keymap *keymap, unsigned modMask, unsigned mask)
|
||||||
else
|
else
|
||||||
str = NULL;
|
str = NULL;
|
||||||
|
|
||||||
len = ((str) ? strlen(str) : 0) + ((mm) ? strlen(mm) : 0) +
|
len = (str ? strlen(str) : 0) + (mm ? strlen(mm) : 0) +
|
||||||
((str && mm) ? 1 : 0);
|
(str && mm ? 1 : 0);
|
||||||
if (len >= BUFFER_SIZE)
|
if (len >= BUFFER_SIZE)
|
||||||
len = BUFFER_SIZE - 1;
|
len = BUFFER_SIZE - 1;
|
||||||
|
|
||||||
rtrn = tbGetBuffer(len + 1);
|
rtrn = tbGetBuffer(len + 1);
|
||||||
rtrn[0] = '\0';
|
rtrn[0] = '\0';
|
||||||
|
|
||||||
snprintf(rtrn, len + 1, "%s%s%s", (mm) ? mm : "",
|
snprintf(rtrn, len + 1, "%s%s%s", (mm ? mm : ""),
|
||||||
(mm && str) ? "+" : "", (str) ? str : "");
|
(mm && str ? "+" : ""), (str ? str : ""));
|
||||||
|
|
||||||
return rtrn;
|
return rtrn;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +140,7 @@ static const char *modNames[XkbNumModifiers] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
XkbcModIndexText(unsigned ndx)
|
XkbcModIndexText(xkb_mod_index_t ndx)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
|
@ -153,9 +156,10 @@ XkbcModIndexText(unsigned ndx)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
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;
|
char *str, *buf;
|
||||||
|
|
||||||
if ((mask & 0xff) == 0xff)
|
if ((mask & 0xff) == 0xff)
|
||||||
|
|
13
src/text.h
13
src/text.h
|
@ -29,14 +29,15 @@
|
||||||
|
|
||||||
#include "xkb-priv.h"
|
#include "xkb-priv.h"
|
||||||
|
|
||||||
extern const char *
|
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);
|
||||||
|
|
||||||
extern const char *
|
const char *
|
||||||
XkbcModIndexText(unsigned ndx);
|
XkbcModIndexText(xkb_mod_index_t ndx);
|
||||||
|
|
||||||
extern const char *
|
const char *
|
||||||
XkbcModMaskText(unsigned mask, bool cFormat);
|
XkbcModMaskText(xkb_mod_mask_t mask, bool cFormat);
|
||||||
|
|
||||||
extern const char *
|
extern const char *
|
||||||
XkbcFileTypeText(enum xkb_file_type type);
|
XkbcFileTypeText(enum xkb_file_type type);
|
||||||
|
|
|
@ -235,8 +235,8 @@ union xkb_action {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xkb_mods {
|
struct xkb_mods {
|
||||||
uint32_t mask; /* effective mods */
|
xkb_mod_mask_t mask; /* effective mods */
|
||||||
uint32_t vmods;
|
xkb_mod_mask_t vmods;
|
||||||
uint8_t real_mods;
|
uint8_t real_mods;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ struct xkb_sym_interpret {
|
||||||
unsigned char flags;
|
unsigned char flags;
|
||||||
unsigned char match;
|
unsigned char match;
|
||||||
uint8_t mods;
|
uint8_t mods;
|
||||||
uint32_t virtual_mod;
|
xkb_mod_index_t virtual_mod;
|
||||||
union xkb_action act;
|
union xkb_action act;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ struct xkb_key {
|
||||||
unsigned char explicit;
|
unsigned char explicit;
|
||||||
|
|
||||||
unsigned char modmap;
|
unsigned char modmap;
|
||||||
uint32_t vmodmap;
|
xkb_mod_mask_t vmodmap;
|
||||||
|
|
||||||
struct xkb_behavior behavior;
|
struct xkb_behavior behavior;
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ struct xkb_keymap {
|
||||||
darray(struct xkb_sym_interpret) sym_interpret;
|
darray(struct xkb_sym_interpret) sym_interpret;
|
||||||
|
|
||||||
/* vmod -> mod mapping */
|
/* vmod -> mod mapping */
|
||||||
uint32_t vmods[XkbNumVirtualMods];
|
xkb_mod_index_t vmods[XkbNumVirtualMods];
|
||||||
const char *vmod_names[XkbNumVirtualMods];
|
const char *vmod_names[XkbNumVirtualMods];
|
||||||
|
|
||||||
struct xkb_mods groups[XkbNumKbdGroups];
|
struct xkb_mods groups[XkbNumKbdGroups];
|
||||||
|
@ -489,7 +489,7 @@ xkb_atom_strdup(struct xkb_context *ctx, xkb_atom_t atom);
|
||||||
const char *
|
const char *
|
||||||
xkb_atom_text(struct xkb_context *ctx, xkb_atom_t atom);
|
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);
|
xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc);
|
||||||
|
|
||||||
extern unsigned int
|
extern unsigned int
|
||||||
|
|
|
@ -240,7 +240,7 @@ CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action,
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
|
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;
|
ExprResult rtrn;
|
||||||
|
|
||||||
|
@ -255,9 +255,11 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ExprResolveVModMask(keymap, value, &rtrn))
|
if (!ExprResolveVModMask(keymap, value, &rtrn))
|
||||||
return ReportMismatch(keymap, action, F_Modifiers, "modifier mask");
|
return ReportMismatch(keymap, action, F_Modifiers, "modifier mask");
|
||||||
*mods_rtrn = rtrn.uval;
|
|
||||||
|
*mods_rtrn = (xkb_mod_mask_t) rtrn.ival;
|
||||||
*flags_inout &= ~XkbSA_UseModMapMods;
|
*flags_inout &= ~XkbSA_UseModMapMods;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +270,8 @@ HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
|
||||||
{
|
{
|
||||||
struct xkb_mod_action *act;
|
struct xkb_mod_action *act;
|
||||||
unsigned rtrn;
|
unsigned rtrn;
|
||||||
unsigned t1, t2;
|
unsigned t1;
|
||||||
|
xkb_mod_mask_t t2;
|
||||||
|
|
||||||
act = (struct xkb_mod_action *) action;
|
act = (struct xkb_mod_action *) action;
|
||||||
if (array_ndx != NULL) {
|
if (array_ndx != NULL) {
|
||||||
|
@ -307,7 +310,8 @@ HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
|
||||||
unsigned field, ExprDef *array_ndx, ExprDef *value)
|
unsigned field, ExprDef *array_ndx, ExprDef *value)
|
||||||
{
|
{
|
||||||
struct xkb_mod_action *act;
|
struct xkb_mod_action *act;
|
||||||
unsigned t1, t2;
|
unsigned t1;
|
||||||
|
xkb_mod_mask_t t2;
|
||||||
|
|
||||||
act = (struct xkb_mod_action *) action;
|
act = (struct xkb_mod_action *) action;
|
||||||
if ((array_ndx != NULL) && (field == F_Modifiers))
|
if ((array_ndx != NULL) && (field == F_Modifiers))
|
||||||
|
@ -599,7 +603,8 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
|
||||||
{
|
{
|
||||||
ExprResult rtrn;
|
ExprResult rtrn;
|
||||||
struct xkb_iso_action *act;
|
struct xkb_iso_action *act;
|
||||||
unsigned flags, mods;
|
unsigned flags;
|
||||||
|
xkb_mod_mask_t mods;
|
||||||
xkb_group_index_t group;
|
xkb_group_index_t group;
|
||||||
|
|
||||||
act = (struct xkb_iso_action *) action;
|
act = (struct xkb_iso_action *) action;
|
||||||
|
@ -825,7 +830,8 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
|
||||||
ExprResult rtrn;
|
ExprResult rtrn;
|
||||||
struct xkb_key *key;
|
struct xkb_key *key;
|
||||||
struct xkb_redirect_key_action *act;
|
struct xkb_redirect_key_action *act;
|
||||||
unsigned t1, t2;
|
unsigned t1;
|
||||||
|
xkb_mod_mask_t t2;
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
|
|
||||||
if (array_ndx != NULL)
|
if (array_ndx != NULL)
|
||||||
|
|
|
@ -55,7 +55,7 @@ typedef struct _LEDInfo {
|
||||||
unsigned char flags;
|
unsigned char flags;
|
||||||
unsigned char which_mods;
|
unsigned char which_mods;
|
||||||
unsigned char real_mods;
|
unsigned char real_mods;
|
||||||
unsigned short vmods;
|
xkb_mod_mask_t vmods;
|
||||||
unsigned char which_groups;
|
unsigned char which_groups;
|
||||||
uint32_t groups;
|
uint32_t groups;
|
||||||
unsigned int ctrls;
|
unsigned int ctrls;
|
||||||
|
@ -1270,11 +1270,11 @@ err_info:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
xkb_mod_mask_t
|
||||||
VModsToReal(struct xkb_keymap *keymap, uint32_t vmodmask)
|
VModsToReal(struct xkb_keymap *keymap, xkb_mod_mask_t vmodmask)
|
||||||
{
|
{
|
||||||
uint32_t ret = 0;
|
xkb_mod_mask_t ret = 0;
|
||||||
int i;
|
xkb_mod_index_t i;
|
||||||
|
|
||||||
if (!vmodmask)
|
if (!vmodmask)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1290,7 +1290,7 @@ VModsToReal(struct xkb_keymap *keymap, uint32_t vmodmask)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act,
|
UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act,
|
||||||
uint32_t rmodmask)
|
xkb_mod_mask_t rmodmask)
|
||||||
{
|
{
|
||||||
switch (act->type) {
|
switch (act->type) {
|
||||||
case XkbSA_SetMods:
|
case XkbSA_SetMods:
|
||||||
|
@ -1383,7 +1383,7 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key)
|
||||||
#define INTERP_SIZE (8 * 4)
|
#define INTERP_SIZE (8 * 4)
|
||||||
struct xkb_sym_interpret *interps[INTERP_SIZE];
|
struct xkb_sym_interpret *interps[INTERP_SIZE];
|
||||||
union xkb_action *acts;
|
union xkb_action *acts;
|
||||||
uint32_t vmodmask = 0;
|
xkb_mod_mask_t vmodmask = 0;
|
||||||
int num_acts = 0;
|
int num_acts = 0;
|
||||||
xkb_group_index_t group;
|
xkb_group_index_t group;
|
||||||
int level;
|
int level;
|
||||||
|
@ -1460,8 +1460,11 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key)
|
||||||
bool
|
bool
|
||||||
UpdateModifiersFromCompat(struct xkb_keymap *keymap)
|
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;
|
int i;
|
||||||
|
struct xkb_key *key;
|
||||||
struct xkb_key_type *type;
|
struct xkb_key_type *type;
|
||||||
struct xkb_kt_map_entry *entry;
|
struct xkb_kt_map_entry *entry;
|
||||||
|
|
||||||
|
@ -1472,29 +1475,31 @@ UpdateModifiersFromCompat(struct xkb_keymap *keymap)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Update keymap->vmods, the virtual -> real mod mapping. */
|
/* Update keymap->vmods, the virtual -> real mod mapping. */
|
||||||
for (i = 0; i < XkbNumVirtualMods; i++)
|
for (vmod = 0; vmod < XkbNumVirtualMods; vmod++)
|
||||||
keymap->vmods[i] = 0;
|
keymap->vmods[vmod] = 0;
|
||||||
|
|
||||||
xkb_foreach_key(key, keymap) {
|
xkb_foreach_key(key, keymap) {
|
||||||
if (!key->vmodmap)
|
if (!key->vmodmap)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (i = 0; i < XkbNumVirtualMods; i++) {
|
for (vmod = 0; vmod < XkbNumVirtualMods; vmod++) {
|
||||||
if (!(key->vmodmap & (1 << i)))
|
if (!(key->vmodmap & (1 << vmod)))
|
||||||
continue;
|
continue;
|
||||||
keymap->vmods[i] |= key->modmap;
|
keymap->vmods[vmod] |= key->modmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now update the level masks for all the types to reflect the vmods. */
|
/* Now update the level masks for all the types to reflect the vmods. */
|
||||||
darray_foreach(type, keymap->types) {
|
darray_foreach(type, keymap->types) {
|
||||||
uint32_t mask = 0;
|
xkb_mod_mask_t mask = 0;
|
||||||
int j;
|
|
||||||
type->mods.mask = type->mods.real_mods;
|
type->mods.mask = type->mods.real_mods;
|
||||||
type->mods.mask |= VModsToReal(keymap, type->mods.vmods);
|
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;
|
continue;
|
||||||
mask |= keymap->vmods[j];
|
mask |= keymap->vmods[vmod];
|
||||||
}
|
}
|
||||||
|
|
||||||
darray_foreach(entry, type->map)
|
darray_foreach(entry, type->map)
|
||||||
|
@ -1513,15 +1518,15 @@ UpdateModifiersFromCompat(struct xkb_keymap *keymap)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update group modifiers. */
|
/* Update group modifiers. */
|
||||||
for (i = 0; i < XkbNumKbdGroups; i++) {
|
for (grp = 0; grp < XkbNumKbdGroups; grp++) {
|
||||||
struct xkb_mods *group = &keymap->groups[i];
|
struct xkb_mods *group = &keymap->groups[grp];
|
||||||
group->mask = group->real_mods | VModsToReal(keymap, group->vmods);
|
group->mask = group->real_mods | VModsToReal(keymap, group->vmods);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update vmod -> indicator maps. */
|
/* Update vmod -> indicator maps. */
|
||||||
for (i = 0; i < XkbNumIndicators; i++) {
|
for (led = 0; led < XkbNumIndicators; led++) {
|
||||||
struct xkb_mods *led = &keymap->indicators[i].mods;
|
struct xkb_mods *mods = &keymap->indicators[led].mods;
|
||||||
led->mask = led->real_mods | VModsToReal(keymap, led->vmods);
|
mods->mask = mods->real_mods | VModsToReal(keymap, mods->vmods);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -50,8 +50,8 @@ typedef struct _KeyTypeInfo {
|
||||||
struct list entry;
|
struct list entry;
|
||||||
|
|
||||||
xkb_atom_t name;
|
xkb_atom_t name;
|
||||||
unsigned mask;
|
xkb_mod_mask_t mask;
|
||||||
unsigned vmask;
|
xkb_mod_mask_t vmask;
|
||||||
unsigned numLevels;
|
unsigned numLevels;
|
||||||
darray(struct xkb_kt_map_entry) entries;
|
darray(struct xkb_kt_map_entry) entries;
|
||||||
struct list preserves;
|
struct list preserves;
|
||||||
|
|
|
@ -36,7 +36,8 @@ InitVModInfo(VModInfo *info, struct xkb_keymap *keymap)
|
||||||
void
|
void
|
||||||
ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
|
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;
|
info->newlyDefined = info->defined = info->available = 0;
|
||||||
|
|
||||||
|
@ -60,32 +61,39 @@ ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
|
HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
|
||||||
enum merge_mode mergeMode,
|
enum merge_mode mergeMode, VModInfo *info)
|
||||||
VModInfo *info)
|
|
||||||
{
|
{
|
||||||
int i, bit, nextFree;
|
xkb_mod_index_t i;
|
||||||
|
int nextFree;
|
||||||
|
xkb_mod_mask_t bit;
|
||||||
ExprResult mod;
|
ExprResult mod;
|
||||||
|
|
||||||
for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<=
|
nextFree = -1;
|
||||||
1) {
|
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
|
||||||
|
const char *str1;
|
||||||
|
const char *str2 = "";
|
||||||
|
|
||||||
if (!(info->defined & bit)) {
|
if (!(info->defined & bit)) {
|
||||||
if (nextFree < 0)
|
if (nextFree < 0)
|
||||||
nextFree = i;
|
nextFree = i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keymap->vmod_names[i] &&
|
/* already defined */
|
||||||
strcmp(keymap->vmod_names[i],
|
if (!keymap->vmod_names[i])
|
||||||
xkb_atom_text(keymap->ctx, stmt->name)) == 0) { /* already defined */
|
continue;
|
||||||
info->available |= bit;
|
|
||||||
if (stmt->value == NULL)
|
|
||||||
return true;
|
|
||||||
else {
|
|
||||||
const char *str1;
|
|
||||||
const char *str2 = "";
|
|
||||||
|
|
||||||
if (!ExprResolveModMask(keymap->ctx, stmt->value,
|
if (strcmp(keymap->vmod_names[i],
|
||||||
&mod)) {
|
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",
|
log_err(keymap->ctx, "Declaration of %s ignored\n",
|
||||||
xkb_atom_text(keymap->ctx, stmt->name));
|
xkb_atom_text(keymap->ctx, stmt->name));
|
||||||
return false;
|
return false;
|
||||||
|
@ -99,17 +107,17 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
|
||||||
str2 = str1;
|
str2 = str1;
|
||||||
str1 = XkbcModMaskText(mod.uval, true);
|
str1 = XkbcModMaskText(mod.uval, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_warn(keymap->ctx,
|
log_warn(keymap->ctx,
|
||||||
"Virtual modifier %s multiply defined; "
|
"Virtual modifier %s defined multiple times; "
|
||||||
"Using %s, ignoring %s\n",
|
"Using %s, ignoring %s\n",
|
||||||
xkb_atom_text(keymap->ctx, stmt->name), str1, str2);
|
xkb_atom_text(keymap->ctx, stmt->name), str1, str2);
|
||||||
|
|
||||||
if (mergeMode == MERGE_OVERRIDE)
|
if (mergeMode == MERGE_OVERRIDE)
|
||||||
keymap->vmods[i] = mod.uval;
|
keymap->vmods[i] = mod.uval;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextFree < 0) {
|
if (nextFree < 0) {
|
||||||
log_err(keymap->ctx,
|
log_err(keymap->ctx,
|
||||||
|
@ -117,19 +125,24 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
|
||||||
XkbNumVirtualMods);
|
XkbNumVirtualMods);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->defined |= (1 << nextFree);
|
info->defined |= (1 << nextFree);
|
||||||
info->newlyDefined |= (1 << nextFree);
|
info->newlyDefined |= (1 << nextFree);
|
||||||
info->available |= (1 << nextFree);
|
info->available |= (1 << nextFree);
|
||||||
|
|
||||||
keymap->vmod_names[nextFree] = xkb_atom_text(keymap->ctx, stmt->name);
|
keymap->vmod_names[nextFree] = xkb_atom_text(keymap->ctx, stmt->name);
|
||||||
if (stmt->value == NULL)
|
|
||||||
|
if (!stmt->value)
|
||||||
return true;
|
return true;
|
||||||
if (ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
|
|
||||||
keymap->vmods[nextFree] = mod.uval;
|
if (!ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
log_err(keymap->ctx, "Declaration of %s ignored\n",
|
log_err(keymap->ctx, "Declaration of %s ignored\n",
|
||||||
xkb_atom_text(keymap->ctx, stmt->name));
|
xkb_atom_text(keymap->ctx, stmt->name));
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
keymap->vmods[nextFree] = mod.uval;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,7 +160,7 @@ static int
|
||||||
LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
|
LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
|
||||||
unsigned type, ExprResult * val_rtrn)
|
unsigned type, ExprResult * val_rtrn)
|
||||||
{
|
{
|
||||||
int i;
|
xkb_mod_index_t i;
|
||||||
const char *name = xkb_atom_text(keymap->ctx, field);
|
const char *name = xkb_atom_text(keymap->ctx, field);
|
||||||
|
|
||||||
if (type != TypeInt)
|
if (type != TypeInt)
|
||||||
|
@ -211,8 +224,10 @@ ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
|
||||||
ExprResult *val_rtrn, VModInfo *info)
|
ExprResult *val_rtrn, VModInfo *info)
|
||||||
{
|
{
|
||||||
if (def->op == ExprIdent) {
|
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);
|
const char *name = xkb_atom_text(keymap->ctx, def->value.str);
|
||||||
|
|
||||||
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
|
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
|
||||||
if ((info->available & bit) && keymap->vmod_names[i] &&
|
if ((info->available & bit) && keymap->vmod_names[i] &&
|
||||||
strcmp(keymap->vmod_names[i], name) == 0) {
|
strcmp(keymap->vmod_names[i], name) == 0) {
|
||||||
|
|
|
@ -31,9 +31,9 @@
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
|
|
||||||
typedef struct _VModInfo {
|
typedef struct _VModInfo {
|
||||||
unsigned defined;
|
xkb_mod_mask_t defined;
|
||||||
unsigned available;
|
xkb_mod_mask_t available;
|
||||||
unsigned newlyDefined;
|
xkb_mod_mask_t newlyDefined;
|
||||||
int errorCount;
|
int errorCount;
|
||||||
} VModInfo;
|
} VModInfo;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
#include "xkbcomp.h"
|
#include "xkbcomp.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
extern bool
|
extern bool
|
||||||
ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
|
ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
|
||||||
|
@ -47,8 +46,8 @@ FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,
|
||||||
extern bool
|
extern bool
|
||||||
UpdateModifiersFromCompat(struct xkb_keymap *keymap);
|
UpdateModifiersFromCompat(struct xkb_keymap *keymap);
|
||||||
|
|
||||||
uint32_t
|
xkb_mod_mask_t
|
||||||
VModsToReal(struct xkb_keymap *keymap, uint32_t vmodmask);
|
VModsToReal(struct xkb_keymap *keymap, xkb_mod_mask_t vmodmask);
|
||||||
|
|
||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
KeyNameToLong(const char *name)
|
KeyNameToLong(const char *name)
|
||||||
|
|
Loading…
Reference in New Issue