aboutsummaryrefslogtreecommitdiff
path: root/src/state.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/state.c b/src/state.c
index f35faa2..d9ecaeb 100644
--- a/src/state.c
+++ b/src/state.c
@@ -67,16 +67,29 @@ void state_request_redraw(State *state, bool relayout)
static gboolean anim_handler(State *state)
{
- bool anim = false;
+ bool done = true;
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;
+ bool draw = btn->anim->paint_func != NULL;
+ bool layout = btn->anim->layout_func != NULL;
+
+ // Remove animation if both paint_func and layout_func finished
+ if (!draw && !layout) {
+ log_debug("Removing animation [type=%d, end=%ld, button=%p]",
+ btn->anim->type, btn->anim->start + btn->anim->duration, btn);
+
+ animation_destroy(btn->anim);
+ btn->anim = NULL;
+ } else {
+ done = false;
+ state->relayout |= layout;
+ }
}
}
- log_debug("Animating [relayout=%d]", state->relayout);
+ log_debug("Redrawing animation [relayout=%d, done=%d]", state->relayout, done);
if (state->relayout) {
draw_compute_layout(state->draw, state->win, state->btns);
@@ -84,10 +97,9 @@ static gboolean anim_handler(State *state)
}
draw_paint(state->draw, state->win);
- if (anim) return G_SOURCE_CONTINUE;
- state->anim_id = 0;
- return G_SOURCE_REMOVE;
+ if (done) state->anim_id = 0;
+ return !done;
}
void state_request_animation(State *state)