[metacity] effects: simplify code
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] effects: simplify code
- Date: Thu, 2 Mar 2017 15:35:37 +0000 (UTC)
commit 14c55f1ecc6f593642ef0b37c60d4f952fc800da
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Mar 2 17:35:18 2017 +0200
effects: simplify code
src/core/effects.c | 133 ++++++----------------------------------------------
src/core/effects.h | 20 +-------
src/core/window.c | 46 ++++++------------
3 files changed, 33 insertions(+), 166 deletions(-)
---
diff --git a/src/core/effects.c b/src/core/effects.c
index dadb807..2ec1aec 100644
--- a/src/core/effects.c
+++ b/src/core/effects.c
@@ -63,13 +63,9 @@
#include <X11/extensions/shape.h>
#define META_MINIMIZE_ANIMATION_LENGTH 0.25
-#define META_SHADE_ANIMATION_LENGTH 0.2
#include <string.h>
-typedef struct MetaEffect MetaEffect;
-typedef struct MetaEffectPriv MetaEffectPriv;
-
typedef struct
{
MetaScreen *screen;
@@ -85,99 +81,24 @@ typedef struct
} BoxAnimationContext;
-/**
- * Information we need to know during a maximise or minimise effect.
- */
-typedef struct
-{
- /** This is the normal-size window. */
- MetaRectangle window_rect;
- /** This is the size of the window when it's an icon. */
- MetaRectangle icon_rect;
-} MetaMinimizeEffect, MetaUnminimizeEffect;
-
-struct MetaEffectPriv
-{
- MetaEffectFinished finished;
- gpointer finished_data;
-};
-
-struct MetaEffect
-{
- /** The window the effect is applied to. */
- MetaWindow *window;
- /** Which effect is happening here. */
- MetaEffectType type;
- /** The effect handler can hang data here. */
- gpointer info;
-
- union
- {
- MetaMinimizeEffect minimize;
- /* ... and theoretically anything else */
- } u;
-
- MetaEffectPriv *priv;
-};
-
-static void run_default_effect_handler (MetaEffect *effect);
-static void run_handler (MetaEffect *effect);
-
-/**
- * Creates an effect.
- *
- */
-static MetaEffect*
-create_effect (MetaEffectType type,
- MetaWindow *window,
- MetaEffectFinished finished,
- gpointer finished_data)
-{
- MetaEffect *effect = g_new (MetaEffect, 1);
-
- effect->type = type;
- effect->window = window;
- effect->priv = g_new (MetaEffectPriv, 1);
- effect->priv->finished = finished;
- effect->priv->finished_data = finished_data;
-
- return effect;
-}
-
-/**
- * Destroys an effect. If the effect has a "finished" hook, it will be
- * called before cleanup.
- *
- * \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);
-}
+static void draw_box_animation (MetaScreen *screen,
+ MetaRectangle *initial_rect,
+ MetaRectangle *destination_rect,
+ double seconds_duration);
void
-meta_effect_run_minimize (MetaWindow *window,
- MetaRectangle *window_rect,
- MetaRectangle *icon_rect,
- MetaEffectFinished finished,
- gpointer data)
+meta_effect_run_minimize (MetaWindow *window,
+ MetaRectangle *window_rect,
+ MetaRectangle *icon_rect)
{
- MetaEffect *effect;
-
- g_return_if_fail (window != NULL);
- g_return_if_fail (icon_rect != NULL);
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (icon_rect != NULL);
- effect = create_effect (META_EFFECT_MINIMIZE, window, finished, data);
-
- effect->u.minimize.window_rect = *window_rect;
- effect->u.minimize.icon_rect = *icon_rect;
-
- run_handler (effect);
+ if (meta_prefs_get_gnome_animations ())
+ {
+ draw_box_animation (window->screen, window_rect, icon_rect,
+ META_MINIMIZE_ANIMATION_LENGTH);
+ }
}
/* old ugly minimization effect */
@@ -551,29 +472,3 @@ meta_effects_end_wireframe (MetaScreen *screen,
meta_display_ungrab (screen->display);
meta_ui_pop_delay_exposes (screen->ui);
}
-
-static void
-run_default_effect_handler (MetaEffect *effect)
-{
- switch (effect->type)
- {
- case META_EFFECT_MINIMIZE:
- draw_box_animation (effect->window->screen,
- &(effect->u.minimize.window_rect),
- &(effect->u.minimize.icon_rect),
- META_MINIMIZE_ANIMATION_LENGTH);
- break;
-
- default:
- break;
- }
-}
-
-static void
-run_handler (MetaEffect *effect)
-{
- if (meta_prefs_get_gnome_animations ())
- run_default_effect_handler (effect);
-
- effect_free (effect);
-}
diff --git a/src/core/effects.h b/src/core/effects.h
index 03fc282..2e2b947 100644
--- a/src/core/effects.h
+++ b/src/core/effects.h
@@ -46,30 +46,16 @@
#include "util.h"
#include "screen-private.h"
-typedef enum
-{
- META_EFFECT_MINIMIZE,
-} MetaEffectType;
-
-/**
- * A callback which will be called when the effect has finished.
- */
-typedef void (* MetaEffectFinished) (gpointer data);
-
/**
* Performs the minimize effect.
*
* \param window The window we're moving
* \param window_rect Its current state
* \param target Where it should end up
- * \param finished Callback for when it's finished
- * \param data Data for callback
*/
-void meta_effect_run_minimize (MetaWindow *window,
- MetaRectangle *window_rect,
- MetaRectangle *target,
- MetaEffectFinished finished,
- gpointer data);
+void meta_effect_run_minimize (MetaWindow *window,
+ MetaRectangle *window_rect,
+ MetaRectangle *target);
/**
* Grabs the server and paints a wireframe rectangle on the screen.
diff --git a/src/core/window.c b/src/core/window.c
index 0b279a6..38a6324 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -1461,27 +1461,6 @@ meta_window_should_be_showing (MetaWindow *window)
}
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
implement_showing (MetaWindow *window,
gboolean showing)
{
@@ -1524,15 +1503,23 @@ implement_showing (MetaWindow *window,
meta_window_get_outer_rect (window, &window_rect);
- meta_effect_run_minimize (window,
- &window_rect,
- &icon_rect,
- finish_minimize,
- window);
+ meta_effect_run_minimize (window, &window_rect, &icon_rect);
}
- else
+
+ meta_window_hide (window);
+
+ if (window->has_focus)
{
- finish_minimize (window);
+ guint32 timestamp;
+
+ /* 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.
+ */
+ timestamp = meta_display_get_current_time_roundtrip (window->display);
+
+ meta_workspace_focus_default_window (window->screen->active_workspace,
+ window, timestamp);
}
}
else
@@ -2134,8 +2121,7 @@ meta_window_show (MetaWindow *window)
guint32 timestamp;
/* 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 finish_minimize. *shrug*
+ * probably make more sense in implement_showing().
*/
timestamp = meta_display_get_current_time_roundtrip (window->display);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]