mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-20 03:35:41 +02:00
bar, module: particles may no longer return NULL in instantiate()
This commit is contained in:
parent
fef40d18e1
commit
c11a79c98d
2 changed files with 1 additions and 23 deletions
21
bar/bar.c
21
bar/bar.c
|
@ -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);
|
||||||
|
|
1
module.c
1
module.c
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue