From f96f358816b7f4c94f1575a9e0dfe81f9fb26efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Tue, 24 Jun 2014 12:02:44 -0300 Subject: Fix: the effect "finished" callback needs to be called after the effect ends Added two fields to BoxAnimationContext to handle finish callback inside box_animation_timeout function instead of effect_free. Now the finish function is called after the effect is finished. --- src/core/effects.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/effects.c b/src/core/effects.c index 592e3470..658f6fa5 100644 --- a/src/core/effects.c +++ b/src/core/effects.c @@ -67,6 +67,7 @@ #endif #define META_MINIMIZE_ANIMATION_LENGTH 0.25 +#define META_UNMINIMIZE_ANIMATION_LENGTH 0.25 #define META_SHADE_ANIMATION_LENGTH 0.2 #include @@ -98,6 +99,9 @@ typedef struct MetaRectangle start_rect; MetaRectangle end_rect; + MetaEffectFinished finished; + gpointer finished_data; + } BoxAnimationContext; /** @@ -149,7 +153,9 @@ static void draw_box_animation (MetaScreen *screen, MetaRectangle *initial_rect, MetaRectangle *destination_rect, - double seconds_duration); + double seconds_duration, + MetaEffectFinished finished, + gpointer finished_data); /** * Creates an effect. @@ -181,8 +187,8 @@ create_effect (MetaEffectType type, static void effect_free (MetaEffect *effect) { - if (effect->priv->finished) - effect->priv->finished (effect->priv->finished_data); + /*if (effect->priv->finished) + effect->priv->finished (effect->priv->finished_data);*/ g_free (effect->priv); g_free (effect); @@ -383,6 +389,8 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context) graphics_sync (context); + context->finished(context->finished_data); + g_free (context); return FALSE; } @@ -430,7 +438,9 @@ void draw_box_animation (MetaScreen *screen, MetaRectangle *initial_rect, MetaRectangle *destination_rect, - double seconds_duration) + double seconds_duration, + MetaEffectFinished finished, + gpointer finished_data) { BoxAnimationContext *context; @@ -455,6 +465,9 @@ draw_box_animation (MetaScreen *screen, context->start_rect = *initial_rect; context->end_rect = *destination_rect; + context->finished = finished; + context->finished_data = finished_data; + #ifdef HAVE_SHAPE attrs.override_redirect = True; @@ -717,13 +730,17 @@ run_default_effect_handler (MetaEffect *effect) draw_box_animation (effect->window->screen, &(effect->u.minimize.window_rect), &(effect->u.minimize.icon_rect), - META_MINIMIZE_ANIMATION_LENGTH); + META_MINIMIZE_ANIMATION_LENGTH, + effect->priv->finished, + effect->priv->finished_data); break; case META_EFFECT_UNMINIMIZE: draw_box_animation (effect->window->screen, &(effect->u.minimize.icon_rect), &(effect->u.minimize.window_rect), - META_MINIMIZE_ANIMATION_LENGTH); + META_UNMINIMIZE_ANIMATION_LENGTH, + effect->priv->finished, + effect->priv->finished_data); break; default: -- cgit v1.2.1