Fix miscalculation of list width in presence of empty particles

This commit is contained in:
Delgan 2024-03-31 18:53:57 +00:00 committed by Daniel Eklöf
parent c44c66c83f
commit 53dec73ed2
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 10 additions and 6 deletions

View file

@ -47,6 +47,7 @@
* script: buffer overflow when reading large amounts of data. * script: buffer overflow when reading large amounts of data.
* i3/sway: module fails when reloading config file ([#361][361]). * i3/sway: module fails when reloading config file ([#361][361]).
* Worked around bug in gcc causing a compilation error ([#350][350]). * Worked around bug in gcc causing a compilation error ([#350][350]).
* Miscalculation of list width in presence of empty particles ([#369][369]).
[311]: https://codeberg.org/dnkl/yambar/issues/311 [311]: https://codeberg.org/dnkl/yambar/issues/311
[302]: https://codeberg.org/dnkl/yambar/issues/302 [302]: https://codeberg.org/dnkl/yambar/issues/302
@ -55,6 +56,7 @@
[352]: https://codeberg.org/dnkl/yambar/issues/352 [352]: https://codeberg.org/dnkl/yambar/issues/352
[361]: https://codeberg.org/dnkl/yambar/issues/361 [361]: https://codeberg.org/dnkl/yambar/issues/361
[350]: https://codeberg.org/dnkl/yambar/issues/350 [350]: https://codeberg.org/dnkl/yambar/issues/350
[369]: https://codeberg.org/dnkl/yambar/issues/369
### Security ### Security

View file

@ -71,6 +71,7 @@ dynlist_expose(const struct exposable *exposable, pixman_image_t *pix, int x, in
for (size_t i = 0; i < e->count; i++) { for (size_t i = 0; i < e->count; i++) {
const struct exposable *ee = e->exposables[i]; const struct exposable *ee = e->exposables[i];
ee->expose(ee, pix, x + left_spacing, y, height); ee->expose(ee, pix, x + left_spacing, y, height);
if (e->widths[i] > 0)
x += left_spacing + e->widths[i] + right_spacing; x += left_spacing + e->widths[i] + right_spacing;
} }
} }
@ -95,7 +96,7 @@ on_mouse(struct exposable *exposable, struct bar *bar,
} }
return; return;
} }
if (e->exposables[i]->width > 0)
px += e->left_spacing + e->exposables[i]->width + e->right_spacing; px += e->left_spacing + e->exposables[i]->width + e->right_spacing;
} }

View file

@ -80,6 +80,7 @@ expose(const struct exposable *exposable, pixman_image_t *pix, int x, int y, int
for (size_t i = 0; i < e->count; i++) { for (size_t i = 0; i < e->count; i++) {
const struct exposable *ee = e->exposables[i]; const struct exposable *ee = e->exposables[i];
ee->expose(ee, pix, x + left_spacing, y, height); ee->expose(ee, pix, x + left_spacing, y, height);
if (e->widths[i] > 0)
x += left_spacing + e->widths[i] + right_spacing; x += left_spacing + e->widths[i] + right_spacing;
} }
} }
@ -109,7 +110,7 @@ on_mouse(struct exposable *exposable, struct bar *bar,
} }
return; return;
} }
if (e->exposables[i]->width > 0)
px += e->left_spacing + e->exposables[i]->width + e->right_spacing; px += e->left_spacing + e->exposables[i]->width + e->right_spacing;
} }