Make BindIndicators static
Since BindIndicators was only ever called immediately after CopyIndicatorMapDefs, move it up in the file and turn it into a static function, which avoids the need to ever pass the unbound LEDs around. Signed-off-by: Daniel Stone <daniel@fooishbar.org>master
parent
d38d16e113
commit
b10f924b0c
|
@ -784,7 +784,6 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge
|
|||
int i;
|
||||
CompatInfo info;
|
||||
GroupCompatInfo *gcm;
|
||||
LEDInfo *unbound = NULL;
|
||||
|
||||
InitCompatInfo(&info, keymap);
|
||||
info.dflt.defs.merge = merge;
|
||||
|
@ -820,13 +819,11 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge
|
|||
}
|
||||
|
||||
if (info.leds != NULL) {
|
||||
if (!CopyIndicatorMapDefs(keymap, info.leds, &unbound))
|
||||
if (!CopyIndicatorMapDefs(keymap, info.leds))
|
||||
info.errorCount++;
|
||||
info.leds = NULL;
|
||||
}
|
||||
|
||||
BindIndicators(keymap, unbound);
|
||||
|
||||
ClearCompatInfo(&info, keymap);
|
||||
return true;
|
||||
|
||||
|
|
|
@ -360,79 +360,7 @@ HandleIndicatorMapDef(IndicatorMapDef *def, struct xkb_keymap *keymap,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds,
|
||||
LEDInfo **unboundRtrn)
|
||||
{
|
||||
LEDInfo *led, *next;
|
||||
LEDInfo *unbound, *last;
|
||||
|
||||
if (XkbcAllocNames(keymap, XkbIndicatorNamesMask, 0) != Success)
|
||||
{
|
||||
WSGO("Couldn't allocate names\n");
|
||||
ACTION("Indicator names may be incorrect\n");
|
||||
}
|
||||
if (XkbcAllocIndicatorMaps(keymap) != Success)
|
||||
{
|
||||
WSGO("Can't allocate indicator maps\n");
|
||||
ACTION("Indicator map definitions may be lost\n");
|
||||
return false;
|
||||
}
|
||||
last = unbound = (unboundRtrn ? *unboundRtrn : NULL);
|
||||
while ((last != NULL) && (last->defs.next != NULL))
|
||||
{
|
||||
last = (LEDInfo *) last->defs.next;
|
||||
}
|
||||
for (led = leds; led != NULL; led = next)
|
||||
{
|
||||
next = (LEDInfo *) led->defs.next;
|
||||
if ((led->groups != 0) && (led->which_groups == 0))
|
||||
led->which_groups = XkbIM_UseEffective;
|
||||
if ((led->which_mods == 0) && ((led->real_mods) || (led->vmods)))
|
||||
led->which_mods = XkbIM_UseEffective;
|
||||
if ((led->indicator == _LED_NotBound) || (!keymap->indicators))
|
||||
{
|
||||
if (unboundRtrn != NULL)
|
||||
{
|
||||
led->defs.next = NULL;
|
||||
if (last != NULL)
|
||||
last->defs.next = (CommonInfo *) led;
|
||||
else
|
||||
unbound = led;
|
||||
last = led;
|
||||
}
|
||||
else
|
||||
free(led);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct xkb_indicator_map * im;
|
||||
im = &keymap->indicators->maps[led->indicator - 1];
|
||||
im->flags = led->flags;
|
||||
im->which_groups = led->which_groups;
|
||||
im->groups = led->groups;
|
||||
im->which_mods = led->which_mods;
|
||||
im->mods.mask = led->real_mods;
|
||||
im->mods.real_mods = led->real_mods;
|
||||
im->mods.vmods = led->vmods;
|
||||
im->ctrls = led->ctrls;
|
||||
if (keymap->names != NULL)
|
||||
{
|
||||
free(keymap->names->indicators[led->indicator - 1]);
|
||||
keymap->names->indicators[led->indicator-1] =
|
||||
xkb_atom_strdup(keymap->ctx, led->name);
|
||||
}
|
||||
free(led);
|
||||
}
|
||||
}
|
||||
if (unboundRtrn != NULL)
|
||||
{
|
||||
*unboundRtrn = unbound;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
BindIndicators(struct xkb_keymap *keymap, LEDInfo *unbound)
|
||||
{
|
||||
int i;
|
||||
|
@ -532,3 +460,64 @@ BindIndicators(struct xkb_keymap *keymap, LEDInfo *unbound)
|
|||
free(led);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
|
||||
{
|
||||
LEDInfo *led, *next;
|
||||
LEDInfo *unbound = NULL, *last = NULL;
|
||||
|
||||
if (XkbcAllocNames(keymap, XkbIndicatorNamesMask, 0) != Success)
|
||||
{
|
||||
WSGO("Couldn't allocate names\n");
|
||||
ACTION("Indicator names may be incorrect\n");
|
||||
}
|
||||
if (XkbcAllocIndicatorMaps(keymap) != Success)
|
||||
{
|
||||
WSGO("Can't allocate indicator maps\n");
|
||||
ACTION("Indicator map definitions may be lost\n");
|
||||
return false;
|
||||
}
|
||||
for (led = leds; led != NULL; led = next)
|
||||
{
|
||||
next = (LEDInfo *) led->defs.next;
|
||||
if ((led->groups != 0) && (led->which_groups == 0))
|
||||
led->which_groups = XkbIM_UseEffective;
|
||||
if ((led->which_mods == 0) && ((led->real_mods) || (led->vmods)))
|
||||
led->which_mods = XkbIM_UseEffective;
|
||||
if ((led->indicator == _LED_NotBound) || (!keymap->indicators))
|
||||
{
|
||||
led->defs.next = NULL;
|
||||
if (last != NULL)
|
||||
last->defs.next = (CommonInfo *) led;
|
||||
else
|
||||
unbound = led;
|
||||
last = led;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct xkb_indicator_map * im;
|
||||
im = &keymap->indicators->maps[led->indicator - 1];
|
||||
im->flags = led->flags;
|
||||
im->which_groups = led->which_groups;
|
||||
im->groups = led->groups;
|
||||
im->which_mods = led->which_mods;
|
||||
im->mods.mask = led->real_mods;
|
||||
im->mods.real_mods = led->real_mods;
|
||||
im->mods.vmods = led->vmods;
|
||||
im->ctrls = led->ctrls;
|
||||
if (keymap->names != NULL)
|
||||
{
|
||||
free(keymap->names->indicators[led->indicator - 1]);
|
||||
keymap->names->indicators[led->indicator-1] =
|
||||
xkb_atom_strdup(keymap->ctx, led->name);
|
||||
}
|
||||
free(led);
|
||||
}
|
||||
}
|
||||
|
||||
if (unbound)
|
||||
BindIndicators(keymap, unbound);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -69,10 +69,5 @@ HandleIndicatorMapDef(IndicatorMapDef *stmt, struct xkb_keymap *keymap,
|
|||
LEDInfo *dflt, LEDInfo *oldLEDs, enum merge_mode mergeMode);
|
||||
|
||||
extern bool
|
||||
CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds,
|
||||
LEDInfo **unboundRtrn);
|
||||
|
||||
extern void
|
||||
BindIndicators(struct xkb_keymap *keymap, LEDInfo *unbound);
|
||||
|
||||
CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds);
|
||||
#endif /* INDICATORS_H */
|
||||
|
|
Loading…
Reference in New Issue