From 9276724113e5608c6e125f8594e1f0745bc95c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 13 Jan 2019 14:33:58 +0100 Subject: [PATCH] module: remove 'with' from expose-context --- bar.c | 24 ++++++++++++------------ module.c | 3 ++- module.h | 5 ++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bar.c b/bar.c index 2ec3b6d..540d27a 100644 --- a/bar.c +++ b/bar.c @@ -91,19 +91,19 @@ calculate_widths(const struct private *b, int *left, int *center, int *right) for (size_t i = 0; i < b->left.count; i++) { struct module_expose_context *e = &b->left.exps[i]; assert(e->exposable != NULL); - *left += b->left_spacing + e->width + b->right_spacing; + *left += b->left_spacing + e->exposable->width + b->right_spacing; } for (size_t i = 0; i < b->center.count; i++) { struct module_expose_context *e = &b->center.exps[i]; assert(e->exposable != NULL); - *center += b->left_spacing + e->width + b->right_spacing; + *center += b->left_spacing + e->exposable->width + b->right_spacing; } for (size_t i = 0; i < b->right.count; i++) { struct module_expose_context *e = &b->right.exps[i]; assert(e->exposable != NULL); - *right += b->left_spacing + e->width + b->right_spacing; + *right += b->left_spacing + e->exposable->width + b->right_spacing; } /* No spacing on the edges (that's what the margins are for) */ @@ -180,7 +180,7 @@ expose(const struct bar *_bar) const struct module *m = bar->left.mods[i]; const struct module_expose_context *e = &bar->left.exps[i]; m->expose(m, e, bar->cairo, x + bar->left_spacing, y, bar->height); - x += bar->left_spacing + e->width + bar->right_spacing; + x += bar->left_spacing + e->exposable->width + bar->right_spacing; } x = bar->width / 2 - center_width / 2 - bar->left_spacing; @@ -188,7 +188,7 @@ expose(const struct bar *_bar) const struct module *m = bar->center.mods[i]; const struct module_expose_context *e = &bar->center.exps[i]; m->expose(m, e, bar->cairo, x + bar->left_spacing, y, bar->height); - x += bar->left_spacing + e->width + bar->right_spacing; + x += bar->left_spacing + e->exposable->width + bar->right_spacing; } x = bar->width - ( @@ -201,7 +201,7 @@ expose(const struct bar *_bar) const struct module *m = bar->right.mods[i]; const struct module_expose_context *e = &bar->right.exps[i]; m->expose(m, e, bar->cairo, x + bar->left_spacing, y, bar->height); - x += bar->left_spacing + e->width + bar->right_spacing; + x += bar->left_spacing + e->exposable->width + bar->right_spacing; } cairo_surface_flush(bar->cairo_surface); @@ -279,14 +279,14 @@ on_mouse(struct bar *bar, enum mouse_event event, int x, int y) const struct module_expose_context *e = &b->left.exps[i]; mx += b->left_spacing; - if (x >= mx && x < mx + e->width) { + if (x >= mx && x < mx + e->exposable->width) { assert(e->exposable != NULL); if (e->exposable->on_mouse != NULL) e->exposable->on_mouse(e->exposable, bar, event, x - mx, y); return; } - mx += e->width + b->right_spacing; + mx += e->exposable->width + b->right_spacing; } mx = b->width / 2 - center_width / 2 - b->left_spacing; @@ -294,14 +294,14 @@ on_mouse(struct bar *bar, enum mouse_event event, int x, int y) const struct module_expose_context *e = &b->center.exps[i]; mx += b->left_spacing; - if (x >= mx && x < mx + e->width) { + if (x >= mx && x < mx + e->exposable->width) { assert(e->exposable != NULL); if (e->exposable->on_mouse != NULL) e->exposable->on_mouse(e->exposable, bar, event, x - mx, y); return; } - mx += e->width + b->right_spacing; + mx += e->exposable->width + b->right_spacing; } mx = b->width - (right_width + b->left_spacing + b->right_margin + b->border.width); @@ -309,14 +309,14 @@ on_mouse(struct bar *bar, enum mouse_event event, int x, int y) const struct module_expose_context *e = &b->right.exps[i]; mx += b->left_spacing; - if (x >= mx && x < mx + e->width) { + if (x >= mx && x < mx + e->exposable->width) { assert(e->exposable != NULL); if (e->exposable->on_mouse != NULL) e->exposable->on_mouse(e->exposable, bar, event, x - mx, y); return; } - mx += e->width + b->right_spacing; + mx += e->exposable->width + b->right_spacing; } set_cursor(bar, "left_ptr"); diff --git a/module.c b/module.c index 624ccfb..77d83e1 100644 --- a/module.c +++ b/module.c @@ -41,9 +41,10 @@ struct module_expose_context module_default_begin_expose(struct module *mod) { struct exposable *e = mod->content(mod); + e->begin_expose(e); + return (struct module_expose_context){ .exposable = e, - .width = e->begin_expose(e), .private = NULL, }; } diff --git a/module.h b/module.h index 74fd5cf..1e70baf 100644 --- a/module.h +++ b/module.h @@ -13,8 +13,8 @@ struct module; struct module_info { bool (*verify_conf)(keychain_t *chain, const struct yml_node *node); - struct module *(*from_conf)(const struct yml_node *node, - struct conf_inherit inherited); + struct module *(*from_conf)( + const struct yml_node *node, struct conf_inherit inherited); #define MODULE_COMMON_ATTRS \ {"font", false, &conf_verify_font}, \ @@ -30,7 +30,6 @@ struct module_run_context { struct module_expose_context { struct exposable *exposable; - int width; void *private; };