rcxml: use fixed arrays for rc.title_buttons_*

These are just lists of enum lab_node_type, with a bounded size and
no middle-insertions/removals, so linked lists are overkill.

Also, the use of wl_list_for_each[_reverse] just to access the first or
last entry in the list (corner button) was weird.
This commit is contained in:
John Lindgren 2025-09-08 22:35:23 -04:00 committed by Johan Malm
parent e17ec0203c
commit bca0ec07ac
4 changed files with 38 additions and 57 deletions

View file

@ -231,25 +231,16 @@ load_button(struct theme *theme, struct button *b, int active)
struct lab_img **rounded_img =
&button_imgs[b->type][b->state_set | LAB_BS_ROUNDED];
struct title_button *leftmost_button;
wl_list_for_each(leftmost_button,
&rc.title_buttons_left, link) {
if (leftmost_button->type == b->type) {
*rounded_img = lab_img_copy(*img);
lab_img_add_modifier(*rounded_img,
round_left_corner_button);
}
break;
if (rc.nr_title_buttons_left > 0
&& b->type == rc.title_buttons_left[0]) {
*rounded_img = lab_img_copy(*img);
lab_img_add_modifier(*rounded_img, round_left_corner_button);
}
struct title_button *rightmost_button;
wl_list_for_each_reverse(rightmost_button,
&rc.title_buttons_right, link) {
if (rightmost_button->type == b->type) {
*rounded_img = lab_img_copy(*img);
lab_img_add_modifier(*rounded_img,
round_right_corner_button);
}
break;
if (rc.nr_title_buttons_right > 0
&& b->type == rc.title_buttons_right
[rc.nr_title_buttons_right - 1]) {
*rounded_img = lab_img_copy(*img);
lab_img_add_modifier(*rounded_img, round_right_corner_button);
}
}