mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
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:
parent
e17ec0203c
commit
bca0ec07ac
4 changed files with 38 additions and 57 deletions
|
|
@ -116,7 +116,8 @@ parse_window_type(const char *type)
|
|||
* desk D All-desktops toggle (aka omnipresent)
|
||||
*/
|
||||
static void
|
||||
fill_section(const char *content, struct wl_list *list, uint32_t *found_buttons)
|
||||
fill_section(const char *content, enum lab_node_type *buttons, int *count,
|
||||
uint32_t *found_buttons /* bitmask */)
|
||||
{
|
||||
gchar **identifiers = g_strsplit(content, ",", -1);
|
||||
for (size_t i = 0; identifiers[i]; ++i) {
|
||||
|
|
@ -162,9 +163,8 @@ fill_section(const char *content, struct wl_list *list, uint32_t *found_buttons)
|
|||
|
||||
*found_buttons |= (1 << type);
|
||||
|
||||
struct title_button *item = znew(*item);
|
||||
item->type = type;
|
||||
wl_list_append(list, &item->link);
|
||||
assert(*count < TITLE_BUTTONS_MAX);
|
||||
buttons[(*count)++] = type;
|
||||
}
|
||||
g_strfreev(identifiers);
|
||||
}
|
||||
|
|
@ -172,15 +172,8 @@ fill_section(const char *content, struct wl_list *list, uint32_t *found_buttons)
|
|||
static void
|
||||
clear_title_layout(void)
|
||||
{
|
||||
struct title_button *button, *button_tmp;
|
||||
wl_list_for_each_safe(button, button_tmp, &rc.title_buttons_left, link) {
|
||||
wl_list_remove(&button->link);
|
||||
zfree(button);
|
||||
}
|
||||
wl_list_for_each_safe(button, button_tmp, &rc.title_buttons_right, link) {
|
||||
wl_list_remove(&button->link);
|
||||
zfree(button);
|
||||
}
|
||||
rc.nr_title_buttons_left = 0;
|
||||
rc.nr_title_buttons_right = 0;
|
||||
rc.title_layout_loaded = false;
|
||||
}
|
||||
|
||||
|
|
@ -189,11 +182,6 @@ fill_title_layout(char *content)
|
|||
{
|
||||
clear_title_layout();
|
||||
|
||||
struct wl_list *sections[] = {
|
||||
&rc.title_buttons_left,
|
||||
&rc.title_buttons_right,
|
||||
};
|
||||
|
||||
gchar **parts = g_strsplit(content, ":", -1);
|
||||
|
||||
if (g_strv_length(parts) != 2) {
|
||||
|
|
@ -202,9 +190,10 @@ fill_title_layout(char *content)
|
|||
}
|
||||
|
||||
uint32_t found_buttons = 0;
|
||||
for (size_t i = 0; parts[i]; ++i) {
|
||||
fill_section(parts[i], sections[i], &found_buttons);
|
||||
}
|
||||
fill_section(parts[0], rc.title_buttons_left,
|
||||
&rc.nr_title_buttons_left, &found_buttons);
|
||||
fill_section(parts[1], rc.title_buttons_right,
|
||||
&rc.nr_title_buttons_right, &found_buttons);
|
||||
|
||||
rc.title_layout_loaded = true;
|
||||
err:
|
||||
|
|
@ -1362,8 +1351,6 @@ rcxml_init(void)
|
|||
static bool has_run;
|
||||
|
||||
if (!has_run) {
|
||||
wl_list_init(&rc.title_buttons_left);
|
||||
wl_list_init(&rc.title_buttons_right);
|
||||
wl_list_init(&rc.usable_area_overrides);
|
||||
wl_list_init(&rc.keybinds);
|
||||
wl_list_init(&rc.mousebinds);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue