forked from external/yambar
module: remove module->expose() and module->end_expose()
Bar now calls exposable->expose() and exposable->destroy() directly
This commit is contained in:
parent
33cba8b0ba
commit
4c577766d1
3 changed files with 10 additions and 39 deletions
21
bar.c
21
bar.c
|
@ -146,7 +146,7 @@ expose(const struct bar *_bar)
|
||||||
struct exposable *e = bar->left.exps[i];
|
struct exposable *e = bar->left.exps[i];
|
||||||
|
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
m->end_expose(m, e);
|
e->destroy(e);
|
||||||
|
|
||||||
bar->left.exps[i] = m->begin_expose(m);
|
bar->left.exps[i] = m->begin_expose(m);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ expose(const struct bar *_bar)
|
||||||
struct exposable *e = bar->center.exps[i];
|
struct exposable *e = bar->center.exps[i];
|
||||||
|
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
m->end_expose(m, e);
|
e->destroy(e);
|
||||||
|
|
||||||
bar->center.exps[i] = m->begin_expose(m);
|
bar->center.exps[i] = m->begin_expose(m);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ expose(const struct bar *_bar)
|
||||||
struct exposable *e = bar->right.exps[i];
|
struct exposable *e = bar->right.exps[i];
|
||||||
|
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
m->end_expose(m, e);
|
e->destroy(e);
|
||||||
|
|
||||||
bar->right.exps[i] = m->begin_expose(m);
|
bar->right.exps[i] = m->begin_expose(m);
|
||||||
}
|
}
|
||||||
|
@ -177,17 +177,15 @@ expose(const struct bar *_bar)
|
||||||
int y = bar->border.width;
|
int y = bar->border.width;
|
||||||
int x = bar->border.width + bar->left_margin - bar->left_spacing;
|
int x = bar->border.width + bar->left_margin - bar->left_spacing;
|
||||||
for (size_t i = 0; i < bar->left.count; i++) {
|
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];
|
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->left_spacing + e->width + bar->right_spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
x = bar->width / 2 - center_width / 2 - bar->left_spacing;
|
x = bar->width / 2 - center_width / 2 - bar->left_spacing;
|
||||||
for (size_t i = 0; i < bar->center.count; i++) {
|
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];
|
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;
|
x += bar->left_spacing + e->width + bar->right_spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,9 +196,8 @@ expose(const struct bar *_bar)
|
||||||
bar->border.width);
|
bar->border.width);
|
||||||
|
|
||||||
for (size_t i = 0; i < bar->right.count; i++) {
|
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];
|
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;
|
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];
|
struct exposable *e = bar->left.exps[i];
|
||||||
|
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
m->end_expose(m, e);
|
e->destroy(e);
|
||||||
m->destroy(m);
|
m->destroy(m);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < bar->center.count; i++) {
|
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];
|
struct exposable *e = bar->center.exps[i];
|
||||||
|
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
m->end_expose(m, e);
|
e->destroy(e);
|
||||||
m->destroy(m);
|
m->destroy(m);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < bar->right.count; i++) {
|
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];
|
struct exposable *e = bar->right.exps[i];
|
||||||
|
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
m->end_expose(m, e);
|
e->destroy(e);
|
||||||
m->destroy(m);
|
m->destroy(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
module.c
15
module.c
|
@ -13,8 +13,6 @@ module_common_new(void)
|
||||||
|
|
||||||
mod->destroy = &module_default_destroy;
|
mod->destroy = &module_default_destroy;
|
||||||
mod->begin_expose = &module_default_begin_expose;
|
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 */
|
/* No defaults for these; must be provided by implementation */
|
||||||
mod->run = NULL;
|
mod->run = NULL;
|
||||||
|
@ -44,16 +42,3 @@ module_default_begin_expose(struct module *mod)
|
||||||
e->begin_expose(e);
|
e->begin_expose(e);
|
||||||
return 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);
|
|
||||||
}
|
|
||||||
|
|
13
module.h
13
module.h
|
@ -68,21 +68,10 @@ struct module {
|
||||||
* 'content()' instead (see above).
|
* 'content()' instead (see above).
|
||||||
*/
|
*/
|
||||||
struct exposable *(*begin_expose)(struct module *mod);
|
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);
|
struct module *module_common_new(void);
|
||||||
void module_signal_ready(struct module_run_context *ctx);
|
|
||||||
|
|
||||||
void module_default_destroy(struct module *mod);
|
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);
|
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);
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue