diff --git a/config-verify.c b/config-verify.c index e20f142..fa5adc4 100644 --- a/config-verify.c +++ b/config-verify.c @@ -19,6 +19,7 @@ #include "modules/network/network.h" #include "modules/removables/removables.h" #include "modules/xkb/xkb.h" +#include "modules/xwindow/xwindow.h" const char * conf_err_prefix(const keychain_t *chain, const struct yml_node *node) @@ -440,11 +441,6 @@ verify_module(keychain_t *chain, const struct yml_node *node) return false; } - static const struct attr_info xwindow[] = { - {"content", true, &conf_verify_particle}, - {"anchors", false, NULL}, - }; - /* TODO: this will dlopened later */ static const struct { const char *name; @@ -460,6 +456,7 @@ verify_module(keychain_t *chain, const struct yml_node *node) {"network", &module_network}, {"removables", &module_removables}, {"xkb", &module_xkb}, + {"xwindow", &module_xwindow}, }; static const struct { @@ -467,7 +464,6 @@ verify_module(keychain_t *chain, const struct yml_node *node) const struct attr_info *attrs; size_t count; } modules[] = { - {"xwindow", xwindow, sizeof(xwindow) / sizeof(xwindow[0])}, }; for (size_t i = 0; i < sizeof(modules_v2) / sizeof(modules_v2[0]); i++) { diff --git a/config.c b/config.c index 6be88df..734d17a 100644 --- a/config.c +++ b/config.c @@ -362,13 +362,6 @@ conf_to_particle(const struct yml_node *node, const struct font *parent_font) return ret; } -static struct module * -module_xwindow_from_config(const struct yml_node *node, const struct font *parent_font) -{ - const struct yml_node *c = yml_get_value(node, "content"); - return module_xwindow(conf_to_particle(c, parent_font)); -} - struct bar * conf_to_bar(const struct yml_node *bar) { @@ -479,10 +472,8 @@ conf_to_bar(const struct yml_node *bar) mods[idx] = module_removables.from_conf(m.value, font); else if (strcmp(mod_name, "xkb") == 0) mods[idx] = module_xkb.from_conf(m.value, font); - - else if (strcmp(mod_name, "xwindow") == 0) - mods[idx] = module_xwindow_from_config(m.value, font); + mods[idx] = module_xwindow.from_conf(m.value, font); else assert(false); } diff --git a/modules/xwindow/xwindow.c b/modules/xwindow/xwindow.c index 515c0a0..d118b1e 100644 --- a/modules/xwindow/xwindow.c +++ b/modules/xwindow/xwindow.c @@ -17,6 +17,7 @@ #define LOG_MODULE "xkb" #include "../../log.h" #include "../../bar.h" +#include "../../config.h" #include "../../xcb.h" struct private { @@ -301,8 +302,8 @@ destroy(struct module *mod) module_default_destroy(mod); } -struct module * -module_xwindow(struct particle *label) +static struct module * +xwindow_new(struct particle *label) { struct private *m = calloc(1, sizeof(*m)); m->label = label; @@ -314,3 +315,20 @@ module_xwindow(struct particle *label) mod->content = &content; return mod; } + +static struct module * +from_conf(const struct yml_node *node, const struct font *parent_font) +{ + const struct yml_node *c = yml_get_value(node, "content"); + return xwindow_new(conf_to_particle(c, parent_font)); +} + +const struct module_info module_xwindow = { + .from_conf = &from_conf, + .attr_count = 2, + .attrs = { + {"content", true, &conf_verify_particle}, + {"anchors", false, NULL}, + {NULL, false, NULL}, + }, +}; diff --git a/modules/xwindow/xwindow.h b/modules/xwindow/xwindow.h index cba35f2..0f67953 100644 --- a/modules/xwindow/xwindow.h +++ b/modules/xwindow/xwindow.h @@ -1,6 +1,4 @@ #pragma once - #include "../../module.h" -#include "../../particle.h" -struct module *module_xwindow(struct particle *label); +extern const struct module_info module_xwindow;