From 4c577766d165c232507f4220e762afebfad4d309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 13 Jan 2019 14:55:21 +0100 Subject: [PATCH] module: remove module->expose() and module->end_expose() Bar now calls exposable->expose() and exposable->destroy() directly --- bar.c | 21 +++++++++------------ module.c | 15 --------------- module.h | 13 +------------ 3 files changed, 10 insertions(+), 39 deletions(-) diff --git a/bar.c b/bar.c index 0d289ba..c3d658f 100644 --- a/bar.c +++ b/bar.c @@ -146,7 +146,7 @@ expose(const struct bar *_bar) struct exposable *e = bar->left.exps[i]; if (e != NULL) - m->end_expose(m, e); + e->destroy(e); bar->left.exps[i] = m->begin_expose(m); } @@ -156,7 +156,7 @@ expose(const struct bar *_bar) struct exposable *e = bar->center.exps[i]; if (e != NULL) - m->end_expose(m, e); + e->destroy(e); bar->center.exps[i] = m->begin_expose(m); } @@ -166,7 +166,7 @@ expose(const struct bar *_bar) struct exposable *e = bar->right.exps[i]; if (e != NULL) - m->end_expose(m, e); + e->destroy(e); bar->right.exps[i] = m->begin_expose(m); } @@ -177,17 +177,15 @@ expose(const struct bar *_bar) int y = bar->border.width; int x = bar->border.width + bar->left_margin - bar->left_spacing; for (size_t i = 0; i < bar->left.count; i++) { - const struct module *m = bar->left.mods[i]; const struct exposable *e = bar->left.exps[i]; - m->expose(m, e, bar->cairo, x + bar->left_spacing, y, bar->height); + e->expose(e, bar->cairo, x + bar->left_spacing, y, bar->height); x += bar->left_spacing + e->width + bar->right_spacing; } x = bar->width / 2 - center_width / 2 - bar->left_spacing; for (size_t i = 0; i < bar->center.count; i++) { - const struct module *m = bar->center.mods[i]; const struct exposable *e = bar->center.exps[i]; - m->expose(m, e, bar->cairo, x + bar->left_spacing, y, bar->height); + e->expose(e, bar->cairo, x + bar->left_spacing, y, bar->height); x += bar->left_spacing + e->width + bar->right_spacing; } @@ -198,9 +196,8 @@ expose(const struct bar *_bar) bar->border.width); for (size_t i = 0; i < bar->right.count; i++) { - const struct module *m = bar->right.mods[i]; const struct exposable *e = bar->right.exps[i]; - m->expose(m, e, bar->cairo, x + bar->left_spacing, y, bar->height); + e->expose(e, bar->cairo, x + bar->left_spacing, y, bar->height); x += bar->left_spacing + e->width + bar->right_spacing; } @@ -678,7 +675,7 @@ run(struct bar_run_context *run_ctx) struct exposable *e = bar->left.exps[i]; if (e != NULL) - m->end_expose(m, e); + e->destroy(e); m->destroy(m); } for (size_t i = 0; i < bar->center.count; i++) { @@ -686,7 +683,7 @@ run(struct bar_run_context *run_ctx) struct exposable *e = bar->center.exps[i]; if (e != NULL) - m->end_expose(m, e); + e->destroy(e); m->destroy(m); } for (size_t i = 0; i < bar->right.count; i++) { @@ -694,7 +691,7 @@ run(struct bar_run_context *run_ctx) struct exposable *e = bar->right.exps[i]; if (e != NULL) - m->end_expose(m, e); + e->destroy(e); m->destroy(m); } diff --git a/module.c b/module.c index 3d72a5d..f999cc2 100644 --- a/module.c +++ b/module.c @@ -13,8 +13,6 @@ module_common_new(void) mod->destroy = &module_default_destroy; mod->begin_expose = &module_default_begin_expose; - mod->expose = &module_default_expose; - mod->end_expose = &module_default_end_expose; /* No defaults for these; must be provided by implementation */ mod->run = NULL; @@ -44,16 +42,3 @@ module_default_begin_expose(struct module *mod) e->begin_expose(e); return e; } - -void -module_default_expose(const struct module *mod, const struct exposable *exposable, - cairo_t *cr, int x, int y, int height) -{ - exposable->expose(exposable, cr, x, y, height); -} - -void -module_default_end_expose(const struct module *mod, struct exposable *exposable) -{ - exposable->destroy(exposable); -} diff --git a/module.h b/module.h index edbebbe..c942b7a 100644 --- a/module.h +++ b/module.h @@ -68,21 +68,10 @@ struct module { * 'content()' instead (see above). */ struct exposable *(*begin_expose)(struct module *mod); - void (*expose)(const struct module *mod, const struct exposable *exposable, - cairo_t *cr, int x, int y, int height); - void (*end_expose)(const struct module *mod, struct exposable *exosable); - }; struct module *module_common_new(void); -void module_signal_ready(struct module_run_context *ctx); - void module_default_destroy(struct module *mod); +void module_signal_ready(struct module_run_context *ctx); struct exposable *module_default_begin_expose(struct module *mod); - -void module_default_expose( - const struct module *mod, const struct exposable *exposbale, - cairo_t *cr, int x, int y, int height); - -void module_default_end_expose(const struct module *mod, struct exposable *exposable);