mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-28 12:45:40 +02:00
Fix race conditions
This commit is contained in:
parent
050439f0d3
commit
a81c7f6e3c
5 changed files with 19 additions and 30 deletions
|
@ -181,7 +181,7 @@ begin_expose_mods(const struct section *s)
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
e->destroy(e);
|
e->destroy(e);
|
||||||
s->exps[i] = module_begin_expose(m);
|
s->exps[i] = module_begin_expose(m);
|
||||||
assert(s->exps[i]->width >= 0);
|
assert(s->exps[i]->width >= 0 && s->exps[i]->height >= 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ expose(const struct bar *_bar)
|
||||||
bar->width_with_border - bar->border.left_width - bar->border.right_width,
|
bar->width_with_border - bar->border.left_width - bar->border.right_width,
|
||||||
bar->border.bottom_width},
|
bar->border.bottom_width},
|
||||||
});
|
});
|
||||||
/**
|
|
||||||
pixman_region32_t clip;
|
pixman_region32_t clip;
|
||||||
pixman_region32_init_rect(
|
pixman_region32_init_rect(
|
||||||
&clip,
|
&clip,
|
||||||
|
@ -282,7 +282,7 @@ expose(const struct bar *_bar)
|
||||||
bar->top_margin - bar->bottom_margin -
|
bar->top_margin - bar->bottom_margin -
|
||||||
bar->border.top_width - bar->border.bottom_width));
|
bar->border.top_width - bar->border.bottom_width));
|
||||||
pixman_image_set_clip_region32(pix, &clip);
|
pixman_image_set_clip_region32(pix, &clip);
|
||||||
pixman_region32_fini(&clip);*/
|
pixman_region32_fini(&clip);
|
||||||
|
|
||||||
int left_width, center_width, right_width;
|
int left_width, center_width, right_width;
|
||||||
calculate_widths(bar, &left_width, ¢er_width, &right_width);
|
calculate_widths(bar, &left_width, ¢er_width, &right_width);
|
||||||
|
@ -325,8 +325,7 @@ expose(const struct bar *_bar)
|
||||||
static void
|
static void
|
||||||
refresh(const struct bar *bar)
|
refresh(const struct bar *bar)
|
||||||
{
|
{
|
||||||
struct private *b = bar->private;
|
const struct private *b = bar->private;
|
||||||
bar_recalc_size(b);
|
|
||||||
b->backend.iface->refresh(bar);
|
b->backend.iface->refresh(bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1043,28 +1043,12 @@ update_size(struct wayland_backend *backend)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
backend->scale = scale;
|
backend->scale = scale;
|
||||||
|
|
||||||
// TODO: Somehow set up width and height properly
|
|
||||||
// I need to read more to understand how bar->width and bar->height are used
|
|
||||||
zwlr_layer_surface_v1_set_size(
|
|
||||||
backend->layer_surface,
|
|
||||||
(bar->width_with_border % scale + bar->width_with_border) / scale,
|
|
||||||
(bar->height_with_border % scale + bar->height_with_border) / scale
|
|
||||||
);
|
|
||||||
|
|
||||||
/* Trigger a 'configure' event, after which we'll have the width */
|
|
||||||
wl_surface_commit(backend->surface);
|
|
||||||
wl_display_roundtrip(backend->display);
|
|
||||||
|
|
||||||
if (backend->width == -1 || backend->height == -1) {
|
if (backend->width == -1 || backend->height == -1) {
|
||||||
LOG_ERR("failed to get panel size");
|
LOG_ERR("failed to get panel size");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("backend size: %dx%d", backend->width, backend->height);
|
|
||||||
bar->width = backend->width;
|
|
||||||
bar->height = backend->height;
|
|
||||||
|
|
||||||
if (bar->location & (BAR_TOP | BAR_BOTTOM)) {
|
if (bar->location & (BAR_TOP | BAR_BOTTOM)) {
|
||||||
zwlr_layer_surface_v1_set_exclusive_zone(
|
zwlr_layer_surface_v1_set_exclusive_zone(
|
||||||
backend->layer_surface,
|
backend->layer_surface,
|
||||||
|
@ -1089,12 +1073,20 @@ update_size(struct wayland_backend *backend)
|
||||||
bar->border.left_margin / scale
|
bar->border.left_margin / scale
|
||||||
);
|
);
|
||||||
|
|
||||||
|
zwlr_layer_surface_v1_set_size(
|
||||||
|
backend->layer_surface,
|
||||||
|
(bar->width_with_border % scale + bar->width_with_border) / scale,
|
||||||
|
(bar->height_with_border % scale + bar->height_with_border) / scale
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Trigger a 'configure' event, after which we'll have the width */
|
||||||
wl_surface_commit(backend->surface);
|
wl_surface_commit(backend->surface);
|
||||||
// TODO: Figure out why not setting width & height
|
wl_display_roundtrip(backend->display);
|
||||||
// make the bar fail to appear. Don't want to have to do this
|
|
||||||
bar->width_with_border = backend->width;
|
bar->width_with_border = backend->width;
|
||||||
bar->height_with_border = backend->height;
|
bar->height_with_border = backend->height;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Reload buffers */
|
/* Reload buffers */
|
||||||
if (backend->next_buffer != NULL)
|
if (backend->next_buffer != NULL)
|
||||||
backend->next_buffer->busy = false;
|
backend->next_buffer->busy = false;
|
||||||
|
|
4
config.c
4
config.c
|
@ -172,7 +172,7 @@ particle_simple_list_from_config(const struct yml_node *node,
|
||||||
static struct particle *(*particle_list_new)(
|
static struct particle *(*particle_list_new)(
|
||||||
struct particle *common,
|
struct particle *common,
|
||||||
struct particle *particles[], size_t count,
|
struct particle *particles[], size_t count,
|
||||||
int left_spacing, int right_spacing) = NULL;
|
bool vertical, int left_spacing, int right_spacing) = NULL;
|
||||||
|
|
||||||
if (particle_list_new == NULL) {
|
if (particle_list_new == NULL) {
|
||||||
const struct plugin *plug = plugin_load("list", PLUGIN_PARTICLE);
|
const struct plugin *plug = plugin_load("list", PLUGIN_PARTICLE);
|
||||||
|
@ -185,7 +185,7 @@ particle_simple_list_from_config(const struct yml_node *node,
|
||||||
0, 0, NULL, fcft_clone(inherited.font), inherited.font_shaping,
|
0, 0, NULL, fcft_clone(inherited.font), inherited.font_shaping,
|
||||||
inherited.foreground, NULL);
|
inherited.foreground, NULL);
|
||||||
|
|
||||||
return particle_list_new(common, parts, count, 0, 2);
|
return particle_list_new(common, parts, count, false, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct particle *
|
struct particle *
|
||||||
|
|
|
@ -67,6 +67,7 @@ exposable_render_deco(const struct exposable *exposable,
|
||||||
pixman_image_t *pix, int x, int y)
|
pixman_image_t *pix, int x, int y)
|
||||||
{
|
{
|
||||||
const struct deco *deco = exposable->particle->deco;
|
const struct deco *deco = exposable->particle->deco;
|
||||||
|
|
||||||
if (deco != NULL)
|
if (deco != NULL)
|
||||||
deco->expose(deco, pix, x, y, exposable->width, exposable->height);
|
deco->expose(deco, pix, x, y, exposable->width, exposable->height);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ struct text_run_cache {
|
||||||
uint64_t hash;
|
uint64_t hash;
|
||||||
struct fcft_text_run *run;
|
struct fcft_text_run *run;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
|
||||||
bool in_use;
|
bool in_use;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -217,10 +216,9 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
||||||
font, chars, wtext, FCFT_SUBPIXEL_NONE);
|
font, chars, wtext, FCFT_SUBPIXEL_NONE);
|
||||||
|
|
||||||
if (run != NULL) {
|
if (run != NULL) {
|
||||||
int w = 0, h = 0;
|
int w = 0;
|
||||||
for (size_t i = 0; i < run->count; i++) {
|
for (size_t i = 0; i < run->count; i++) {
|
||||||
w += run->glyphs[i]->advance.x;
|
w += run->glyphs[i]->advance.x;
|
||||||
h += run->glyphs[i]->advance.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t cache_idx = -1;
|
ssize_t cache_idx = -1;
|
||||||
|
@ -246,7 +244,6 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
||||||
p->cache[cache_idx].hash = hash;
|
p->cache[cache_idx].hash = hash;
|
||||||
p->cache[cache_idx].run = run;
|
p->cache[cache_idx].run = run;
|
||||||
p->cache[cache_idx].width = w;
|
p->cache[cache_idx].width = w;
|
||||||
p->cache[cache_idx].height = h;
|
|
||||||
p->cache[cache_idx].in_use = true;
|
p->cache[cache_idx].in_use = true;
|
||||||
|
|
||||||
e->cache_idx = cache_idx;
|
e->cache_idx = cache_idx;
|
||||||
|
|
Loading…
Add table
Reference in a new issue