diff options
| -rw-r--r-- | src/draw.c | 2 | ||||
| -rw-r--r-- | src/state.c | 9 | ||||
| -rw-r--r-- | src/state.h | 1 |
3 files changed, 11 insertions, 1 deletions
@@ -8,6 +8,8 @@ #include "button.h" #include "log.h" +// TODO: Animations ?? + static void layout_destroy(Layout *layout) { if (layout->pl != NULL) g_object_unref(layout->pl); diff --git a/src/state.c b/src/state.c index 0054076..0debb1f 100644 --- a/src/state.c +++ b/src/state.c @@ -10,6 +10,7 @@ State *state_create(Window *win, Drawable *draw) state->win = win; state->draw = draw; state->btns = NULL; + state->id = 0; return state; } @@ -25,6 +26,7 @@ static gboolean redraw_and_layout(gpointer data) State *state = data; draw_compute_layout(state->draw, state->win, state->btns); draw_paint(state->draw, state->win); + state->id = 0; return G_SOURCE_REMOVE; } @@ -32,6 +34,7 @@ static gboolean redraw(gpointer data) { State *state = data; draw_paint(state->draw, state->win); + state->id = 0; return G_SOURCE_REMOVE; } @@ -40,7 +43,11 @@ static gboolean redraw(gpointer data) // This could probably be fixed by implementing a redraw source... void state_redraw(State *state, bool changed_layout) { - g_idle_add_full(G_PRIORITY_HIGH_IDLE, changed_layout ? redraw_and_layout : redraw, state, NULL); + // XXX: Override old redraw + if (state->id != 0) + g_source_remove(state->id); + + state->id = g_idle_add_full(G_PRIORITY_HIGH_IDLE, changed_layout ? redraw_and_layout : redraw, state, NULL); } void state_destroy(State *state) diff --git a/src/state.h b/src/state.h index a8bc0eb..5814415 100644 --- a/src/state.h +++ b/src/state.h @@ -13,6 +13,7 @@ struct State { Window *win; Drawable *draw; GList *btns; + gint id; }; State *state_create(Window *win, Drawable *draw); |
