Change 'indicator' to 'led' everywhere possible

The code currently uses the two names interchangeably.
Settle on 'led', because it is shorter, more recognizable, and what we
use in our API (though of course the parser still uses 'indicator').

In camel case we make it 'Led'.
We change 'xkb_indicator_map' to just 'xkb_led' and the variables of
this type are 'led'. This mimics 'xkb_key' and 'key'.
IndicatorNameInfo and LEDInfo are changed to 'LedNameInfo' and
'LedInfo', and the variables are 'ledi' (like 'keyi' etc.). This is
instead of 'ii' and 'im'.

This might make a few places a bit confusing, but less than before I
think. It's also shorter.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2013-02-17 22:18:57 +02:00 committed by Daniel Stone
parent 10c351f516
commit 8cee749000
13 changed files with 218 additions and 227 deletions

View File

@ -154,7 +154,7 @@ write_keycodes(struct xkb_keymap *keymap, struct buf *buf)
struct xkb_key *key; struct xkb_key *key;
struct xkb_key_alias *alias; struct xkb_key_alias *alias;
xkb_led_index_t i; xkb_led_index_t i;
const struct xkb_indicator_map *im; const struct xkb_led *led;
if (keymap->keycodes_section_name) if (keymap->keycodes_section_name)
write_buf(buf, "\txkb_keycodes \"%s\" {\n", write_buf(buf, "\txkb_keycodes \"%s\" {\n",
@ -170,10 +170,10 @@ write_keycodes(struct xkb_keymap *keymap, struct buf *buf)
KeyNameText(keymap->ctx, key->name), key->keycode); KeyNameText(keymap->ctx, key->name), key->keycode);
} }
darray_enumerate(i, im, keymap->indicators) darray_enumerate(i, led, keymap->leds)
if (im->name != XKB_ATOM_NONE) if (led->name != XKB_ATOM_NONE)
write_buf(buf, "\t\tindicator %d = \"%s\";\n", write_buf(buf, "\t\tindicator %d = \"%s\";\n",
i + 1, xkb_atom_text(keymap->ctx, im->name)); i + 1, xkb_atom_text(keymap->ctx, led->name));
darray_foreach(alias, keymap->key_aliases) darray_foreach(alias, keymap->key_aliases)
@ -248,8 +248,8 @@ write_types(struct xkb_keymap *keymap, struct buf *buf)
} }
static bool static bool
write_indicator_map(struct xkb_keymap *keymap, struct buf *buf, write_led_map(struct xkb_keymap *keymap, struct buf *buf,
const struct xkb_indicator_map *led) const struct xkb_led *led)
{ {
write_buf(buf, "\t\tindicator \"%s\" {\n", write_buf(buf, "\t\tindicator \"%s\" {\n",
xkb_atom_text(keymap->ctx, led->name)); xkb_atom_text(keymap->ctx, led->name));
@ -257,7 +257,7 @@ write_indicator_map(struct xkb_keymap *keymap, struct buf *buf,
if (led->which_groups) { if (led->which_groups) {
if (led->which_groups != XKB_STATE_LAYOUT_EFFECTIVE) { if (led->which_groups != XKB_STATE_LAYOUT_EFFECTIVE) {
write_buf(buf, "\t\t\twhichGroupState= %s;\n", write_buf(buf, "\t\t\twhichGroupState= %s;\n",
IndicatorStateText(keymap->ctx, led->which_groups)); LedStateText(keymap->ctx, led->which_groups));
} }
write_buf(buf, "\t\t\tgroups= 0x%02x;\n", write_buf(buf, "\t\t\tgroups= 0x%02x;\n",
led->groups); led->groups);
@ -266,7 +266,7 @@ write_indicator_map(struct xkb_keymap *keymap, struct buf *buf,
if (led->which_mods) { if (led->which_mods) {
if (led->which_mods != XKB_STATE_MODS_EFFECTIVE) { if (led->which_mods != XKB_STATE_MODS_EFFECTIVE) {
write_buf(buf, "\t\t\twhichModState= %s;\n", write_buf(buf, "\t\t\twhichModState= %s;\n",
IndicatorStateText(keymap->ctx, led->which_mods)); LedStateText(keymap->ctx, led->which_mods));
} }
write_buf(buf, "\t\t\tmodifiers= %s;\n", write_buf(buf, "\t\t\tmodifiers= %s;\n",
ModMaskText(keymap, led->mods.mods)); ModMaskText(keymap, led->mods.mods));
@ -425,7 +425,7 @@ static bool
write_compat(struct xkb_keymap *keymap, struct buf *buf) write_compat(struct xkb_keymap *keymap, struct buf *buf)
{ {
struct xkb_sym_interpret *interp; struct xkb_sym_interpret *interp;
const struct xkb_indicator_map *led; const struct xkb_led *led;
if (keymap->compat_section_name) if (keymap->compat_section_name)
write_buf(buf, "\txkb_compatibility \"%s\" {\n\n", write_buf(buf, "\txkb_compatibility \"%s\" {\n\n",
@ -464,10 +464,10 @@ write_compat(struct xkb_keymap *keymap, struct buf *buf)
write_buf(buf, "\t\t};\n"); write_buf(buf, "\t\t};\n");
} }
darray_foreach(led, keymap->indicators) darray_foreach(led, keymap->leds)
if (led->which_groups || led->groups || led->which_mods || if (led->which_groups || led->groups || led->which_mods ||
led->mods.mods || led->ctrls) led->mods.mods || led->ctrls)
write_indicator_map(keymap, buf, led); write_led_map(keymap, buf, led);
write_buf(buf, "\t};\n\n"); write_buf(buf, "\t};\n\n");

View File

@ -110,7 +110,7 @@ xkb_keymap_unref(struct xkb_keymap *keymap)
darray_free(keymap->key_aliases); darray_free(keymap->key_aliases);
free(keymap->group_names); free(keymap->group_names);
darray_free(keymap->mods); darray_free(keymap->mods);
darray_free(keymap->indicators); darray_free(keymap->leds);
free(keymap->keycodes_section_name); free(keymap->keycodes_section_name);
free(keymap->symbols_section_name); free(keymap->symbols_section_name);
free(keymap->types_section_name); free(keymap->types_section_name);
@ -242,7 +242,7 @@ xkb_keymap_num_levels_for_key(struct xkb_keymap *keymap, xkb_keycode_t kc,
XKB_EXPORT xkb_led_index_t XKB_EXPORT xkb_led_index_t
xkb_keymap_num_leds(struct xkb_keymap *keymap) xkb_keymap_num_leds(struct xkb_keymap *keymap)
{ {
return darray_size(keymap->indicators); return darray_size(keymap->leds);
} }
/** /**
@ -251,11 +251,10 @@ xkb_keymap_num_leds(struct xkb_keymap *keymap)
XKB_EXPORT const char * XKB_EXPORT const char *
xkb_keymap_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx) xkb_keymap_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx)
{ {
if (idx >= darray_size(keymap->indicators)) if (idx >= darray_size(keymap->leds))
return NULL; return NULL;
return xkb_atom_text(keymap->ctx, return xkb_atom_text(keymap->ctx, darray_item(keymap->leds, idx).name);
darray_item(keymap->indicators, idx).name);
} }
/** /**
@ -266,12 +265,12 @@ xkb_keymap_led_get_index(struct xkb_keymap *keymap, const char *name)
{ {
xkb_atom_t atom = xkb_atom_lookup(keymap->ctx, name); xkb_atom_t atom = xkb_atom_lookup(keymap->ctx, name);
xkb_led_index_t i; xkb_led_index_t i;
const struct xkb_indicator_map *led; const struct xkb_led *led;
if (atom == XKB_ATOM_NONE) if (atom == XKB_ATOM_NONE)
return XKB_LED_INVALID; return XKB_LED_INVALID;
darray_enumerate(i, led, keymap->indicators) darray_enumerate(i, led, keymap->leds)
if (led->name == atom) if (led->name == atom)
return i; return i;

View File

@ -281,7 +281,7 @@ struct xkb_sym_interpret {
bool repeat; bool repeat;
}; };
struct xkb_indicator_map { struct xkb_led {
xkb_atom_t name; xkb_atom_t name;
enum xkb_state_component which_groups; enum xkb_state_component which_groups;
xkb_layout_mask_t groups; xkb_layout_mask_t groups;
@ -395,7 +395,7 @@ struct xkb_keymap {
xkb_layout_index_t num_group_names; xkb_layout_index_t num_group_names;
xkb_atom_t *group_names; xkb_atom_t *group_names;
darray(struct xkb_indicator_map) indicators; darray(struct xkb_led) leds;
char *keycodes_section_name; char *keycodes_section_name;
char *symbols_section_name; char *symbols_section_name;

View File

@ -614,39 +614,39 @@ xkb_state_get_keymap(struct xkb_state *state)
static void static void
xkb_state_led_update_all(struct xkb_state *state) xkb_state_led_update_all(struct xkb_state *state)
{ {
xkb_led_index_t led; xkb_led_index_t idx;
const struct xkb_indicator_map *map; const struct xkb_led *led;
state->components.leds = 0; state->components.leds = 0;
darray_enumerate(led, map, state->keymap->indicators) { darray_enumerate(idx, led, state->keymap->leds) {
xkb_mod_mask_t mod_mask = 0; xkb_mod_mask_t mod_mask = 0;
xkb_layout_mask_t group_mask = 0; xkb_layout_mask_t group_mask = 0;
if (map->which_mods & XKB_STATE_MODS_EFFECTIVE) if (led->which_mods & XKB_STATE_MODS_EFFECTIVE)
mod_mask |= state->components.mods; mod_mask |= state->components.mods;
if (map->which_mods & XKB_STATE_MODS_DEPRESSED) if (led->which_mods & XKB_STATE_MODS_DEPRESSED)
mod_mask |= state->components.base_mods; mod_mask |= state->components.base_mods;
if (map->which_mods & XKB_STATE_MODS_LATCHED) if (led->which_mods & XKB_STATE_MODS_LATCHED)
mod_mask |= state->components.latched_mods; mod_mask |= state->components.latched_mods;
if (map->which_mods & XKB_STATE_MODS_LOCKED) if (led->which_mods & XKB_STATE_MODS_LOCKED)
mod_mask |= state->components.locked_mods; mod_mask |= state->components.locked_mods;
if (map->mods.mask & mod_mask) if (led->mods.mask & mod_mask)
state->components.leds |= (1 << led); state->components.leds |= (1 << idx);
if (map->which_groups & XKB_STATE_LAYOUT_EFFECTIVE) if (led->which_groups & XKB_STATE_LAYOUT_EFFECTIVE)
group_mask |= (1 << state->components.group); group_mask |= (1 << state->components.group);
if (map->which_groups & XKB_STATE_LAYOUT_DEPRESSED) if (led->which_groups & XKB_STATE_LAYOUT_DEPRESSED)
group_mask |= (1 << state->components.base_group); group_mask |= (1 << state->components.base_group);
if (map->which_groups & XKB_STATE_LAYOUT_LATCHED) if (led->which_groups & XKB_STATE_LAYOUT_LATCHED)
group_mask |= (1 << state->components.latched_group); group_mask |= (1 << state->components.latched_group);
if (map->which_groups & XKB_STATE_LAYOUT_LOCKED) if (led->which_groups & XKB_STATE_LAYOUT_LOCKED)
group_mask |= (1 << state->components.locked_group); group_mask |= (1 << state->components.locked_group);
if (map->groups & group_mask) if (led->groups & group_mask)
state->components.leds |= (1 << led); state->components.leds |= (1 << idx);
if (map->ctrls & state->keymap->enabled_ctrls) if (led->ctrls & state->keymap->enabled_ctrls)
state->components.leds |= (1 << led); state->components.leds |= (1 << idx);
} }
} }
@ -1059,8 +1059,8 @@ xkb_state_layout_name_is_active(struct xkb_state *state, const char *name,
XKB_EXPORT int XKB_EXPORT int
xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx) xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
{ {
if (idx >= darray_size(state->keymap->indicators) || if (idx >= darray_size(state->keymap->leds) ||
darray_item(state->keymap->indicators, idx).name == XKB_ATOM_NONE) darray_item(state->keymap->leds, idx).name == XKB_ATOM_NONE)
return -1; return -1;
return !!(state->components.leds & (1 << idx)); return !!(state->components.leds & (1 << idx));

View File

@ -318,7 +318,7 @@ SIMatchText(enum xkb_match_operation type)
} while (0) } while (0)
const char * const char *
IndicatorStateText(struct xkb_context *ctx, enum xkb_state_component mask) LedStateText(struct xkb_context *ctx, enum xkb_state_component mask)
{ {
unsigned int i; unsigned int i;
char *ret; char *ret;

View File

@ -70,7 +70,7 @@ const char *
SIMatchText(enum xkb_match_operation type); SIMatchText(enum xkb_match_operation type);
const char * const char *
IndicatorStateText(struct xkb_context *ctx, enum xkb_state_component mask); LedStateText(struct xkb_context *ctx, enum xkb_state_component mask);
const char * const char *
ControlMaskText(struct xkb_context *ctx, enum xkb_action_controls mask); ControlMaskText(struct xkb_context *ctx, enum xkb_action_controls mask);

View File

@ -273,14 +273,14 @@ ModMapCreate(uint32_t modifier, ExprDef * keys)
return def; return def;
} }
IndicatorMapDef * LedMapDef *
IndicatorMapCreate(xkb_atom_t name, VarDef * body) LedMapCreate(xkb_atom_t name, VarDef * body)
{ {
IndicatorMapDef *def; LedMapDef *def;
def = malloc_or_die(sizeof(*def)); def = malloc_or_die(sizeof(*def));
def->common.type = STMT_INDICATOR_MAP; def->common.type = STMT_LED_MAP;
def->common.next = NULL; def->common.next = NULL;
def->merge = MERGE_DEFAULT; def->merge = MERGE_DEFAULT;
def->name = name; def->name = name;
@ -288,14 +288,14 @@ IndicatorMapCreate(xkb_atom_t name, VarDef * body)
return def; return def;
} }
IndicatorNameDef * LedNameDef *
IndicatorNameCreate(int ndx, ExprDef * name, bool virtual) LedNameCreate(int ndx, ExprDef * name, bool virtual)
{ {
IndicatorNameDef *def; LedNameDef *def;
def = malloc_or_die(sizeof(*def)); def = malloc_or_die(sizeof(*def));
def->common.type = STMT_INDICATOR_NAME; def->common.type = STMT_LED_NAME;
def->common.next = NULL; def->common.next = NULL;
def->merge = MERGE_DEFAULT; def->merge = MERGE_DEFAULT;
def->ndx = ndx; def->ndx = ndx;
@ -639,10 +639,10 @@ FreeStmt(ParseCommon *stmt)
case STMT_GROUP_COMPAT: case STMT_GROUP_COMPAT:
FreeStmt(&u.groupCompat->def->common); FreeStmt(&u.groupCompat->def->common);
break; break;
case STMT_INDICATOR_MAP: case STMT_LED_MAP:
FreeStmt(&u.ledMap->body->common); FreeStmt(&u.ledMap->body->common);
break; break;
case STMT_INDICATOR_NAME: case STMT_LED_NAME:
FreeStmt(&u.ledName->name->common); FreeStmt(&u.ledName->name->common);
break; break;
default: default:
@ -717,8 +717,8 @@ static const char *stmt_type_strings[_STMT_NUM_VALUES] = {
[STMT_SYMBOLS] = "key symbols definition", [STMT_SYMBOLS] = "key symbols definition",
[STMT_MODMAP] = "modifier map declaration", [STMT_MODMAP] = "modifier map declaration",
[STMT_GROUP_COMPAT] = "group declaration", [STMT_GROUP_COMPAT] = "group declaration",
[STMT_INDICATOR_MAP] = "indicator map declaration", [STMT_LED_MAP] = "indicator map declaration",
[STMT_INDICATOR_NAME] = "indicator name declaration", [STMT_LED_NAME] = "indicator name declaration",
}; };
const char * const char *

View File

@ -70,11 +70,11 @@ GroupCompatCreate(int group, ExprDef *def);
ModMapDef * ModMapDef *
ModMapCreate(uint32_t modifier, ExprDef *keys); ModMapCreate(uint32_t modifier, ExprDef *keys);
IndicatorMapDef * LedMapDef *
IndicatorMapCreate(xkb_atom_t name, VarDef *body); LedMapCreate(xkb_atom_t name, VarDef *body);
IndicatorNameDef * LedNameDef *
IndicatorNameCreate(int ndx, ExprDef *name, bool virtual); LedNameCreate(int ndx, ExprDef *name, bool virtual);
ExprDef * ExprDef *
ActionCreate(xkb_atom_t name, ExprDef *args); ActionCreate(xkb_atom_t name, ExprDef *args);

View File

@ -85,8 +85,8 @@ enum stmt_type {
STMT_SYMBOLS, STMT_SYMBOLS,
STMT_MODMAP, STMT_MODMAP,
STMT_GROUP_COMPAT, STMT_GROUP_COMPAT,
STMT_INDICATOR_MAP, STMT_LED_MAP,
STMT_INDICATOR_NAME, STMT_LED_NAME,
_STMT_NUM_VALUES _STMT_NUM_VALUES
}; };
@ -263,14 +263,14 @@ typedef struct {
int ndx; int ndx;
ExprDef *name; ExprDef *name;
bool virtual; bool virtual;
} IndicatorNameDef; } LedNameDef;
typedef struct { typedef struct {
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
xkb_atom_t name; xkb_atom_t name;
VarDef *body; VarDef *body;
} IndicatorMapDef; } LedMapDef;
enum xkb_map_flags { enum xkb_map_flags {
MAP_IS_DEFAULT = (1 << 0), MAP_IS_DEFAULT = (1 << 0),

View File

@ -149,19 +149,19 @@
* *
* Set whether the key should repeat or not. Must be a boolean value. * Set whether the key should repeat or not. Must be a boolean value.
* *
* Indicator map statements * Led map statements
* ------------------------ * ------------------------
* Statements of the form: * Statements of the form:
* indicator "Shift Lock" { ... } * indicator "Shift Lock" { ... }
* *
* This statement specifies the behavior and binding of the indicator * This statement specifies the behavior and binding of the LED (a.k.a
* with the given name ("Shift Lock" above). The name should have been * indicator) with the given name ("Shift Lock" above). The name should
* declared previously in the xkb_keycodes section (see Indicator name * have been declared previously in the xkb_keycodes section (see Led
* statement), and given an index there. If it wasn't, it is created * name statement), and given an index there. If it wasn't, it is created
* with the next free index. * with the next free index.
* The body of the statement describes the conditions of the keyboard * The body of the statement describes the conditions of the keyboard
* state which will cause the indicator to be lit. It may include the * state which will cause the LED to be lit. It may include the following
* following statements: * statements:
* *
* - modifiers statment: * - modifiers statment:
* modifiers = ScrollLock; * modifiers = ScrollLock;
@ -186,8 +186,8 @@
* modifiers = NumLock; * modifiers = NumLock;
* whichModState = Locked; * whichModState = Locked;
* }; * };
* Whenever the NumLock modifier is locked, the Num Lock indicator * Whenever the NumLock modifier is locked, the Num Lock LED will light
* will light up. * up.
* *
* - groups statment: * - groups statment:
* groups = All - group1; * groups = All - group1;
@ -222,7 +222,7 @@
* After all of the xkb_compat sections have been compiled, the following * After all of the xkb_compat sections have been compiled, the following
* members of struct xkb_keymap are finalized: * members of struct xkb_keymap are finalized:
* darray(struct xkb_sym_interpret) sym_interprets; * darray(struct xkb_sym_interpret) sym_interprets;
* darray(struct xkb_indicator_map) indicators; * darray(struct xkb_led) leds;
* char *compat_section_name; * char *compat_section_name;
* TODO: virtual modifiers. * TODO: virtual modifiers.
*/ */
@ -253,8 +253,8 @@ typedef struct {
unsigned file_id; unsigned file_id;
enum merge_mode merge; enum merge_mode merge;
struct xkb_indicator_map im; struct xkb_led led;
} LEDInfo; } LedInfo;
typedef struct { typedef struct {
char *name; char *name;
@ -262,8 +262,8 @@ typedef struct {
int errorCount; int errorCount;
SymInterpInfo dflt; SymInterpInfo dflt;
darray(SymInterpInfo) interps; darray(SymInterpInfo) interps;
LEDInfo ledDflt; LedInfo ledDflt;
darray(LEDInfo) leds; darray(LedInfo) leds;
ActionsInfo *actions; ActionsInfo *actions;
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
} CompatInfo; } CompatInfo;
@ -300,20 +300,19 @@ ReportSIBadType(CompatInfo *info, SymInterpInfo *si, const char *field,
} }
static inline bool static inline bool
ReportIndicatorBadType(CompatInfo *info, LEDInfo *led, ReportLedBadType(CompatInfo *info, LedInfo *ledi, const char *field,
const char *field, const char *wanted) const char *wanted)
{ {
return ReportBadType(info->keymap->ctx, "indicator map", field, return ReportBadType(info->keymap->ctx, "indicator map", field,
xkb_atom_text(info->keymap->ctx, led->im.name), xkb_atom_text(info->keymap->ctx, ledi->led.name),
wanted); wanted);
} }
static inline bool static inline bool
ReportIndicatorNotArray(CompatInfo *info, LEDInfo *led, ReportLedNotArray(CompatInfo *info, LedInfo *ledi, const char *field)
const char *field)
{ {
return ReportNotArray(info->keymap, "indicator map", field, return ReportNotArray(info->keymap, "indicator map", field,
xkb_atom_text(info->keymap->ctx, led->im.name)); xkb_atom_text(info->keymap->ctx, ledi->led.name));
} }
static void static void
@ -469,7 +468,7 @@ ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn,
/***====================================================================***/ /***====================================================================***/
static bool static bool
UseNewLEDField(enum led_field field, LEDInfo *old, LEDInfo *new, UseNewLEDField(enum led_field field, LedInfo *old, LedInfo *new,
bool report, enum led_field *collide) bool report, enum led_field *collide)
{ {
if (!(old->defined & field)) if (!(old->defined & field))
@ -487,9 +486,9 @@ UseNewLEDField(enum led_field field, LEDInfo *old, LEDInfo *new,
} }
static bool static bool
AddIndicatorMap(CompatInfo *info, LEDInfo *new) AddLedMap(CompatInfo *info, LedInfo *new)
{ {
LEDInfo *old; LedInfo *old;
enum led_field collide; enum led_field collide;
struct xkb_context *ctx = info->keymap->ctx; struct xkb_context *ctx = info->keymap->ctx;
int verbosity = xkb_context_get_log_verbosity(ctx); int verbosity = xkb_context_get_log_verbosity(ctx);
@ -497,14 +496,14 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new)
darray_foreach(old, info->leds) { darray_foreach(old, info->leds) {
bool report; bool report;
if (old->im.name != new->im.name) if (old->led.name != new->led.name)
continue; continue;
if (old->im.mods.mods == new->im.mods.mods && if (old->led.mods.mods == new->led.mods.mods &&
old->im.groups == new->im.groups && old->led.groups == new->led.groups &&
old->im.ctrls == new->im.ctrls && old->led.ctrls == new->led.ctrls &&
old->im.which_mods == new->im.which_mods && old->led.which_mods == new->led.which_mods &&
old->im.which_groups == new->im.which_groups) { old->led.which_groups == new->led.which_groups) {
old->defined |= new->defined; old->defined |= new->defined;
return true; return true;
} }
@ -517,24 +516,24 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new)
log_warn(info->keymap->ctx, log_warn(info->keymap->ctx,
"Map for indicator %s redefined; " "Map for indicator %s redefined; "
"Earlier definition ignored\n", "Earlier definition ignored\n",
xkb_atom_text(ctx, old->im.name)); xkb_atom_text(ctx, old->led.name));
*old = *new; *old = *new;
return true; return true;
} }
collide = 0; collide = 0;
if (UseNewLEDField(LED_FIELD_MODS, old, new, report, &collide)) { if (UseNewLEDField(LED_FIELD_MODS, old, new, report, &collide)) {
old->im.which_mods = new->im.which_mods; old->led.which_mods = new->led.which_mods;
old->im.mods = new->im.mods; old->led.mods = new->led.mods;
old->defined |= LED_FIELD_MODS; old->defined |= LED_FIELD_MODS;
} }
if (UseNewLEDField(LED_FIELD_GROUPS, old, new, report, &collide)) { if (UseNewLEDField(LED_FIELD_GROUPS, old, new, report, &collide)) {
old->im.which_groups = new->im.which_groups; old->led.which_groups = new->led.which_groups;
old->im.groups = new->im.groups; old->led.groups = new->led.groups;
old->defined |= LED_FIELD_GROUPS; old->defined |= LED_FIELD_GROUPS;
} }
if (UseNewLEDField(LED_FIELD_CTRLS, old, new, report, &collide)) { if (UseNewLEDField(LED_FIELD_CTRLS, old, new, report, &collide)) {
old->im.ctrls = new->im.ctrls; old->led.ctrls = new->led.ctrls;
old->defined |= LED_FIELD_CTRLS; old->defined |= LED_FIELD_CTRLS;
} }
@ -542,7 +541,7 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new)
log_warn(info->keymap->ctx, log_warn(info->keymap->ctx,
"Map for indicator %s redefined; " "Map for indicator %s redefined; "
"Using %s definition for duplicate fields\n", "Using %s definition for duplicate fields\n",
xkb_atom_text(ctx, old->im.name), xkb_atom_text(ctx, old->led.name),
(new->merge == MERGE_AUGMENT ? "first" : "last")); (new->merge == MERGE_AUGMENT ? "first" : "last"));
} }
@ -558,7 +557,7 @@ MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
enum merge_mode merge) enum merge_mode merge)
{ {
SymInterpInfo *si; SymInterpInfo *si;
LEDInfo *led; LedInfo *ledi;
if (from->errorCount > 0) { if (from->errorCount > 0) {
into->errorCount += from->errorCount; into->errorCount += from->errorCount;
@ -576,9 +575,9 @@ MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
into->errorCount++; into->errorCount++;
} }
darray_foreach(led, from->leds) { darray_foreach(ledi, from->leds) {
led->merge = (merge == MERGE_DEFAULT ? led->merge : merge); ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge);
if (!AddIndicatorMap(into, led)) if (!AddLedMap(into, ledi))
into->errorCount++; into->errorCount++;
} }
} }
@ -697,45 +696,44 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
} }
static bool static bool
SetIndicatorMapField(CompatInfo *info, LEDInfo *led, SetLedMapField(CompatInfo *info, LedInfo *ledi, const char *field,
const char *field, ExprDef *arrayNdx, ExprDef *value) ExprDef *arrayNdx, ExprDef *value)
{ {
bool ok = true; bool ok = true;
struct xkb_keymap *keymap = info->keymap; struct xkb_keymap *keymap = info->keymap;
if (istreq(field, "modifiers") || istreq(field, "mods")) { if (istreq(field, "modifiers") || istreq(field, "mods")) {
if (arrayNdx) if (arrayNdx)
return ReportIndicatorNotArray(info, led, field); return ReportLedNotArray(info, ledi, field);
if (!ExprResolveModMask(keymap, value, MOD_BOTH, &led->im.mods.mods)) if (!ExprResolveModMask(keymap, value, MOD_BOTH, &ledi->led.mods.mods))
return ReportIndicatorBadType(info, led, field, "modifier mask"); return ReportLedBadType(info, ledi, field, "modifier mask");
led->defined |= LED_FIELD_MODS; ledi->defined |= LED_FIELD_MODS;
} }
else if (istreq(field, "groups")) { else if (istreq(field, "groups")) {
unsigned int mask; unsigned int mask;
if (arrayNdx) if (arrayNdx)
return ReportIndicatorNotArray(info, led, field); return ReportLedNotArray(info, ledi, field);
if (!ExprResolveMask(keymap->ctx, value, &mask, groupMaskNames)) if (!ExprResolveMask(keymap->ctx, value, &mask, groupMaskNames))
return ReportIndicatorBadType(info, led, field, "group mask"); return ReportLedBadType(info, ledi, field, "group mask");
led->im.groups = mask; ledi->led.groups = mask;
led->defined |= LED_FIELD_GROUPS; ledi->defined |= LED_FIELD_GROUPS;
} }
else if (istreq(field, "controls") || istreq(field, "ctrls")) { else if (istreq(field, "controls") || istreq(field, "ctrls")) {
unsigned int mask; unsigned int mask;
if (arrayNdx) if (arrayNdx)
return ReportIndicatorNotArray(info, led, field); return ReportLedNotArray(info, ledi, field);
if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames)) if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
return ReportIndicatorBadType(info, led, field, return ReportLedBadType(info, ledi, field, "controls mask");
"controls mask");
led->im.ctrls = mask; ledi->led.ctrls = mask;
led->defined |= LED_FIELD_CTRLS; ledi->defined |= LED_FIELD_CTRLS;
} }
else if (istreq(field, "allowexplicit")) { else if (istreq(field, "allowexplicit")) {
log_dbg(info->keymap->ctx, log_dbg(info->keymap->ctx,
@ -747,27 +745,27 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
unsigned int mask; unsigned int mask;
if (arrayNdx) if (arrayNdx)
return ReportIndicatorNotArray(info, led, field); return ReportLedNotArray(info, ledi, field);
if (!ExprResolveMask(keymap->ctx, value, &mask, if (!ExprResolveMask(keymap->ctx, value, &mask,
modComponentMaskNames)) modComponentMaskNames))
return ReportIndicatorBadType(info, led, field, return ReportLedBadType(info, ledi, field,
"mask of modifier state components"); "mask of modifier state components");
led->im.which_mods = mask; ledi->led.which_mods = mask;
} }
else if (istreq(field, "whichgroupstate")) { else if (istreq(field, "whichgroupstate")) {
unsigned mask; unsigned mask;
if (arrayNdx) if (arrayNdx)
return ReportIndicatorNotArray(info, led, field); return ReportLedNotArray(info, ledi, field);
if (!ExprResolveMask(keymap->ctx, value, &mask, if (!ExprResolveMask(keymap->ctx, value, &mask,
groupComponentMaskNames)) groupComponentMaskNames))
return ReportIndicatorBadType(info, led, field, return ReportLedBadType(info, ledi, field,
"mask of group state components"); "mask of group state components");
led->im.which_groups = mask; ledi->led.which_groups = mask;
} }
else if (istreq(field, "driveskbd") || else if (istreq(field, "driveskbd") ||
istreq(field, "driveskeyboard") || istreq(field, "driveskeyboard") ||
@ -789,7 +787,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
log_err(info->keymap->ctx, log_err(info->keymap->ctx,
"Unknown field %s in map for %s indicator; " "Unknown field %s in map for %s indicator; "
"Definition ignored\n", "Definition ignored\n",
field, xkb_atom_text(keymap->ctx, led->im.name)); field, xkb_atom_text(keymap->ctx, ledi->led.name));
ok = false; ok = false;
} }
@ -808,8 +806,7 @@ HandleGlobalVar(CompatInfo *info, VarDef *stmt)
else if (elem && istreq(elem, "interpret")) else if (elem && istreq(elem, "interpret"))
ret = SetInterpField(info, &info->dflt, field, ndx, stmt->value); ret = SetInterpField(info, &info->dflt, field, ndx, stmt->value);
else if (elem && istreq(elem, "indicator")) else if (elem && istreq(elem, "indicator"))
ret = SetIndicatorMapField(info, &info->ledDflt, field, ndx, ret = SetLedMapField(info, &info->ledDflt, field, ndx, stmt->value);
stmt->value);
else else
ret = SetActionField(info->keymap, elem, field, ndx, stmt->value, ret = SetActionField(info->keymap, elem, field, ndx, stmt->value,
info->actions); info->actions);
@ -885,19 +882,18 @@ HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge)
} }
static bool static bool
HandleIndicatorMapDef(CompatInfo *info, IndicatorMapDef *def, HandleLedMapDef(CompatInfo *info, LedMapDef *def, enum merge_mode merge)
enum merge_mode merge)
{ {
LEDInfo led; LedInfo ledi;
VarDef *var; VarDef *var;
bool ok; bool ok;
if (def->merge != MERGE_DEFAULT) if (def->merge != MERGE_DEFAULT)
merge = def->merge; merge = def->merge;
led = info->ledDflt; ledi = info->ledDflt;
led.merge = merge; ledi.merge = merge;
led.im.name = def->name; ledi.led.name = def->name;
ok = true; ok = true;
for (var = def->body; var != NULL; var = (VarDef *) var->common.next) { for (var = def->body; var != NULL; var = (VarDef *) var->common.next) {
@ -916,13 +912,12 @@ HandleIndicatorMapDef(CompatInfo *info, IndicatorMapDef *def,
ok = false; ok = false;
} }
else { else {
ok = SetIndicatorMapField(info, &led, field, arrayNdx, ok = SetLedMapField(info, &ledi, field, arrayNdx, var->value) && ok;
var->value) && ok;
} }
} }
if (ok) if (ok)
return AddIndicatorMap(info, &led); return AddLedMap(info, &ledi);
return false; return false;
} }
@ -952,8 +947,8 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
"Ignored\n"); "Ignored\n");
ok = true; ok = true;
break; break;
case STMT_INDICATOR_MAP: case STMT_LED_MAP:
ok = HandleIndicatorMapDef(info, (IndicatorMapDef *) stmt, merge); ok = HandleLedMapDef(info, (LedMapDef *) stmt, merge);
break; break;
case STMT_VAR: case STMT_VAR:
ok = HandleGlobalVar(info, (VarDef *) stmt); ok = HandleGlobalVar(info, (VarDef *) stmt);
@ -992,54 +987,54 @@ CopyInterps(CompatInfo *info, bool needSymbol, enum xkb_match_operation pred)
} }
static void static void
CopyIndicatorMapDefs(CompatInfo *info) CopyLedMapDefs(CompatInfo *info)
{ {
LEDInfo *led; LedInfo *ledi;
xkb_led_index_t i; xkb_led_index_t i;
struct xkb_indicator_map *im; struct xkb_led *led;
struct xkb_keymap *keymap = info->keymap; struct xkb_keymap *keymap = info->keymap;
darray_foreach(led, info->leds) { darray_foreach(ledi, info->leds) {
/* /*
* Find the indicator with the given name, if it was already * Find the LED with the given name, if it was already declared
* declared in keycodes. * in keycodes.
*/ */
darray_enumerate(i, im, keymap->indicators) darray_enumerate(i, led, keymap->leds)
if (im->name == led->im.name) if (led->name == ledi->led.name)
break; break;
/* Not previously declared; create it with next free index. */ /* Not previously declared; create it with next free index. */
if (i >= darray_size(keymap->indicators)) { if (i >= darray_size(keymap->leds)) {
log_dbg(keymap->ctx, log_dbg(keymap->ctx,
"Indicator name \"%s\" was not declared in the keycodes section; " "Indicator name \"%s\" was not declared in the keycodes section; "
"Adding new indicator\n", "Adding new indicator\n",
xkb_atom_text(keymap->ctx, led->im.name)); xkb_atom_text(keymap->ctx, ledi->led.name));
darray_enumerate(i, im, keymap->indicators) darray_enumerate(i, led, keymap->leds)
if (im->name == XKB_ATOM_NONE) if (led->name == XKB_ATOM_NONE)
break; break;
if (i >= darray_size(keymap->indicators)) { if (i >= darray_size(keymap->leds)) {
/* Not place to put it; ignore. */ /* Not place to put it; ignore. */
if (i >= XKB_MAX_LEDS) { if (i >= XKB_MAX_LEDS) {
log_err(keymap->ctx, log_err(keymap->ctx,
"Too many indicators (maximum is %d); " "Too many indicators (maximum is %d); "
"Indicator name \"%s\" ignored\n", "Indicator name \"%s\" ignored\n",
XKB_MAX_LEDS, XKB_MAX_LEDS,
xkb_atom_text(keymap->ctx, led->im.name)); xkb_atom_text(keymap->ctx, ledi->led.name));
continue; continue;
} }
/* Add a new indicator. */ /* Add a new LED. */
darray_resize(keymap->indicators, i + 1); darray_resize(keymap->leds, i + 1);
im = &darray_item(keymap->indicators, i); led = &darray_item(keymap->leds, i);
} }
} }
*im = led->im; *led = ledi->led;
if (im->groups != 0 && im->which_groups == 0) if (led->groups != 0 && led->which_groups == 0)
im->which_groups = XKB_STATE_LAYOUT_EFFECTIVE; led->which_groups = XKB_STATE_LAYOUT_EFFECTIVE;
if (im->mods.mods != 0 && im->which_mods == 0) if (led->mods.mods != 0 && led->which_mods == 0)
im->which_mods = XKB_STATE_MODS_EFFECTIVE; led->which_mods = XKB_STATE_MODS_EFFECTIVE;
} }
} }
@ -1062,7 +1057,7 @@ CopyCompatToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
CopyInterps(info, false, MATCH_ANY_OR_NONE); CopyInterps(info, false, MATCH_ANY_OR_NONE);
} }
CopyIndicatorMapDefs(info); CopyLedMapDefs(info);
return true; return true;
} }

