aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/comet.c4
-rw-r--r--src/state.c15
-rw-r--r--src/state.h2
3 files changed, 19 insertions, 2 deletions
diff --git a/src/comet.c b/src/comet.c
index 586245f..a969677 100644
--- a/src/comet.c
+++ b/src/comet.c
@@ -293,8 +293,6 @@ int main(int argc, char **argv)
// Dwm tags
DwmIpc *dwm = dwm_create(state, "/tmp/dwm.sock");
- // FIXME: BUG! Explodes if the buttons are not loaded with the left first!!!
- // And I have no clue as to why!!!!!
dwm_register_tags(dwm, color, purple, text_color, line_color);
register_buttons(state, color, line_color, text_color);
@@ -363,6 +361,8 @@ int main(int argc, char **argv)
button_group_append(group, menu);
state_add_button(state, group);
+ state_order_button(state);
+
connect_attach_state(con, state);
connect_attach_source(con);
diff --git a/src/state.c b/src/state.c
index e8ddbe0..c5dc759 100644
--- a/src/state.c
+++ b/src/state.c
@@ -55,6 +55,21 @@ void state_redraw(State *state, bool changed_layout)
state->id = g_idle_add_full(G_PRIORITY_HIGH_IDLE, changed_layout ? redraw_and_layout : redraw, state, NULL);
}
+static gint align_compare(gconstpointer a, gconstpointer b)
+{
+ PangoAlignment a_align = ((Button *)a)->align;
+ PangoAlignment b_align = ((Button *)b)->align;
+
+ if (a_align < b_align) return -1;
+ if (a_align > b_align) return 1;
+ return 0;
+}
+
+void state_order_button(State *state)
+{
+ state->btns = g_list_sort(state->btns, align_compare);
+}
+
void state_destroy(State *state)
{
g_list_free_full(state->btns, (void *)button_destroy);
diff --git a/src/state.h b/src/state.h
index 1dedd8e..9ce4cc9 100644
--- a/src/state.h
+++ b/src/state.h
@@ -22,6 +22,8 @@ void state_add_button(State *state, Button *btn);
void state_remove_button(State *state, Button *btn);
+void state_order_button(State *state);
+
void state_redraw(State *state, bool changed_layout);
void state_destroy(State *state);