bar, module: particles may no longer return NULL in instantiate()

This commit is contained in:
Daniel Eklöf 2020-11-02 19:09:58 +01:00
parent fef40d18e1
commit c11a79c98d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 1 additions and 23 deletions

View file

@ -36,22 +36,16 @@ calculate_widths(const struct private *b, int *left, int *center, int *right)
for (size_t i = 0; i < b->left.count; i++) { for (size_t i = 0; i < b->left.count; i++) {
struct exposable *e = b->left.exps[i]; struct exposable *e = b->left.exps[i];
if (e == NULL)
continue;
*left += b->left_spacing + e->width + b->right_spacing; *left += b->left_spacing + e->width + b->right_spacing;
} }
for (size_t i = 0; i < b->center.count; i++) { for (size_t i = 0; i < b->center.count; i++) {
struct exposable *e = b->center.exps[i]; struct exposable *e = b->center.exps[i];
if (e == NULL)
continue;
*center += b->left_spacing + e->width + b->right_spacing; *center += b->left_spacing + e->width + b->right_spacing;
} }
for (size_t i = 0; i < b->right.count; i++) { for (size_t i = 0; i < b->right.count; i++) {
struct exposable *e = b->right.exps[i]; struct exposable *e = b->right.exps[i];
if (e == NULL)
continue;
*right += b->left_spacing + e->width + b->right_spacing; *right += b->left_spacing + e->width + b->right_spacing;
} }
@ -85,30 +79,24 @@ expose(const struct bar *_bar)
for (size_t i = 0; i < bar->left.count; i++) { for (size_t i = 0; i < bar->left.count; i++) {
struct module *m = bar->left.mods[i]; struct module *m = bar->left.mods[i];
struct exposable *e = bar->left.exps[i]; struct exposable *e = bar->left.exps[i];
if (e != NULL) if (e != NULL)
e->destroy(e); e->destroy(e);
bar->left.exps[i] = module_begin_expose(m); bar->left.exps[i] = module_begin_expose(m);
} }
for (size_t i = 0; i < bar->center.count; i++) { for (size_t i = 0; i < bar->center.count; i++) {
struct module *m = bar->center.mods[i]; struct module *m = bar->center.mods[i];
struct exposable *e = bar->center.exps[i]; struct exposable *e = bar->center.exps[i];
if (e != NULL) if (e != NULL)
e->destroy(e); e->destroy(e);
bar->center.exps[i] = module_begin_expose(m); bar->center.exps[i] = module_begin_expose(m);
} }
for (size_t i = 0; i < bar->right.count; i++) { for (size_t i = 0; i < bar->right.count; i++) {
struct module *m = bar->right.mods[i]; struct module *m = bar->right.mods[i];
struct exposable *e = bar->right.exps[i]; struct exposable *e = bar->right.exps[i];
if (e != NULL) if (e != NULL)
e->destroy(e); e->destroy(e);
bar->right.exps[i] = module_begin_expose(m); bar->right.exps[i] = module_begin_expose(m);
} }
@ -119,8 +107,6 @@ expose(const struct bar *_bar)
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 exposable *e = bar->left.exps[i]; const struct exposable *e = bar->left.exps[i];
if (e == NULL)
continue;
e->expose(e, pix, x + bar->left_spacing, y, bar->height); e->expose(e, pix, 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;
} }
@ -128,8 +114,6 @@ expose(const struct bar *_bar)
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 exposable *e = bar->center.exps[i]; const struct exposable *e = bar->center.exps[i];
if (e == NULL)
continue;
e->expose(e, pix, x + bar->left_spacing, y, bar->height); e->expose(e, pix, 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;
} }
@ -142,8 +126,6 @@ expose(const struct bar *_bar)
for (size_t i = 0; i < bar->right.count; i++) { for (size_t i = 0; i < bar->right.count; i++) {
const struct exposable *e = bar->right.exps[i]; const struct exposable *e = bar->right.exps[i];
if (e == NULL)
continue;
e->expose(e, pix, x + bar->left_spacing, y, bar->height); e->expose(e, pix, 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;
} }
@ -316,7 +298,6 @@ destroy(struct bar *bar)
for (size_t i = 0; i < b->left.count; i++) { for (size_t i = 0; i < b->left.count; i++) {
struct module *m = b->left.mods[i]; struct module *m = b->left.mods[i];
struct exposable *e = b->left.exps[i]; struct exposable *e = b->left.exps[i];
if (e != NULL) if (e != NULL)
e->destroy(e); e->destroy(e);
m->destroy(m); m->destroy(m);
@ -324,7 +305,6 @@ destroy(struct bar *bar)
for (size_t i = 0; i < b->center.count; i++) { for (size_t i = 0; i < b->center.count; i++) {
struct module *m = b->center.mods[i]; struct module *m = b->center.mods[i];
struct exposable *e = b->center.exps[i]; struct exposable *e = b->center.exps[i];
if (e != NULL) if (e != NULL)
e->destroy(e); e->destroy(e);
m->destroy(m); m->destroy(m);
@ -332,7 +312,6 @@ destroy(struct bar *bar)
for (size_t i = 0; i < b->right.count; i++) { for (size_t i = 0; i < b->right.count; i++) {
struct module *m = b->right.mods[i]; struct module *m = b->right.mods[i];
struct exposable *e = b->right.exps[i]; struct exposable *e = b->right.exps[i];
if (e != NULL) if (e != NULL)
e->destroy(e); e->destroy(e);
m->destroy(m); m->destroy(m);

View file

@ -23,7 +23,6 @@ struct exposable *
module_begin_expose(struct module *mod) module_begin_expose(struct module *mod)
{ {
struct exposable *e = mod->content(mod); struct exposable *e = mod->content(mod);
if (e != NULL)
e->begin_expose(e); e->begin_expose(e);
return e; return e;
} }