View File

@ -74,16 +74,15 @@
* Allows to refer to a previously defined key (here <COMP>) by another * Allows to refer to a previously defined key (here <COMP>) by another
* name (here <MENU>). Conflicts are handled similarly. * name (here <MENU>). Conflicts are handled similarly.
* *
* Indicator name statements * LED name statements
* ------------------------- * -------------------------
* Statements of the form: * Statements of the form:
* indicator 1 = "Caps Lock"; * indicator 1 = "Caps Lock";
* indicator 2 = "Num Lock"; * indicator 2 = "Num Lock";
* indicator 3 = "Scroll Lock"; * indicator 3 = "Scroll Lock";
* *
* Assigns a name the indicator (i.e. keyboard LED) with the given index. * Assigns a name to the keyboard LED (a.k.a indicator) with the given index.
* The amount of possible indicators is predetermined (XKB_NUM_INDICATORS). * The led may be referred by this name later in the compat section
* The indicator may be referred by this name later in the compat section
* and by the user. * and by the user.
* *
* Effect on the keymap * Effect on the keymap
@ -94,8 +93,8 @@
* xkb_keycode_t max_key_code; * xkb_keycode_t max_key_code;
* darray(struct xkb_key_alias) key_aliases; * darray(struct xkb_key_alias) key_aliases;
* char *keycodes_section_name; * char *keycodes_section_name;
* The 'name' field of indicators declared in xkb_keycodes: * The 'name' field of leds declared in xkb_keycodes:
* darray(struct xkb_indicator_map) indicators; * darray(struct xkb_led) leds;
* Further, the array of keys: * Further, the array of keys:
* struct xkb_key *keys; * struct xkb_key *keys;
* had been resized to its final size (i.e. all of the xkb_key objects are * had been resized to its final size (i.e. all of the xkb_key objects are
@ -121,7 +120,7 @@ typedef struct {
unsigned file_id; unsigned file_id;
xkb_atom_t name; xkb_atom_t name;
} IndicatorNameInfo; } LedNameInfo;
typedef struct { typedef struct {
char *name; /* e.g. evdev+aliases(qwerty) */ char *name; /* e.g. evdev+aliases(qwerty) */
@ -132,7 +131,7 @@ typedef struct {
xkb_keycode_t min_key_code; xkb_keycode_t min_key_code;
xkb_keycode_t max_key_code; xkb_keycode_t max_key_code;
darray(KeyNameInfo) key_names; darray(KeyNameInfo) key_names;
darray(IndicatorNameInfo) indicator_names; darray(LedNameInfo) led_names;
darray(AliasInfo) aliases; darray(AliasInfo) aliases;
struct xkb_context *ctx; struct xkb_context *ctx;
@ -149,17 +148,17 @@ InitAliasInfo(AliasInfo *info, enum merge_mode merge, unsigned file_id,
info->real = real; info->real = real;
} }
static IndicatorNameInfo * static LedNameInfo *
FindIndicatorByName(KeyNamesInfo *info, xkb_atom_t name, FindLedByName(KeyNamesInfo *info, xkb_atom_t name,
xkb_led_index_t *idx_out) xkb_led_index_t *idx_out)
{ {
IndicatorNameInfo *led; LedNameInfo *ledi;
xkb_led_index_t idx; xkb_led_index_t idx;
darray_enumerate(idx, led, info->indicator_names) { darray_enumerate(idx, ledi, info->led_names) {
if (led->name == name) { if (ledi->name == name) {
*idx_out = idx; *idx_out = idx;
return led; return ledi;
} }
} }
@ -167,21 +166,20 @@ FindIndicatorByName(KeyNamesInfo *info, xkb_atom_t name,
} }
static bool static bool
AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge, AddLedName(KeyNamesInfo *info, enum merge_mode merge,
IndicatorNameInfo *new, xkb_led_index_t new_idx) LedNameInfo *new, xkb_led_index_t new_idx)
{ {
xkb_led_index_t old_idx; xkb_led_index_t old_idx;
IndicatorNameInfo *old; LedNameInfo *old;
bool replace; const bool replace = (merge == MERGE_REPLACE || merge == MERGE_OVERRIDE);
int verbosity = xkb_context_get_log_verbosity(info->ctx); int verbosity = xkb_context_get_log_verbosity(info->ctx);
replace = (merge == MERGE_REPLACE || merge == MERGE_OVERRIDE);
/* Inidicator with the same name already exists. */ /* Inidicator with the same name already exists. */
old = FindIndicatorByName(info, new->name, &old_idx); old = FindLedByName(info, new->name, &old_idx);
if (old) { if (old) {
bool report = ((old->file_id == new->file_id && verbosity > 0) || const bool report = ((old->file_id == new->file_id && verbosity > 0) ||
verbosity > 9); verbosity > 9);
if (old_idx == new_idx) { if (old_idx == new_idx) {
log_warn(info->ctx, log_warn(info->ctx,
@ -205,11 +203,11 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
return true; return true;
} }
if (new_idx >= darray_size(info->indicator_names)) if (new_idx >= darray_size(info->led_names))
darray_resize0(info->indicator_names, new_idx + 1); darray_resize0(info->led_names, new_idx + 1);
/* Inidicator with the same index already exists. */ /* Inidicator with the same index already exists. */
old = &darray_item(info->indicator_names, new_idx); old = &darray_item(info->led_names, new_idx);
if (old->name != XKB_ATOM_NONE) { if (old->name != XKB_ATOM_NONE) {
bool report = ((old->file_id == new->file_id && verbosity > 0) || bool report = ((old->file_id == new->file_id && verbosity > 0) ||
verbosity > 9); verbosity > 9);
@ -217,8 +215,8 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
/* Same name case already handled above. */ /* Same name case already handled above. */
if (report) { if (report) {
xkb_atom_t use = (replace ? new->name : old->name); const xkb_atom_t use = (replace ? new->name : old->name);
xkb_atom_t ignore = (replace ? old->name : new->name); const xkb_atom_t ignore = (replace ? old->name : new->name);
log_warn(info->ctx, "Multiple names for indicator %d; " log_warn(info->ctx, "Multiple names for indicator %d; "
"Using %s, ignoring %s\n", new_idx + 1, "Using %s, ignoring %s\n", new_idx + 1,
xkb_atom_text(info->ctx, use), xkb_atom_text(info->ctx, use),
@ -231,7 +229,7 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
return true; return true;
} }
darray_item(info->indicator_names, new_idx) = *new; darray_item(info->led_names, new_idx) = *new;
return true; return true;
} }
@ -241,7 +239,7 @@ ClearKeyNamesInfo(KeyNamesInfo *info)
free(info->name); free(info->name);
darray_free(info->key_names); darray_free(info->key_names);
darray_free(info->aliases); darray_free(info->aliases);
darray_free(info->indicator_names); darray_free(info->led_names);
} }
static void static void
@ -382,7 +380,7 @@ MergeIncludedKeycodes(KeyNamesInfo *into, KeyNamesInfo *from,
{ {
xkb_keycode_t i; xkb_keycode_t i;
xkb_led_index_t idx; xkb_led_index_t idx;
IndicatorNameInfo *led; LedNameInfo *ledi;
if (from->errorCount > 0) { if (from->errorCount > 0) {
into->errorCount += from->errorCount; into->errorCount += from->errorCount;
@ -406,12 +404,12 @@ MergeIncludedKeycodes(KeyNamesInfo *into, KeyNamesInfo *from,
into->errorCount++; into->errorCount++;
} }
darray_enumerate(idx, led, from->indicator_names) { darray_enumerate(idx, ledi, from->led_names) {
if (led->name == XKB_ATOM_NONE) if (ledi->name == XKB_ATOM_NONE)
continue; continue;
led->merge = (merge == MERGE_DEFAULT ? led->merge : merge); ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge);
if (!AddIndicatorName(into, led->merge, led, idx)) if (!AddLedName(into, ledi->merge, ledi, idx))
into->errorCount++; into->errorCount++;
} }
@ -560,10 +558,10 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
} }
static int static int
HandleIndicatorNameDef(KeyNamesInfo *info, IndicatorNameDef *def, HandleLedNameDef(KeyNamesInfo *info, LedNameDef *def,
enum merge_mode merge) enum merge_mode merge)
{ {
IndicatorNameInfo ii; LedNameInfo ledi;
xkb_atom_t name; xkb_atom_t name;
if (def->ndx < 1 || def->ndx > XKB_MAX_LEDS) { if (def->ndx < 1 || def->ndx > XKB_MAX_LEDS) {
@ -582,10 +580,10 @@ HandleIndicatorNameDef(KeyNamesInfo *info, IndicatorNameDef *def,
"string"); "string");
} }
ii.merge = info->merge; ledi.merge = info->merge;
ii.file_id = info->file_id; ledi.file_id = info->file_id;
ii.name = name; ledi.name = name;
return AddIndicatorName(info, merge, &ii, def->ndx - 1); return AddLedName(info, merge, &ledi, def->ndx - 1);
} }
static void static void
@ -612,9 +610,8 @@ HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge)
case STMT_VAR: case STMT_VAR:
ok = HandleKeyNameVar(info, (VarDef *) stmt); ok = HandleKeyNameVar(info, (VarDef *) stmt);
break; break;
case STMT_INDICATOR_NAME: case STMT_LED_NAME:
ok = HandleIndicatorNameDef(info, (IndicatorNameDef *) stmt, ok = HandleLedNameDef(info, (LedNameDef *) stmt, merge);
merge);
break; break;
default: default:
log_err(info->ctx, log_err(info->ctx,
@ -694,7 +691,7 @@ CopyKeyNamesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info)
{ {
xkb_keycode_t kc; xkb_keycode_t kc;
xkb_led_index_t idx; xkb_led_index_t idx;
IndicatorNameInfo *led; LedNameInfo *ledi;
keymap->keys = calloc(info->max_key_code + 1, sizeof(*keymap->keys)); keymap->keys = calloc(info->max_key_code + 1, sizeof(*keymap->keys));
if (!keymap->keys) if (!keymap->keys)
@ -710,12 +707,12 @@ CopyKeyNamesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info)
keymap->keycodes_section_name = strdup_safe(info->name); keymap->keycodes_section_name = strdup_safe(info->name);
darray_resize0(keymap->indicators, darray_size(info->indicator_names)); darray_resize0(keymap->leds, darray_size(info->led_names));
darray_enumerate(idx, led, info->indicator_names) { darray_enumerate(idx, ledi, info->led_names) {
if (led->name == XKB_ATOM_NONE) if (ledi->name == XKB_ATOM_NONE)
continue; continue;
darray_item(keymap->indicators, idx).name = led->name; darray_item(keymap->leds, idx).name = ledi->name;
} }
ApplyAliases(info, keymap); ApplyAliases(info, keymap);

View File

@ -180,7 +180,7 @@ static bool
UpdateDerivedKeymapFields(struct xkb_keymap *keymap) UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
{ {
struct xkb_mod *mod; struct xkb_mod *mod;
struct xkb_indicator_map *im; struct xkb_led *led;
unsigned int i, j; unsigned int i, j;
struct xkb_key *key; struct xkb_key *key;
@ -213,9 +213,9 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
UpdateActionMods(keymap, &key->groups[i].levels[j].action, UpdateActionMods(keymap, &key->groups[i].levels[j].action,
key->modmap); key->modmap);
/* Update vmod -> indicator maps. */ /* Update vmod -> led maps. */
darray_foreach(im, keymap->indicators) darray_foreach(led, keymap->leds)
ComputeEffectiveMask(keymap, &im->mods); ComputeEffectiveMask(keymap, &led->mods);
/* Find maximum number of groups out of all keys in the keymap. */ /* Find maximum number of groups out of all keys in the keymap. */
xkb_foreach_key(key, keymap) xkb_foreach_key(key, keymap)

View File

@ -142,8 +142,8 @@ _xkbcommon_error(struct YYLTYPE *loc, struct parser_param *param, const char *ms
SymbolsDef *syms; SymbolsDef *syms;
ModMapDef *modMask; ModMapDef *modMask;
GroupCompatDef *groupCompat; GroupCompatDef *groupCompat;
IndicatorMapDef *ledMap; LedMapDef *ledMap;
IndicatorNameDef *ledName; LedNameDef *ledName;
KeycodeDef *keyCode; KeycodeDef *keyCode;
KeyAliasDef *keyAlias; KeyAliasDef *keyAlias;
void *geom; void *geom;
@ -171,8 +171,8 @@ _xkbcommon_error(struct YYLTYPE *loc, struct parser_param *param, const char *ms
%type <syms> SymbolsDecl %type <syms> SymbolsDecl
%type <modMask> ModMapDecl %type <modMask> ModMapDecl
%type <groupCompat> GroupCompatDecl %type <groupCompat> GroupCompatDecl
%type <ledMap> IndicatorMapDecl %type <ledMap> LedMapDecl
%type <ledName> IndicatorNameDecl %type <ledName> LedNameDecl
%type <keyCode> KeyNameDecl %type <keyCode> KeyNameDecl
%type <keyAlias> KeyAliasDecl %type <keyAlias> KeyAliasDecl
%type <geom> ShapeDecl SectionDecl SectionBody SectionBodyItem RowBody RowBodyItem %type <geom> ShapeDecl SectionDecl SectionBody SectionBodyItem RowBody RowBodyItem
@ -315,12 +315,12 @@ Decl : OptMergeMode VarDecl
$2->merge = $1; $2->merge = $1;
$$ = &$2->common; $$ = &$2->common;
} }
| OptMergeMode IndicatorMapDecl | OptMergeMode LedMapDecl
{ {
$2->merge = $1; $2->merge = $1;
$$ = &$2->common; $$ = &$2->common;
} }
| OptMergeMode IndicatorNameDecl | OptMergeMode LedNameDecl
{ {
$2->merge = $1; $2->merge = $1;
$$ = &$2->common; $$ = &$2->common;
@ -425,14 +425,14 @@ ModMapDecl : MODIFIER_MAP Ident OBRACE ExprList CBRACE SEMI
{ $$ = ModMapCreate($2, $4); } { $$ = ModMapCreate($2, $4); }
; ;
IndicatorMapDecl: INDICATOR String OBRACE VarDeclList CBRACE SEMI LedMapDecl: INDICATOR String OBRACE VarDeclList CBRACE SEMI
{ $$ = IndicatorMapCreate($2, $4); } { $$ = LedMapCreate($2, $4); }
; ;
IndicatorNameDecl: INDICATOR Integer EQUALS Expr SEMI LedNameDecl: INDICATOR Integer EQUALS Expr SEMI
{ $$ = IndicatorNameCreate($2, $4, false); } { $$ = LedNameCreate($2, $4, false); }
| VIRTUAL INDICATOR Integer EQUALS Expr SEMI | VIRTUAL INDICATOR Integer EQUALS Expr SEMI
{ $$ = IndicatorNameCreate($3, $5, true); } { $$ = LedNameCreate($3, $5, true); }
; ;
ShapeDecl : SHAPE String OBRACE OutlineList CBRACE SEMI ShapeDecl : SHAPE String OBRACE OutlineList CBRACE SEMI
@ -455,7 +455,7 @@ SectionBodyItem : ROW OBRACE RowBody CBRACE SEMI
{ FreeStmt(&$1->common); $$ = NULL; } { FreeStmt(&$1->common); $$ = NULL; }
| DoodadDecl | DoodadDecl
{ $$ = NULL; } { $$ = NULL; }
| IndicatorMapDecl | LedMapDecl
{ FreeStmt(&$1->common); $$ = NULL; } { FreeStmt(&$1->common); $$ = NULL; }
| OverlayDecl | OverlayDecl
{ $$ = NULL; } { $$ = NULL; }