mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-20 03:35:41 +02:00
module: begin_expose() and content() take a non-const module pointer
This commit is contained in:
parent
b579f97db7
commit
7f0f096ba4
9 changed files with 15 additions and 15 deletions
6
bar.c
6
bar.c
|
@ -101,21 +101,21 @@ expose(const struct bar *_bar)
|
||||||
|
|
||||||
struct module_expose_context ctx_left[bar->left.count];
|
struct module_expose_context ctx_left[bar->left.count];
|
||||||
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];
|
struct module *m = bar->left.mods[i];
|
||||||
ctx_left[i] = m->begin_expose(m, bar->cairo);
|
ctx_left[i] = m->begin_expose(m, bar->cairo);
|
||||||
left_width += bar->left_spacing + ctx_left[i].width + bar->right_spacing;
|
left_width += bar->left_spacing + ctx_left[i].width + bar->right_spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct module_expose_context ctx_center[bar->center.count];
|
struct module_expose_context ctx_center[bar->center.count];
|
||||||
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];
|
struct module *m = bar->center.mods[i];
|
||||||
ctx_center[i] = m->begin_expose(m, bar->cairo);
|
ctx_center[i] = m->begin_expose(m, bar->cairo);
|
||||||
center_width += bar->left_spacing + ctx_center[i].width + bar->right_spacing;
|
center_width += bar->left_spacing + ctx_center[i].width + bar->right_spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct module_expose_context ctx_right[bar->right.count];
|
struct module_expose_context ctx_right[bar->right.count];
|
||||||
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];
|
struct module *m = bar->right.mods[i];
|
||||||
ctx_right[i] = m->begin_expose(m, bar->cairo);
|
ctx_right[i] = m->begin_expose(m, bar->cairo);
|
||||||
right_width += bar->left_spacing + ctx_right[i].width + bar->right_spacing;
|
right_width += bar->left_spacing + ctx_right[i].width + bar->right_spacing;
|
||||||
}
|
}
|
||||||
|
|
2
module.c
2
module.c
|
@ -25,7 +25,7 @@ module_default_destroy(struct module *mod)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct module_expose_context
|
struct module_expose_context
|
||||||
module_default_begin_expose(const struct module *mod, cairo_t *cr)
|
module_default_begin_expose(struct module *mod, cairo_t *cr)
|
||||||
{
|
{
|
||||||
struct exposable *e = mod->content(mod);
|
struct exposable *e = mod->content(mod);
|
||||||
return (struct module_expose_context){
|
return (struct module_expose_context){
|
||||||
|
|
6
module.h
6
module.h
|
@ -29,8 +29,8 @@ struct module {
|
||||||
int (*run)(struct module_run_context *ctx);
|
int (*run)(struct module_run_context *ctx);
|
||||||
void (*destroy)(struct module *module);
|
void (*destroy)(struct module *module);
|
||||||
|
|
||||||
struct exposable *(*content)(const struct module *mod);
|
struct exposable *(*content)(struct module *mod);
|
||||||
struct module_expose_context (*begin_expose)(const struct module *mod, cairo_t *cr);
|
struct module_expose_context (*begin_expose)(struct module *mod, cairo_t *cr);
|
||||||
void (*expose)(const struct module *mod,
|
void (*expose)(const struct module *mod,
|
||||||
const struct module_expose_context *ctx,
|
const struct module_expose_context *ctx,
|
||||||
cairo_t *cr, int x, int y, int height);
|
cairo_t *cr, int x, int y, int height);
|
||||||
|
@ -42,7 +42,7 @@ struct module *module_common_new(void);
|
||||||
void module_default_destroy(struct module *mod);
|
void module_default_destroy(struct module *mod);
|
||||||
|
|
||||||
struct module_expose_context module_default_begin_expose(
|
struct module_expose_context module_default_begin_expose(
|
||||||
const struct module *mod, cairo_t *cr);
|
struct module *mod, cairo_t *cr);
|
||||||
|
|
||||||
void module_default_expose(
|
void module_default_expose(
|
||||||
const struct module *mod,
|
const struct module *mod,
|
||||||
|
|
|
@ -49,11 +49,11 @@ destroy(struct module *mod)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct exposable *
|
static struct exposable *
|
||||||
content(const struct module *mod)
|
content(struct module *mod)
|
||||||
{
|
{
|
||||||
const struct private *m = mod->private;
|
const struct private *m = mod->private;
|
||||||
|
|
||||||
mtx_lock(&((struct module *)mod)->lock);
|
mtx_lock(&mod->lock);
|
||||||
|
|
||||||
assert(m->state == STATE_FULL ||
|
assert(m->state == STATE_FULL ||
|
||||||
m->state == STATE_CHARGING ||
|
m->state == STATE_CHARGING ||
|
||||||
|
@ -92,7 +92,7 @@ content(const struct module *mod)
|
||||||
.count = 6,
|
.count = 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
mtx_unlock(&((struct module *)mod)->lock);
|
mtx_unlock(&mod->lock);
|
||||||
|
|
||||||
struct exposable *exposable = m->label->instantiate(m->label, &tags);
|
struct exposable *exposable = m->label->instantiate(m->label, &tags);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ destroy(struct module *mod)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct exposable *
|
static struct exposable *
|
||||||
content(const struct module *mod)
|
content(struct module *mod)
|
||||||
{
|
{
|
||||||
const struct private *m = mod->private;
|
const struct private *m = mod->private;
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
|
|
|
@ -397,7 +397,7 @@ destroy(struct module *mod)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct exposable *
|
static struct exposable *
|
||||||
content(const struct module *mod)
|
content(struct module *mod)
|
||||||
{
|
{
|
||||||
struct private *m = mod->private;
|
struct private *m = mod->private;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ destroy(struct module *mod)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct exposable *
|
static struct exposable *
|
||||||
content(const struct module *mod)
|
content(struct module *mod)
|
||||||
{
|
{
|
||||||
const struct private *m = mod->private;
|
const struct private *m = mod->private;
|
||||||
return m->label->instantiate(m->label, NULL);
|
return m->label->instantiate(m->label, NULL);
|
||||||
|
|
|
@ -52,7 +52,7 @@ destroy(struct module *mod)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct exposable *
|
static struct exposable *
|
||||||
content(const struct module *mod)
|
content(struct module *mod)
|
||||||
{
|
{
|
||||||
const struct private *m = mod->private;
|
const struct private *m = mod->private;
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ run(struct module_run_context *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct exposable *
|
static struct exposable *
|
||||||
content(const struct module *mod)
|
content(struct module *mod)
|
||||||
{
|
{
|
||||||
struct private *m = mod->private;
|
struct private *m = mod->private;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue