From 5807acda35eba4a1c7d0f515586d138a0bd95be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Mon, 23 Jun 2014 21:29:30 -0300 Subject: Remove all effects code for a fresh and clean start --- src/core/window.c | 66 +++++-------------------------------------------------- 1 file changed, 5 insertions(+), 61 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 74e69074..be982de3 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -1479,49 +1479,7 @@ implement_showing (MetaWindow *window, if (!showing) { - gboolean on_workspace; - - on_workspace = meta_window_located_on_workspace (window, - window->screen->active_workspace); - - /* Really this effects code should probably - * be in meta_window_hide so the window->mapped - * test isn't duplicated here. Anyhow, we animate - * if we are mapped now, we are supposed to - * be minimized, and we are on the current workspace. - */ - if (on_workspace && window->minimized && window->mapped && - !meta_prefs_get_reduced_resources ()) - { - MetaRectangle icon_rect, window_rect; - gboolean result; - - /* Check if the window has an icon geometry */ - result = meta_window_get_icon_geometry (window, &icon_rect); - - if (!result) - { - /* just animate into the corner somehow - maybe - * not a good idea... - */ - icon_rect.x = window->screen->rect.width; - icon_rect.y = window->screen->rect.height; - icon_rect.width = 1; - icon_rect.height = 1; - } - - meta_window_get_outer_rect (window, &window_rect); - - meta_effect_run_minimize (window, - &window_rect, - &icon_rect, - finish_minimize, - window); - } - else - { - finish_minimize (window); - } + meta_window_hide(window); } else { @@ -2283,24 +2241,6 @@ meta_window_show (MetaWindow *window) XMapWindow (window->display->xdisplay, window->xwindow); meta_error_trap_pop (window->display, FALSE); did_show = TRUE; - - if (window->was_minimized) - { - MetaRectangle window_rect; - MetaRectangle icon_rect; - - window->was_minimized = FALSE; - - if (meta_window_get_icon_geometry (window, &icon_rect)) - { - meta_window_get_outer_rect (window, &window_rect); - - meta_effect_run_unminimize (window, - &window_rect, - &icon_rect, - NULL, NULL); - } - } } if (window->iconic) @@ -2437,6 +2377,8 @@ meta_window_minimize (MetaWindow *window) window->desc); } } + + /* Should insert minimize effect here? */ } void @@ -2452,6 +2394,8 @@ meta_window_unminimize (MetaWindow *window) queue_calc_showing_func, NULL); } + + /* Should insert unminimize effect here? */ } static void -- cgit v1.2.1 From 5675f355396d58bcbb16f8e7fabd60d5d3bc69e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Tue, 24 Jun 2014 11:46:02 -0300 Subject: Add a simple unminimize effect the same as minimize --- src/core/effects.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/effects.c b/src/core/effects.c index 4e9b3ae8..592e3470 100644 --- a/src/core/effects.c +++ b/src/core/effects.c @@ -719,6 +719,12 @@ run_default_effect_handler (MetaEffect *effect) &(effect->u.minimize.icon_rect), META_MINIMIZE_ANIMATION_LENGTH); 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); + break; default: break; -- cgit v1.2.1 From e1d87e891c43c4c40b0bdd2f2627286e9bffdef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Tue, 24 Jun 2014 11:49:47 -0300 Subject: Add "effect_pending" flag Initialized at META_EFFECT_NONE. The management of this should be done by caller functions to effect functions. --- src/core/effects.h | 1 + src/core/window-private.h | 4 ++++ src/core/window.c | 1 + 3 files changed, 6 insertions(+) diff --git a/src/core/effects.h b/src/core/effects.h index ca25aa88..e0025ff6 100644 --- a/src/core/effects.h +++ b/src/core/effects.h @@ -50,6 +50,7 @@ typedef enum { + META_EFFECT_NONE = 0, META_EFFECT_MINIMIZE, META_EFFECT_UNMINIMIZE, META_EFFECT_FOCUS, diff --git a/src/core/window-private.h b/src/core/window-private.h index dcb19d7f..65359e15 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -36,6 +36,7 @@ #include #include "window.h" +#include "effects.h" #include "screen-private.h" #include "util.h" #include "stack.h" @@ -185,6 +186,9 @@ struct _MetaWindow guint was_minimized : 1; guint tab_unminimized : 1; + /* Whether there is a pending effect */ + MetaEffectType effect_pending; + /* Whether the window is mapped; actual server-side state * see also unmaps_pending */ diff --git a/src/core/window.c b/src/core/window.c index be982de3..652c098d 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -476,6 +476,7 @@ meta_window_new_with_attrs (MetaDisplay *display, window->minimized = FALSE; window->was_minimized = FALSE; window->tab_unminimized = FALSE; + window->effect_pending = META_EFFECT_NONE; window->iconic = FALSE; window->mapped = attrs->map_state != IsUnmapped; /* if already mapped, no need to worry about focus-on-first-time-showing */ -- cgit v1.2.1 From f3263ee47c1ad6cacd359668ef967af9c8d2beb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Tue, 24 Jun 2014 11:54:06 -0300 Subject: Remove "icky" timestamp pinging on finish_minimize --- src/core/window.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 652c098d..37ea3ff5 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -1453,21 +1453,8 @@ static void finish_minimize (gpointer data) { MetaWindow *window = data; - /* FIXME: It really sucks to put timestamp pinging here; it'd - * probably make more sense in implement_showing() so that it's at - * least not duplicated in meta_window_show; but since - * finish_minimize is a callback making things just slightly icky, I - * haven't done that yet. - */ - guint32 timestamp = meta_display_get_current_time_roundtrip (window->display); meta_window_hide (window); - if (window->has_focus) - { - meta_workspace_focus_default_window (window->screen->active_workspace, - window, - timestamp); - } } static void -- cgit v1.2.1 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(-) 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 From 9a7b1d9a02542171aa31f8340bbb16fa096793c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Tue, 24 Jun 2014 12:04:02 -0300 Subject: Implement animation handling in implement_showing Functions meta_window_animate_[un]minimize will handle [un]minimization animations. Maybe this should be done in effects.c file to trigger animations based on context, compositing, preferences etc. --- src/core/window.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 5 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 37ea3ff5..2b7a867e 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -1454,7 +1454,74 @@ finish_minimize (gpointer data) { MetaWindow *window = data; - meta_window_hide (window); + window->effect_pending = META_EFFECT_NONE; +} + +static void +finish_unminimize (gpointer data) +{ + MetaWindow *window = data; + + meta_window_show (window); + window->effect_pending = META_EFFECT_NONE; +} + +static void +meta_window_animate_minimize (MetaWindow *window) +{ + MetaRectangle icon_rect, window_rect; + gboolean result; + + /* Check if the window has an icon geometry */ + result = meta_window_get_icon_geometry (window, &icon_rect); + + if (!result) + { + /* just animate into the corner somehow - maybe + * not a good idea... + */ + icon_rect.x = window->screen->rect.width; + icon_rect.y = window->screen->rect.height; + icon_rect.width = 1; + icon_rect.height = 1; + } + + meta_window_get_outer_rect (window, &window_rect); + + meta_effect_run_minimize (window, + &window_rect, + &icon_rect, + finish_minimize, + window); +} + +static void +meta_window_animate_unminimize (MetaWindow *window) +{ + MetaRectangle icon_rect, window_rect; + gboolean result; + + /* Check if the window has an icon geometry */ + result = meta_window_get_icon_geometry (window, &icon_rect); + + if (!result) + { + /* just animate into the corner somehow - maybe + * not a good idea... + */ + icon_rect.x = window->screen->rect.width; + icon_rect.y = window->screen->rect.height; + icon_rect.width = 1; + icon_rect.height = 1; + } + + meta_window_get_outer_rect (window, &window_rect); + + meta_effect_run_unminimize (window, + &window_rect, + &icon_rect, + finish_unminimize, + window); } static void @@ -1462,16 +1529,42 @@ implement_showing (MetaWindow *window, gboolean showing) { /* Actually show/hide the window */ - meta_verbose ("Implement showing = %d for window %s\n", - showing, window->desc); + meta_verbose ("Implement showing = %d for window %s with effect pending %i\n", + showing, window->desc, window->effect_pending); if (!showing) { - meta_window_hide(window); + /* Handle pending effects */ + switch(window->effect_pending) + { + case META_EFFECT_MINIMIZE: + /* First hide the window and then animate */ + meta_window_hide(window); + meta_window_animate_minimize (window); + break; + case META_EFFECT_UNMINIMIZE: + case META_EFFECT_NONE: + default: + meta_window_hide(window); + break; + } } else { - meta_window_show (window); + /* Handle pending effects */ + switch(window->effect_pending) + { + case META_EFFECT_MINIMIZE: + break; + case META_EFFECT_UNMINIMIZE: + /* First animate then show the window */ + meta_window_animate_unminimize (window); + break; + case META_EFFECT_NONE: + default: + meta_window_show (window); + break; + } } } @@ -2346,6 +2439,8 @@ meta_window_minimize (MetaWindow *window) if (!window->minimized) { window->minimized = TRUE; + /* Flag minimize effect pending */ + window->effect_pending = META_EFFECT_MINIMIZE; meta_window_queue(window, META_QUEUE_CALC_SHOWING); meta_window_foreach_transient (window, @@ -2376,6 +2471,7 @@ meta_window_unminimize (MetaWindow *window) { window->minimized = FALSE; window->was_minimized = TRUE; + window->effect_pending = META_EFFECT_UNMINIMIZE; meta_window_queue(window, META_QUEUE_CALC_SHOWING); meta_window_foreach_transient (window, -- cgit v1.2.1 From 25fc06391ca02c65dd9830e03a729a68f66c3220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Tue, 24 Jun 2014 12:04:45 -0300 Subject: Bugfix: run finished function if animations are disabled --- src/core/effects.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/effects.c b/src/core/effects.c index 658f6fa5..5d0d24a6 100644 --- a/src/core/effects.c +++ b/src/core/effects.c @@ -751,8 +751,15 @@ run_default_effect_handler (MetaEffect *effect) static void run_handler (MetaEffect *effect) { + /* If effects are disabled just run the finished function */ if (meta_prefs_get_mate_animations ()) + { run_default_effect_handler (effect); + } + else + { + effect->priv->finished(effect->priv->finished_data); + } effect_free (effect); } -- cgit v1.2.1 From 4f08084b0ff11e1a7ebbdd5385fd6b2969b7f36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Tue, 24 Jun 2014 12:05:25 -0300 Subject: Bugfix: If the window shown was minimized, grab focus. --- src/core/window.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/window.c b/src/core/window.c index 2b7a867e..631229b7 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -2353,6 +2353,11 @@ meta_window_show (MetaWindow *window) meta_display_increment_focus_sentinel (window->display); } } + else if (window->was_minimized) + { + window->was_minimized = FALSE; + meta_window_focus(window, timestamp); + } set_net_wm_state (window); -- cgit v1.2.1 From 12e9874307e73f613036ad8f370bc05650c84298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Wed, 25 Jun 2014 22:43:17 -0300 Subject: Bugfix: Correct was_minimized flag transition --- src/core/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/window.c b/src/core/window.c index 631229b7..694ba99e 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -1463,6 +1463,7 @@ finish_unminimize (gpointer data) MetaWindow *window = data; meta_window_show (window); + window->was_minimized = FALSE; window->effect_pending = META_EFFECT_NONE; } @@ -2355,7 +2356,6 @@ meta_window_show (MetaWindow *window) } else if (window->was_minimized) { - window->was_minimized = FALSE; meta_window_focus(window, timestamp); } -- cgit v1.2.1 From 5b415150cf3676ee95e1da7d5a29093cd20e6c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Ignacio=20Aramend=C3=ADa?= Date: Wed, 25 Jun 2014 23:21:28 -0300 Subject: Remove misleading comment in effect_free function The new behaviour is the animation callback function should run the finished function once it's done with the animation. --- src/core/effects.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/core/effects.c b/src/core/effects.c index 5d0d24a6..853d5ce9 100644 --- a/src/core/effects.c +++ b/src/core/effects.c @@ -179,17 +179,13 @@ create_effect (MetaEffectType type, } /** - * Destroys an effect. If the effect has a "finished" hook, it will be - * called before cleanup. + * Destroys an effect. * * \param effect The effect. */ static void effect_free (MetaEffect *effect) { - /*if (effect->priv->finished) - effect->priv->finished (effect->priv->finished_data);*/ - g_free (effect->priv); g_free (effect); } -- cgit v1.2.1