diff options
| author | Federico Angelilli <code@fedang.net> | 2024-03-06 21:36:14 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-03-06 21:36:14 +0100 |
| commit | f7e94e7a0f33cbf6b5ee784974a431d633aada0f (patch) | |
| tree | 4bdfd2a42d198c0a295880cf433ec3ee5c8863fb /src/state.c | |
| parent | f4b80335df97b6136682b1acb71ecf4766d636ed (diff) | |
Fix button ordering bug
Diffstat (limited to 'src/state.c')
| -rw-r--r-- | src/state.c | 15 |
1 files changed, 15 insertions, 0 deletions
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); |
