module/xkb: lock in content, and handle no layout available

This commit is contained in:
Daniel Eklöf 2019-01-13 15:04:18 +01:00
parent 825b0a16f8
commit f04ff31d0f

View file

@ -55,13 +55,26 @@ content(struct module *mod)
{ {
const struct private *m = mod->private; const struct private *m = mod->private;
mtx_lock(&mod->lock);
const char *name = "";
const char *symbol = "";
if (m->current < m->layouts.count) {
name = m->layouts.layouts[m->current].name;
symbol = m->layouts.layouts[m->current].symbol;
}
struct tag_set tags = { struct tag_set tags = {
.tags = (struct tag *[]){ .tags = (struct tag *[]){
tag_new_string(mod, "name", m->layouts.layouts[m->current].name), tag_new_string(mod, "name", name),
tag_new_string(mod, "symbol", m->layouts.layouts[m->current].symbol)}, tag_new_string(mod, "symbol", symbol),
},
.count = 2, .count = 2,
}; };
mtx_unlock(&mod->lock);
struct exposable *exposable = m->label->instantiate(m->label, &tags); struct exposable *exposable = m->label->instantiate(m->label, &tags);
tag_set_destroy(&tags); tag_set_destroy(&tags);