From 430def6e39315b6cee807aba3e4126134b93b164 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Fri, 15 Mar 2024 00:21:01 +0100 Subject: Fix layout animation and animation handler --- src/state.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/state.c') diff --git a/src/state.c b/src/state.c index 0f17695..f35faa2 100644 --- a/src/state.c +++ b/src/state.c @@ -67,7 +67,16 @@ void state_request_redraw(State *state, bool relayout) static gboolean anim_handler(State *state) { - //log_debug("Animating [relayout=%d]", state->relayout); + bool anim = false; + for (GList *it = state->btns; it != NULL; it = it->next) { + Button *btn = it->data; + if (btn->anim != NULL) { + anim = true; + state->relayout |= btn->anim->layout_func != NULL; + } + } + + log_debug("Animating [relayout=%d]", state->relayout); if (state->relayout) { draw_compute_layout(state->draw, state->win, state->btns); @@ -75,12 +84,7 @@ static gboolean anim_handler(State *state) } draw_paint(state->draw, state->win); - - for (GList *it = state->btns; it != NULL; it = it->next) { - Button *btn = it->data; - if (btn->anim != NULL) - return G_SOURCE_CONTINUE; - } + if (anim) return G_SOURCE_CONTINUE; state->anim_id = 0; return G_SOURCE_REMOVE; -- cgit v1.2.3