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>
struct xkb_key *key;
struct xkb_key_alias *alias;
xkb_led_index_t i;
- const struct xkb_indicator_map *im;
+ const struct xkb_led *led;
if (keymap->keycodes_section_name)
write_buf(buf, "\txkb_keycodes \"%s\" {\n",
KeyNameText(keymap->ctx, key->name), key->keycode);
}
- darray_enumerate(i, im, keymap->indicators)
- if (im->name != XKB_ATOM_NONE)
+ darray_enumerate(i, led, keymap->leds)
+ if (led->name != XKB_ATOM_NONE)
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)
}
static bool
-write_indicator_map(struct xkb_keymap *keymap, struct buf *buf,
- const struct xkb_indicator_map *led)
+write_led_map(struct xkb_keymap *keymap, struct buf *buf,
+ const struct xkb_led *led)
{
write_buf(buf, "\t\tindicator \"%s\" {\n",
xkb_atom_text(keymap->ctx, led->name));
if (led->which_groups) {
if (led->which_groups != XKB_STATE_LAYOUT_EFFECTIVE) {
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",
led->groups);
if (led->which_mods) {
if (led->which_mods != XKB_STATE_MODS_EFFECTIVE) {
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",
ModMaskText(keymap, led->mods.mods));
write_compat(struct xkb_keymap *keymap, struct buf *buf)
{
struct xkb_sym_interpret *interp;
- const struct xkb_indicator_map *led;
+ const struct xkb_led *led;
if (keymap->compat_section_name)
write_buf(buf, "\txkb_compatibility \"%s\" {\n\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 ||
led->mods.mods || led->ctrls)
- write_indicator_map(keymap, buf, led);
+ write_led_map(keymap, buf, led);
write_buf(buf, "\t};\n\n");
darray_free(keymap->key_aliases);
free(keymap->group_names);
darray_free(keymap->mods);
- darray_free(keymap->indicators);
+ darray_free(keymap->leds);
free(keymap->keycodes_section_name);
free(keymap->symbols_section_name);
free(keymap->types_section_name);
XKB_EXPORT xkb_led_index_t
xkb_keymap_num_leds(struct xkb_keymap *keymap)
{
- return darray_size(keymap->indicators);
+ return darray_size(keymap->leds);
}
/**
XKB_EXPORT const char *
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 xkb_atom_text(keymap->ctx,
- darray_item(keymap->indicators, idx).name);
+ return xkb_atom_text(keymap->ctx, darray_item(keymap->leds, idx).name);
}
/**
{
xkb_atom_t atom = xkb_atom_lookup(keymap->ctx, name);
xkb_led_index_t i;
- const struct xkb_indicator_map *led;
+ const struct xkb_led *led;
if (atom == XKB_ATOM_NONE)
return XKB_LED_INVALID;
- darray_enumerate(i, led, keymap->indicators)
+ darray_enumerate(i, led, keymap->leds)
if (led->name == atom)
return i;
bool repeat;
};
-struct xkb_indicator_map {
+struct xkb_led {
xkb_atom_t name;
enum xkb_state_component which_groups;
xkb_layout_mask_t groups;
xkb_layout_index_t num_group_names;
xkb_atom_t *group_names;
- darray(struct xkb_indicator_map) indicators;
+ darray(struct xkb_led) leds;
char *keycodes_section_name;
char *symbols_section_name;
static void
xkb_state_led_update_all(struct xkb_state *state)
{
- xkb_led_index_t led;
- const struct xkb_indicator_map *map;
+ xkb_led_index_t idx;
+ const struct xkb_led *led;
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_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;
- if (map->which_mods & XKB_STATE_MODS_DEPRESSED)
+ if (led->which_mods & XKB_STATE_MODS_DEPRESSED)
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;
- if (map->which_mods & XKB_STATE_MODS_LOCKED)
+ if (led->which_mods & XKB_STATE_MODS_LOCKED)
mod_mask |= state->components.locked_mods;
- if (map->mods.mask & mod_mask)
- state->components.leds |= (1 << led);
+ if (led->mods.mask & mod_mask)
+ 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);
- if (map->which_groups & XKB_STATE_LAYOUT_DEPRESSED)
+ if (led->which_groups & XKB_STATE_LAYOUT_DEPRESSED)
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);
- if (map->which_groups & XKB_STATE_LAYOUT_LOCKED)
+ if (led->which_groups & XKB_STATE_LAYOUT_LOCKED)
group_mask |= (1 << state->components.locked_group);
- if (map->groups & group_mask)
- state->components.leds |= (1 << led);
+ if (led->groups & group_mask)
+ state->components.leds |= (1 << idx);
- if (map->ctrls & state->keymap->enabled_ctrls)
- state->components.leds |= (1 << led);
+ if (led->ctrls & state->keymap->enabled_ctrls)
+ state->components.leds |= (1 << idx);
}
}
XKB_EXPORT int
xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
{
- if (idx >= darray_size(state->keymap->indicators) ||
- darray_item(state->keymap->indicators, idx).name == XKB_ATOM_NONE)
+ if (idx >= darray_size(state->keymap->leds) ||
+ darray_item(state->keymap->leds, idx).name == XKB_ATOM_NONE)
return -1;
return !!(state->components.leds & (1 << idx));
} while (0)
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;
char *ret;
SIMatchText(enum xkb_match_operation type);
const char *
-IndicatorStateText(struct xkb_context *ctx, enum xkb_state_component mask);
+LedStateText(struct xkb_context *ctx, enum xkb_state_component mask);
const char *
ControlMaskText(struct xkb_context *ctx, enum xkb_action_controls mask);
return def;
}
-IndicatorMapDef *
-IndicatorMapCreate(xkb_atom_t name, VarDef * body)
+LedMapDef *
+LedMapCreate(xkb_atom_t name, VarDef * body)
{
- IndicatorMapDef *def;
+ LedMapDef *def;
def = malloc_or_die(sizeof(*def));
- def->common.type = STMT_INDICATOR_MAP;
+ def->common.type = STMT_LED_MAP;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->name = name;
return def;
}
-IndicatorNameDef *
-IndicatorNameCreate(int ndx, ExprDef * name, bool virtual)
+LedNameDef *
+LedNameCreate(int ndx, ExprDef * name, bool virtual)
{
- IndicatorNameDef *def;
+ LedNameDef *def;
def = malloc_or_die(sizeof(*def));
- def->common.type = STMT_INDICATOR_NAME;
+ def->common.type = STMT_LED_NAME;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->ndx = ndx;
case STMT_GROUP_COMPAT:
FreeStmt(&u.groupCompat->def->common);
break;
- case STMT_INDICATOR_MAP:
+ case STMT_LED_MAP:
FreeStmt(&u.ledMap->body->common);
break;
- case STMT_INDICATOR_NAME:
+ case STMT_LED_NAME:
FreeStmt(&u.ledName->name->common);
break;
default:
[STMT_SYMBOLS] = "key symbols definition",
[STMT_MODMAP] = "modifier map declaration",
[STMT_GROUP_COMPAT] = "group declaration",
- [STMT_INDICATOR_MAP] = "indicator map declaration",
- [STMT_INDICATOR_NAME] = "indicator name declaration",
+ [STMT_LED_MAP] = "indicator map declaration",
+ [STMT_LED_NAME] = "indicator name declaration",
};
const char *
ModMapDef *
ModMapCreate(uint32_t modifier, ExprDef *keys);
-IndicatorMapDef *
-IndicatorMapCreate(xkb_atom_t name, VarDef *body);
+LedMapDef *
+LedMapCreate(xkb_atom_t name, VarDef *body);
-IndicatorNameDef *
-IndicatorNameCreate(int ndx, ExprDef *name, bool virtual);
+LedNameDef *
+LedNameCreate(int ndx, ExprDef *name, bool virtual);
ExprDef *
ActionCreate(xkb_atom_t name, ExprDef *args);
STMT_SYMBOLS,
STMT_MODMAP,
STMT_GROUP_COMPAT,
- STMT_INDICATOR_MAP,
- STMT_INDICATOR_NAME,
+ STMT_LED_MAP,
+ STMT_LED_NAME,
_STMT_NUM_VALUES
};
int ndx;
ExprDef *name;
bool virtual;
-} IndicatorNameDef;
+} LedNameDef;
typedef struct {
ParseCommon common;
enum merge_mode merge;
xkb_atom_t name;
VarDef *body;
-} IndicatorMapDef;
+} LedMapDef;
enum xkb_map_flags {
MAP_IS_DEFAULT = (1 << 0),
*
* Set whether the key should repeat or not. Must be a boolean value.
*
- * Indicator map statements
+ * Led map statements
* ------------------------
* Statements of the form:
* indicator "Shift Lock" { ... }
*
- * This statement specifies the behavior and binding of the indicator
- * with the given name ("Shift Lock" above). The name should have been
- * declared previously in the xkb_keycodes section (see Indicator name
- * statement), and given an index there. If it wasn't, it is created
+ * This statement specifies the behavior and binding of the LED (a.k.a
+ * indicator) with the given name ("Shift Lock" above). The name should
+ * have been declared previously in the xkb_keycodes section (see Led
+ * name statement), and given an index there. If it wasn't, it is created
* with the next free index.
* The body of the statement describes the conditions of the keyboard
- * state which will cause the indicator to be lit. It may include the
- * following statements:
+ * state which will cause the LED to be lit. It may include the following
+ * statements:
*
* - modifiers statment:
* modifiers = ScrollLock;
* modifiers = NumLock;
* whichModState = Locked;
* };
- * Whenever the NumLock modifier is locked, the Num Lock indicator
- * will light up.
+ * Whenever the NumLock modifier is locked, the Num Lock LED will light
+ * up.
*
* - groups statment:
* groups = All - group1;
* After all of the xkb_compat sections have been compiled, the following
* members of struct xkb_keymap are finalized:
* darray(struct xkb_sym_interpret) sym_interprets;
- * darray(struct xkb_indicator_map) indicators;
+ * darray(struct xkb_led) leds;
* char *compat_section_name;
* TODO: virtual modifiers.
*/
unsigned file_id;
enum merge_mode merge;
- struct xkb_indicator_map im;
-} LEDInfo;
+ struct xkb_led led;
+} LedInfo;
typedef struct {
char *name;
int errorCount;
SymInterpInfo dflt;
darray(SymInterpInfo) interps;
- LEDInfo ledDflt;
- darray(LEDInfo) leds;
+ LedInfo ledDflt;
+ darray(LedInfo) leds;
ActionsInfo *actions;
struct xkb_keymap *keymap;
} CompatInfo;
}
static inline bool
-ReportIndicatorBadType(CompatInfo *info, LEDInfo *led,
- const char *field, const char *wanted)
+ReportLedBadType(CompatInfo *info, LedInfo *ledi, const char *field,
+ const char *wanted)
{
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);
}
static inline bool
-ReportIndicatorNotArray(CompatInfo *info, LEDInfo *led,
- const char *field)
+ReportLedNotArray(CompatInfo *info, LedInfo *ledi, const char *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 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)
{
if (!(old->defined & field))
}
static bool
-AddIndicatorMap(CompatInfo *info, LEDInfo *new)
+AddLedMap(CompatInfo *info, LedInfo *new)
{
- LEDInfo *old;
+ LedInfo *old;
enum led_field collide;
struct xkb_context *ctx = info->keymap->ctx;
int verbosity = xkb_context_get_log_verbosity(ctx);
darray_foreach(old, info->leds) {
bool report;
- if (old->im.name != new->im.name)
+ if (old->led.name != new->led.name)
continue;
- if (old->im.mods.mods == new->im.mods.mods &&
- old->im.groups == new->im.groups &&
- old->im.ctrls == new->im.ctrls &&
- old->im.which_mods == new->im.which_mods &&
- old->im.which_groups == new->im.which_groups) {
+ if (old->led.mods.mods == new->led.mods.mods &&
+ old->led.groups == new->led.groups &&
+ old->led.ctrls == new->led.ctrls &&
+ old->led.which_mods == new->led.which_mods &&
+ old->led.which_groups == new->led.which_groups) {
old->defined |= new->defined;
return true;
}
log_warn(info->keymap->ctx,
"Map for indicator %s redefined; "
"Earlier definition ignored\n",
- xkb_atom_text(ctx, old->im.name));
+ xkb_atom_text(ctx, old->led.name));
*old = *new;
return true;
}
collide = 0;
if (UseNewLEDField(LED_FIELD_MODS, old, new, report, &collide)) {
- old->im.which_mods = new->im.which_mods;
- old->im.mods = new->im.mods;
+ old->led.which_mods = new->led.which_mods;
+ old->led.mods = new->led.mods;
old->defined |= LED_FIELD_MODS;
}
if (UseNewLEDField(LED_FIELD_GROUPS, old, new, report, &collide)) {
- old->im.which_groups = new->im.which_groups;
- old->im.groups = new->im.groups;
+ old->led.which_groups = new->led.which_groups;
+ old->led.groups = new->led.groups;
old->defined |= LED_FIELD_GROUPS;
}
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;
}
log_warn(info->keymap->ctx,
"Map for indicator %s redefined; "
"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"));
}
enum merge_mode merge)
{
SymInterpInfo *si;
- LEDInfo *led;
+ LedInfo *ledi;
if (from->errorCount > 0) {
into->errorCount += from->errorCount;
into->errorCount++;
}
- darray_foreach(led, from->leds) {
- led->merge = (merge == MERGE_DEFAULT ? led->merge : merge);
- if (!AddIndicatorMap(into, led))
+ darray_foreach(ledi, from->leds) {
+ ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge);
+ if (!AddLedMap(into, ledi))
into->errorCount++;
}
}
}
static bool
-SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
- const char *field, ExprDef *arrayNdx, ExprDef *value)
+SetLedMapField(CompatInfo *info, LedInfo *ledi, const char *field,
+ ExprDef *arrayNdx, ExprDef *value)
{
bool ok = true;
struct xkb_keymap *keymap = info->keymap;
if (istreq(field, "modifiers") || istreq(field, "mods")) {
if (arrayNdx)
- return ReportIndicatorNotArray(info, led, field);
+ return ReportLedNotArray(info, ledi, field);
- if (!ExprResolveModMask(keymap, value, MOD_BOTH, &led->im.mods.mods))
- return ReportIndicatorBadType(info, led, field, "modifier mask");
+ if (!ExprResolveModMask(keymap, value, MOD_BOTH, &ledi->led.mods.mods))
+ return ReportLedBadType(info, ledi, field, "modifier mask");
- led->defined |= LED_FIELD_MODS;
+ ledi->defined |= LED_FIELD_MODS;
}
else if (istreq(field, "groups")) {
unsigned int mask;
if (arrayNdx)
- return ReportIndicatorNotArray(info, led, field);
+ return ReportLedNotArray(info, ledi, field);
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;
- led->defined |= LED_FIELD_GROUPS;
+ ledi->led.groups = mask;
+ ledi->defined |= LED_FIELD_GROUPS;
}
else if (istreq(field, "controls") || istreq(field, "ctrls")) {
unsigned int mask;
if (arrayNdx)
- return ReportIndicatorNotArray(info, led, field);
+ return ReportLedNotArray(info, ledi, field);
if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
- return ReportIndicatorBadType(info, led, field,
- "controls mask");
+ return ReportLedBadType(info, ledi, field, "controls mask");
- led->im.ctrls = mask;
- led->defined |= LED_FIELD_CTRLS;
+ ledi->led.ctrls = mask;
+ ledi->defined |= LED_FIELD_CTRLS;
}
else if (istreq(field, "allowexplicit")) {
log_dbg(info->keymap->ctx,
unsigned int mask;
if (arrayNdx)
- return ReportIndicatorNotArray(info, led, field);
+ return ReportLedNotArray(info, ledi, field);
if (!ExprResolveMask(keymap->ctx, value, &mask,
modComponentMaskNames))
- return ReportIndicatorBadType(info, led, field,
- "mask of modifier state components");
+ return ReportLedBadType(info, ledi, field,
+ "mask of modifier state components");
- led->im.which_mods = mask;
+ ledi->led.which_mods = mask;
}
else if (istreq(field, "whichgroupstate")) {
unsigned mask;
if (arrayNdx)
- return ReportIndicatorNotArray(info, led, field);
+ return ReportLedNotArray(info, ledi, field);
if (!ExprResolveMask(keymap->ctx, value, &mask,
groupComponentMaskNames))
- return ReportIndicatorBadType(info, led, field,
- "mask of group state components");
+ return ReportLedBadType(info, ledi, field,
+ "mask of group state components");
- led->im.which_groups = mask;
+ ledi->led.which_groups = mask;
}
else if (istreq(field, "driveskbd") ||
istreq(field, "driveskeyboard") ||
log_err(info->keymap->ctx,
"Unknown field %s in map for %s indicator; "
"Definition ignored\n",
- field, xkb_atom_text(keymap->ctx, led->im.name));
+ field, xkb_atom_text(keymap->ctx, ledi->led.name));
ok = false;
}
else if (elem && istreq(elem, "interpret"))
ret = SetInterpField(info, &info->dflt, field, ndx, stmt->value);
else if (elem && istreq(elem, "indicator"))
- ret = SetIndicatorMapField(info, &info->ledDflt, field, ndx,
- stmt->value);
+ ret = SetLedMapField(info, &info->ledDflt, field, ndx, stmt->value);
else
ret = SetActionField(info->keymap, elem, field, ndx, stmt->value,
info->actions);
}
static bool
-HandleIndicatorMapDef(CompatInfo *info, IndicatorMapDef *def,
- enum merge_mode merge)
+HandleLedMapDef(CompatInfo *info, LedMapDef *def, enum merge_mode merge)
{
- LEDInfo led;
+ LedInfo ledi;
VarDef *var;
bool ok;
if (def->merge != MERGE_DEFAULT)
merge = def->merge;
- led = info->ledDflt;
- led.merge = merge;
- led.im.name = def->name;
+ ledi = info->ledDflt;
+ ledi.merge = merge;
+ ledi.led.name = def->name;
ok = true;
for (var = def->body; var != NULL; var = (VarDef *) var->common.next) {
ok = false;
}
else {
- ok = SetIndicatorMapField(info, &led, field, arrayNdx,
- var->value) && ok;
+ ok = SetLedMapField(info, &ledi, field, arrayNdx, var->value) && ok;
}
}
if (ok)
- return AddIndicatorMap(info, &led);
+ return AddLedMap(info, &ledi);
return false;
}
"Ignored\n");
ok = true;
break;
- case STMT_INDICATOR_MAP:
- ok = HandleIndicatorMapDef(info, (IndicatorMapDef *) stmt, merge);
+ case STMT_LED_MAP:
+ ok = HandleLedMapDef(info, (LedMapDef *) stmt, merge);
break;
case STMT_VAR:
ok = HandleGlobalVar(info, (VarDef *) stmt);
}
static void
-CopyIndicatorMapDefs(CompatInfo *info)
+CopyLedMapDefs(CompatInfo *info)
{
- LEDInfo *led;
+ LedInfo *ledi;
xkb_led_index_t i;
- struct xkb_indicator_map *im;
+ struct xkb_led *led;
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
- * declared in keycodes.
+ * Find the LED with the given name, if it was already declared
+ * in keycodes.
*/
- darray_enumerate(i, im, keymap->indicators)
- if (im->name == led->im.name)
+ darray_enumerate(i, led, keymap->leds)
+ if (led->name == ledi->led.name)
break;
/* 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,
"Indicator name \"%s\" was not declared in the keycodes section; "
"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)
- if (im->name == XKB_ATOM_NONE)
+ darray_enumerate(i, led, keymap->leds)
+ if (led->name == XKB_ATOM_NONE)
break;
- if (i >= darray_size(keymap->indicators)) {
+ if (i >= darray_size(keymap->leds)) {
/* Not place to put it; ignore. */
if (i >= XKB_MAX_LEDS) {
log_err(keymap->ctx,
"Too many indicators (maximum is %d); "
"Indicator name \"%s\" ignored\n",
XKB_MAX_LEDS,
- xkb_atom_text(keymap->ctx, led->im.name));
+ xkb_atom_text(keymap->ctx, ledi->led.name));
continue;
}
- /* Add a new indicator. */
- darray_resize(keymap->indicators, i + 1);
- im = &darray_item(keymap->indicators, i);
+ /* Add a new LED. */
+ darray_resize(keymap->leds, i + 1);
+ led = &darray_item(keymap->leds, i);
}
}
- *im = led->im;
- if (im->groups != 0 && im->which_groups == 0)
- im->which_groups = XKB_STATE_LAYOUT_EFFECTIVE;
- if (im->mods.mods != 0 && im->which_mods == 0)
- im->which_mods = XKB_STATE_MODS_EFFECTIVE;
+ *led = ledi->led;
+ if (led->groups != 0 && led->which_groups == 0)
+ led->which_groups = XKB_STATE_LAYOUT_EFFECTIVE;
+ if (led->mods.mods != 0 && led->which_mods == 0)
+ led->which_mods = XKB_STATE_MODS_EFFECTIVE;
}
}
CopyInterps(info, false, MATCH_ANY_OR_NONE);
}
- CopyIndicatorMapDefs(info);
+ CopyLedMapDefs(info);
return true;
}
* Allows to refer to a previously defined key (here <COMP>) by another
* name (here <MENU>). Conflicts are handled similarly.
*
- * Indicator name statements
+ * LED name statements
* -------------------------
* Statements of the form:
* indicator 1 = "Caps Lock";
* indicator 2 = "Num Lock";
* indicator 3 = "Scroll Lock";
*
- * Assigns a name the indicator (i.e. keyboard LED) with the given index.
- * The amount of possible indicators is predetermined (XKB_NUM_INDICATORS).
- * The indicator may be referred by this name later in the compat section
+ * Assigns a name to the keyboard LED (a.k.a indicator) with the given index.
+ * The led may be referred by this name later in the compat section
* and by the user.
*
* Effect on the keymap
* xkb_keycode_t max_key_code;
* darray(struct xkb_key_alias) key_aliases;
* char *keycodes_section_name;
- * The 'name' field of indicators declared in xkb_keycodes:
- * darray(struct xkb_indicator_map) indicators;
+ * The 'name' field of leds declared in xkb_keycodes:
+ * darray(struct xkb_led) leds;
* Further, the array of keys:
* struct xkb_key *keys;
* had been resized to its final size (i.e. all of the xkb_key objects are
unsigned file_id;
xkb_atom_t name;
-} IndicatorNameInfo;
+} LedNameInfo;
typedef struct {
char *name; /* e.g. evdev+aliases(qwerty) */
xkb_keycode_t min_key_code;
xkb_keycode_t max_key_code;
darray(KeyNameInfo) key_names;
- darray(IndicatorNameInfo) indicator_names;
+ darray(LedNameInfo) led_names;
darray(AliasInfo) aliases;
struct xkb_context *ctx;
info->real = real;
}
-static IndicatorNameInfo *
-FindIndicatorByName(KeyNamesInfo *info, xkb_atom_t name,
- xkb_led_index_t *idx_out)
+static LedNameInfo *
+FindLedByName(KeyNamesInfo *info, xkb_atom_t name,
+ xkb_led_index_t *idx_out)
{
- IndicatorNameInfo *led;
+ LedNameInfo *ledi;
xkb_led_index_t idx;
- darray_enumerate(idx, led, info->indicator_names) {
- if (led->name == name) {
+ darray_enumerate(idx, ledi, info->led_names) {
+ if (ledi->name == name) {
*idx_out = idx;
- return led;
+ return ledi;
}
}
}
static bool
-AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
- IndicatorNameInfo *new, xkb_led_index_t new_idx)
+AddLedName(KeyNamesInfo *info, enum merge_mode merge,
+ LedNameInfo *new, xkb_led_index_t new_idx)
{
xkb_led_index_t old_idx;
- IndicatorNameInfo *old;
- bool replace;
+ LedNameInfo *old;
+ const bool replace = (merge == MERGE_REPLACE || merge == MERGE_OVERRIDE);
int verbosity = xkb_context_get_log_verbosity(info->ctx);
- replace = (merge == MERGE_REPLACE || merge == MERGE_OVERRIDE);
/* Inidicator with the same name already exists. */
- old = FindIndicatorByName(info, new->name, &old_idx);
+ old = FindLedByName(info, new->name, &old_idx);
if (old) {
- bool report = ((old->file_id == new->file_id && verbosity > 0) ||
- verbosity > 9);
+ const bool report = ((old->file_id == new->file_id && verbosity > 0) ||
+ verbosity > 9);
if (old_idx == new_idx) {
log_warn(info->ctx,
return true;
}
- if (new_idx >= darray_size(info->indicator_names))
- darray_resize0(info->indicator_names, new_idx + 1);
+ if (new_idx >= darray_size(info->led_names))
+ darray_resize0(info->led_names, new_idx + 1);
/* 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) {
bool report = ((old->file_id == new->file_id && verbosity > 0) ||
verbosity > 9);
/* Same name case already handled above. */
if (report) {
- xkb_atom_t use = (replace ? new->name : old->name);
- xkb_atom_t ignore = (replace ? old->name : new->name);
+ const xkb_atom_t use = (replace ? new->name : old->name);
+ const xkb_atom_t ignore = (replace ? old->name : new->name);
log_warn(info->ctx, "Multiple names for indicator %d; "
"Using %s, ignoring %s\n", new_idx + 1,
xkb_atom_text(info->ctx, use),
return true;
}
- darray_item(info->indicator_names, new_idx) = *new;
+ darray_item(info->led_names, new_idx) = *new;
return true;
}
free(info->name);
darray_free(info->key_names);
darray_free(info->aliases);
- darray_free(info->indicator_names);
+ darray_free(info->led_names);
}
static void
{
xkb_keycode_t i;
xkb_led_index_t idx;
- IndicatorNameInfo *led;
+ LedNameInfo *ledi;
if (from->errorCount > 0) {
into->errorCount += from->errorCount;
into->errorCount++;
}
- darray_enumerate(idx, led, from->indicator_names) {
- if (led->name == XKB_ATOM_NONE)
+ darray_enumerate(idx, ledi, from->led_names) {
+ if (ledi->name == XKB_ATOM_NONE)
continue;
- led->merge = (merge == MERGE_DEFAULT ? led->merge : merge);
- if (!AddIndicatorName(into, led->merge, led, idx))
+ ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge);
+ if (!AddLedName(into, ledi->merge, ledi, idx))
into->errorCount++;
}
}
static int
-HandleIndicatorNameDef(KeyNamesInfo *info, IndicatorNameDef *def,
- enum merge_mode merge)
+HandleLedNameDef(KeyNamesInfo *info, LedNameDef *def,
+ enum merge_mode merge)
{
- IndicatorNameInfo ii;
+ LedNameInfo ledi;
xkb_atom_t name;
if (def->ndx < 1 || def->ndx > XKB_MAX_LEDS) {
"string");
}
- ii.merge = info->merge;
- ii.file_id = info->file_id;
- ii.name = name;
- return AddIndicatorName(info, merge, &ii, def->ndx - 1);
+ ledi.merge = info->merge;
+ ledi.file_id = info->file_id;
+ ledi.name = name;
+ return AddLedName(info, merge, &ledi, def->ndx - 1);
}
static void
case STMT_VAR:
ok = HandleKeyNameVar(info, (VarDef *) stmt);
break;
- case STMT_INDICATOR_NAME:
- ok = HandleIndicatorNameDef(info, (IndicatorNameDef *) stmt,
- merge);
+ case STMT_LED_NAME:
+ ok = HandleLedNameDef(info, (LedNameDef *) stmt, merge);
break;
default:
log_err(info->ctx,
{
xkb_keycode_t kc;
xkb_led_index_t idx;
- IndicatorNameInfo *led;
+ LedNameInfo *ledi;
keymap->keys = calloc(info->max_key_code + 1, sizeof(*keymap->keys));
if (!keymap->keys)
keymap->keycodes_section_name = strdup_safe(info->name);
- darray_resize0(keymap->indicators, darray_size(info->indicator_names));
- darray_enumerate(idx, led, info->indicator_names) {
- if (led->name == XKB_ATOM_NONE)
+ darray_resize0(keymap->leds, darray_size(info->led_names));
+ darray_enumerate(idx, ledi, info->led_names) {
+ if (ledi->name == XKB_ATOM_NONE)
continue;
- darray_item(keymap->indicators, idx).name = led->name;
+ darray_item(keymap->leds, idx).name = ledi->name;
}
ApplyAliases(info, keymap);
UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
{
struct xkb_mod *mod;
- struct xkb_indicator_map *im;
+ struct xkb_led *led;
unsigned int i, j;
struct xkb_key *key;
UpdateActionMods(keymap, &key->groups[i].levels[j].action,
key->modmap);
- /* Update vmod -> indicator maps. */
- darray_foreach(im, keymap->indicators)
- ComputeEffectiveMask(keymap, &im->mods);
+ /* Update vmod -> led maps. */
+ darray_foreach(led, keymap->leds)
+ ComputeEffectiveMask(keymap, &led->mods);
/* Find maximum number of groups out of all keys in the keymap. */
xkb_foreach_key(key, keymap)
SymbolsDef *syms;
ModMapDef *modMask;
GroupCompatDef *groupCompat;
- IndicatorMapDef *ledMap;
- IndicatorNameDef *ledName;
+ LedMapDef *ledMap;
+ LedNameDef *ledName;
KeycodeDef *keyCode;
KeyAliasDef *keyAlias;
void *geom;
%type <syms> SymbolsDecl
%type <modMask> ModMapDecl
%type <groupCompat> GroupCompatDecl
-%type <ledMap> IndicatorMapDecl
-%type <ledName> IndicatorNameDecl
+%type <ledMap> LedMapDecl
+%type <ledName> LedNameDecl
%type <keyCode> KeyNameDecl
%type <keyAlias> KeyAliasDecl
%type <geom> ShapeDecl SectionDecl SectionBody SectionBodyItem RowBody RowBodyItem
$2->merge = $1;
$$ = &$2->common;
}
- | OptMergeMode IndicatorMapDecl
+ | OptMergeMode LedMapDecl
{
$2->merge = $1;
$$ = &$2->common;
}
- | OptMergeMode IndicatorNameDecl
+ | OptMergeMode LedNameDecl
{
$2->merge = $1;
$$ = &$2->common;
{ $$ = ModMapCreate($2, $4); }
;
-IndicatorMapDecl: INDICATOR String OBRACE VarDeclList CBRACE SEMI
- { $$ = IndicatorMapCreate($2, $4); }
+LedMapDecl: INDICATOR String OBRACE VarDeclList CBRACE SEMI
+ { $$ = LedMapCreate($2, $4); }
;
-IndicatorNameDecl: INDICATOR Integer EQUALS Expr SEMI
- { $$ = IndicatorNameCreate($2, $4, false); }
+LedNameDecl: INDICATOR Integer EQUALS Expr SEMI
+ { $$ = LedNameCreate($2, $4, false); }
| VIRTUAL INDICATOR Integer EQUALS Expr SEMI
- { $$ = IndicatorNameCreate($3, $5, true); }
+ { $$ = LedNameCreate($3, $5, true); }
;
ShapeDecl : SHAPE String OBRACE OutlineList CBRACE SEMI
{ FreeStmt(&$1->common); $$ = NULL; }
| DoodadDecl
{ $$ = NULL; }
- | IndicatorMapDecl
+ | LedMapDecl
{ FreeStmt(&$1->common); $$ = NULL; }
| OverlayDecl
{ $$ = NULL; }