From 08c3c187eb50dd073dc7a4cf8b19fdad03a72343 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 17 Oct 2008 17:10:15 +0100 Subject: [PATCH] Removes the running counter from the plugins and instead manage it internally to the plugin manager --- src/compositor/mutter/mutter-plugin-manager.c | 13 +++++++++++- src/compositor/mutter/plugins/default.c | 19 +----------------- src/compositor/mutter/plugins/scratch.c | 20 +------------------ src/include/mutter-plugin.h | 5 ----- 4 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/compositor/mutter/mutter-plugin-manager.c b/src/compositor/mutter/mutter-plugin-manager.c index a464ead4a..e9f9f76f6 100644 --- a/src/compositor/mutter/mutter-plugin-manager.c +++ b/src/compositor/mutter/mutter-plugin-manager.c @@ -52,6 +52,10 @@ typedef struct MutterPluginPrivate MutterPluginManager *self; GModule *module; gulong features; + /* We use this to track the number of effects currently being managed + * by a plugin. Currently this is used to block unloading while effects + * are in progress. */ + gint running; gboolean disabled : 1; } MutterPluginPrivate; @@ -224,7 +228,7 @@ mutter_plugin_unload (MutterPlugin *plugin) priv = plugin->manager_private; module = priv->module; - if (plugin->running) + if (priv->running) { priv->disabled = TRUE; return FALSE; @@ -560,6 +564,7 @@ mutter_plugin_manager_event_simple ( actor, ALL_BUT_SWITCH); + priv->running++; plugin->minimize (actor); } break; @@ -571,12 +576,14 @@ mutter_plugin_manager_event_simple ( actor, ALL_BUT_SWITCH); + priv->running++; plugin->map (actor); } break; case MUTTER_PLUGIN_DESTROY: if (plugin->destroy) { + priv->running++; plugin->destroy (actor); } break; @@ -767,6 +774,10 @@ mutter_plugin_effect_completed (MutterPlugin *plugin, MutterWindow *actor, unsigned long event) { + MutterPluginPrivate *priv = plugin->manager_private; + + priv->running--; + if (!actor) { g_warning ("Plugin [%s] passed NULL for actor!", diff --git a/src/compositor/mutter/plugins/default.c b/src/compositor/mutter/plugins/default.c index 259b73198..a6657288f 100644 --- a/src/compositor/mutter/plugins/default.c +++ b/src/compositor/mutter/plugins/default.c @@ -328,8 +328,6 @@ on_minimize_effect_complete (ClutterActor *actor, gpointer data) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_NORTH_WEST); - /* Decrease the running effect counter */ - mutter_plugin.running--; /* Now notify the manager that we are done with this effect */ mutter_plugin_effect_completed (&mutter_plugin, mc_window, MUTTER_PLUGIN_MINIMIZE); @@ -357,8 +355,6 @@ minimize (MutterWindow *mc_window) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_CENTER); - mutter_plugin.running++; - apriv->tml_minimize = clutter_effect_scale (state->minimize_effect, actor, 0.0, @@ -392,9 +388,6 @@ on_maximize_effect_complete (ClutterActor *actor, gpointer data) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_NORTH_WEST); - /* Decrease the running effect counter */ - mutter_plugin.running--; - /* Now notify the manager that we are done with this effect */ mutter_plugin_effect_completed (&mutter_plugin, mc_window, MUTTER_PLUGIN_MAXIMIZE); @@ -500,9 +493,6 @@ on_map_effect_complete (ClutterActor *actor, gpointer data) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_NORTH_WEST); - /* Decrease the running effect counter */ - mutter_plugin.running--; - /* Now notify the manager that we are done with this effect */ mutter_plugin_effect_completed (&mutter_plugin, mc_window, MUTTER_PLUGIN_MAP); } @@ -526,8 +516,6 @@ map (MutterWindow *mc_window) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_CENTER); - mutter_plugin.running++; - clutter_actor_set_scale (actor, 0.0, 0.0); clutter_actor_show (actor); @@ -549,8 +537,7 @@ map (MutterWindow *mc_window) /* * Destroy effect completion callback; this is a simple effect that requires no - * further action than decreasing the running effect counter and notifying the - * manager that the effect is completed. + * further action than notifying the manager that the effect is completed. */ static void on_destroy_effect_complete (ClutterActor *actor, gpointer data) @@ -561,8 +548,6 @@ on_destroy_effect_complete (ClutterActor *actor, gpointer data) apriv->tml_destroy = NULL; - mutter_plugin.running--; - mutter_plugin_effect_completed (plugin, mc_window, MUTTER_PLUGIN_DESTROY); } @@ -585,8 +570,6 @@ destroy (MutterWindow *mc_window) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_CENTER); - mutter_plugin.running++; - apriv->tml_destroy = clutter_effect_scale (plugin_state->destroy_effect, actor, 1.0, diff --git a/src/compositor/mutter/plugins/scratch.c b/src/compositor/mutter/plugins/scratch.c index d698a5016..762ae607b 100644 --- a/src/compositor/mutter/plugins/scratch.c +++ b/src/compositor/mutter/plugins/scratch.c @@ -340,9 +340,6 @@ on_minimize_effect_complete (ClutterActor *actor, gpointer data) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_NORTH_WEST); - /* Decrease the running effect counter */ - plugin->running--; - /* Now notify the manager that we are done with this effect */ mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MINIMIZE); @@ -372,8 +369,6 @@ minimize (MutterWindow *mcw) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_CENTER); - plugin->running++; - apriv->tml_minimize = clutter_effect_scale (priv->minimize_effect, actor, 0.0, @@ -406,9 +401,6 @@ on_maximize_effect_complete (ClutterActor *actor, gpointer data) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_NORTH_WEST); - /* Decrease the running effect counter */ - plugin->running--; - /* Now notify the manager that we are done with this effect */ mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MAXIMIZE); } @@ -516,9 +508,6 @@ on_map_effect_complete (ClutterActor *actor, gpointer data) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_NORTH_WEST); - /* Decrease the running effect counter */ - plugin->running--; - /* Now notify the manager that we are done with this effect */ mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MAP); } @@ -544,8 +533,6 @@ map (MutterWindow *mcw) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_CENTER); - plugin->running++; - clutter_actor_set_scale (actor, 0.0, 0.0); clutter_actor_show (actor); @@ -566,8 +553,7 @@ map (MutterWindow *mcw) /* * Destroy effect completion callback; this is a simple effect that requires no - * further action than decreasing the running effect counter and notifying the - * manager that the effect is completed. + * further action than notifying the manager that the effect is completed. */ static void on_destroy_effect_complete (ClutterActor *actor, gpointer data) @@ -578,8 +564,6 @@ on_destroy_effect_complete (ClutterActor *actor, gpointer data) apriv->tml_destroy = NULL; - plugin->running--; - mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_DESTROY); } @@ -603,8 +587,6 @@ destroy (MutterWindow *mcw) clutter_actor_move_anchor_point_from_gravity (actor, CLUTTER_GRAVITY_CENTER); - plugin->running++; - apriv->tml_destroy = clutter_effect_scale (priv->destroy_effect, actor, 1.0, diff --git a/src/include/mutter-plugin.h b/src/include/mutter-plugin.h index ae9d78094..0e0ba744a 100644 --- a/src/include/mutter-plugin.h +++ b/src/include/mutter-plugin.h @@ -187,11 +187,6 @@ struct MutterPlugin * workspaces. */ GList *work_areas; - /* FIXME: It should be possible to hide this from plugins */ - gint running; /* Plugin must increase this counter for each effect it starts - * decrease it again once the effect finishes. - */ - void *plugin_private; /* Plugin private data go here; use the plugin init * function to allocate and initialize any private * data.