state: light indicator when either condition is satisfied For the indicator to be set, it is sufficient for at least one of the group, modifier, or control state to match; this is in line with the xkblib spec, section 8.2 and ComputeAutoState() in xserver/xkb/xkbLEDs.c (though the xserver implementation differs from the spec on some points...). This also adds a tiny optimization to skip the entire check if the mask is empty. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
diff --git a/src/state.c b/src/state.c
index fdccb00..0f93cc7 100644
--- a/src/state.c
+++ b/src/state.c
@@ -538,13 +538,13 @@ xkb_state_led_update_all(struct xkb_state *state)
for (led = 0; led < XkbNumIndicators; led++) {
struct xkb_indicator_map *map = &state->keymap->indicators[led];
- uint32_t mod_mask = 0;
+ xkb_mod_mask_t mod_mask = 0;
uint32_t group_mask = 0;
if (!map->which_mods && !map->which_groups && !map->ctrls)
continue;
- if (map->which_mods) {
+ if (map->which_mods & XkbIM_UseAnyMods) {
if (map->which_mods & XkbIM_UseBase)
mod_mask |= state->base_mods;
if (map->which_mods & XkbIM_UseLatched)
@@ -556,7 +556,7 @@ xkb_state_led_update_all(struct xkb_state *state)
if ((map->mods.mask & mod_mask))
state->leds |= (1 << led);
}
- else if (map->which_groups) {
+ if (map->which_groups & XkbIM_UseAnyGroup) {
if (map->which_groups & XkbIM_UseBase)
group_mask |= (1 << state->base_group);
if (map->which_groups & XkbIM_UseLatched)
@@ -568,7 +568,7 @@ xkb_state_led_update_all(struct xkb_state *state)
if ((map->groups & group_mask))
state->leds |= (1 << led);
}
- else if (map->ctrls) {
+ if (map->ctrls) {
if ((map->ctrls & state->keymap->enabled_ctrls))
state->leds |= (1 << led);
}