From f04ff31d0f53c5f7db4294ba54098e345a21d3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 13 Jan 2019 15:04:18 +0100 Subject: [PATCH] module/xkb: lock in content, and handle no layout available --- modules/xkb.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/xkb.c b/modules/xkb.c index f91e51d..d7c0a7c 100644 --- a/modules/xkb.c +++ b/modules/xkb.c @@ -55,13 +55,26 @@ content(struct module *mod) { 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 = { .tags = (struct tag *[]){ - tag_new_string(mod, "name", m->layouts.layouts[m->current].name), - tag_new_string(mod, "symbol", m->layouts.layouts[m->current].symbol)}, + tag_new_string(mod, "name", name), + tag_new_string(mod, "symbol", symbol), + }, .count = 2, }; + mtx_unlock(&mod->lock); + struct exposable *exposable = m->label->instantiate(m->label, &tags); tag_set_destroy(&tags);