Removes the running counter from the plugins and instead manage it internally

to the plugin manager
This commit is contained in:
Robert Bragg 2008-10-17 17:10:15 +01:00
parent b422faa4fe
commit 08c3c187eb
4 changed files with 14 additions and 43 deletions

View File

@ -52,6 +52,10 @@ typedef struct MutterPluginPrivate
MutterPluginManager *self; MutterPluginManager *self;
GModule *module; GModule *module;
gulong features; 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; gboolean disabled : 1;
} MutterPluginPrivate; } MutterPluginPrivate;
@ -224,7 +228,7 @@ mutter_plugin_unload (MutterPlugin *plugin)
priv = plugin->manager_private; priv = plugin->manager_private;
module = priv->module; module = priv->module;
if (plugin->running) if (priv->running)
{ {
priv->disabled = TRUE; priv->disabled = TRUE;
return FALSE; return FALSE;
@ -560,6 +564,7 @@ mutter_plugin_manager_event_simple (
actor, actor,
ALL_BUT_SWITCH); ALL_BUT_SWITCH);
priv->running++;
plugin->minimize (actor); plugin->minimize (actor);
} }
break; break;
@ -571,12 +576,14 @@ mutter_plugin_manager_event_simple (
actor, actor,
ALL_BUT_SWITCH); ALL_BUT_SWITCH);
priv->running++;
plugin->map (actor); plugin->map (actor);
} }
break; break;
case MUTTER_PLUGIN_DESTROY: case MUTTER_PLUGIN_DESTROY:
if (plugin->destroy) if (plugin->destroy)
{ {
priv->running++;
plugin->destroy (actor); plugin->destroy (actor);
} }
break; break;
@ -767,6 +774,10 @@ mutter_plugin_effect_completed (MutterPlugin *plugin,
MutterWindow *actor, MutterWindow *actor,
unsigned long event) unsigned long event)
{ {
MutterPluginPrivate *priv = plugin->manager_private;
priv->running--;
if (!actor) if (!actor)
{ {
g_warning ("Plugin [%s] passed NULL for actor!", g_warning ("Plugin [%s] passed NULL for actor!",

View File

@ -328,8 +328,6 @@ on_minimize_effect_complete (ClutterActor *actor, gpointer data)
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_NORTH_WEST); CLUTTER_GRAVITY_NORTH_WEST);
/* Decrease the running effect counter */
mutter_plugin.running--;
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (&mutter_plugin, mc_window, mutter_plugin_effect_completed (&mutter_plugin, mc_window,
MUTTER_PLUGIN_MINIMIZE); MUTTER_PLUGIN_MINIMIZE);
@ -357,8 +355,6 @@ minimize (MutterWindow *mc_window)
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_CENTER); CLUTTER_GRAVITY_CENTER);
mutter_plugin.running++;
apriv->tml_minimize = clutter_effect_scale (state->minimize_effect, apriv->tml_minimize = clutter_effect_scale (state->minimize_effect,
actor, actor,
0.0, 0.0,
@ -392,9 +388,6 @@ on_maximize_effect_complete (ClutterActor *actor, gpointer data)
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_NORTH_WEST); CLUTTER_GRAVITY_NORTH_WEST);
/* Decrease the running effect counter */
mutter_plugin.running--;
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (&mutter_plugin, mc_window, mutter_plugin_effect_completed (&mutter_plugin, mc_window,
MUTTER_PLUGIN_MAXIMIZE); MUTTER_PLUGIN_MAXIMIZE);
@ -500,9 +493,6 @@ on_map_effect_complete (ClutterActor *actor, gpointer data)
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_NORTH_WEST); CLUTTER_GRAVITY_NORTH_WEST);
/* Decrease the running effect counter */
mutter_plugin.running--;
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (&mutter_plugin, mc_window, MUTTER_PLUGIN_MAP); 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_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_CENTER); CLUTTER_GRAVITY_CENTER);
mutter_plugin.running++;
clutter_actor_set_scale (actor, 0.0, 0.0); clutter_actor_set_scale (actor, 0.0, 0.0);
clutter_actor_show (actor); clutter_actor_show (actor);
@ -549,8 +537,7 @@ map (MutterWindow *mc_window)
/* /*
* Destroy effect completion callback; this is a simple effect that requires no * Destroy effect completion callback; this is a simple effect that requires no
* further action than decreasing the running effect counter and notifying the * further action than notifying the manager that the effect is completed.
* manager that the effect is completed.
*/ */
static void static void
on_destroy_effect_complete (ClutterActor *actor, gpointer data) on_destroy_effect_complete (ClutterActor *actor, gpointer data)
@ -561,8 +548,6 @@ on_destroy_effect_complete (ClutterActor *actor, gpointer data)
apriv->tml_destroy = NULL; apriv->tml_destroy = NULL;
mutter_plugin.running--;
mutter_plugin_effect_completed (plugin, mc_window, mutter_plugin_effect_completed (plugin, mc_window,
MUTTER_PLUGIN_DESTROY); MUTTER_PLUGIN_DESTROY);
} }
@ -585,8 +570,6 @@ destroy (MutterWindow *mc_window)
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_CENTER); CLUTTER_GRAVITY_CENTER);
mutter_plugin.running++;
apriv->tml_destroy = clutter_effect_scale (plugin_state->destroy_effect, apriv->tml_destroy = clutter_effect_scale (plugin_state->destroy_effect,
actor, actor,
1.0, 1.0,

View File

@ -340,9 +340,6 @@ on_minimize_effect_complete (ClutterActor *actor, gpointer data)
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_NORTH_WEST); CLUTTER_GRAVITY_NORTH_WEST);
/* Decrease the running effect counter */
plugin->running--;
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (plugin, mcw, mutter_plugin_effect_completed (plugin, mcw,
MUTTER_PLUGIN_MINIMIZE); MUTTER_PLUGIN_MINIMIZE);
@ -372,8 +369,6 @@ minimize (MutterWindow *mcw)
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_CENTER); CLUTTER_GRAVITY_CENTER);
plugin->running++;
apriv->tml_minimize = clutter_effect_scale (priv->minimize_effect, apriv->tml_minimize = clutter_effect_scale (priv->minimize_effect,
actor, actor,
0.0, 0.0,
@ -406,9 +401,6 @@ on_maximize_effect_complete (ClutterActor *actor, gpointer data)
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_NORTH_WEST); CLUTTER_GRAVITY_NORTH_WEST);
/* Decrease the running effect counter */
plugin->running--;
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MAXIMIZE); 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_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_NORTH_WEST); CLUTTER_GRAVITY_NORTH_WEST);
/* Decrease the running effect counter */
plugin->running--;
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MAP); 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_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_CENTER); CLUTTER_GRAVITY_CENTER);
plugin->running++;
clutter_actor_set_scale (actor, 0.0, 0.0); clutter_actor_set_scale (actor, 0.0, 0.0);
clutter_actor_show (actor); clutter_actor_show (actor);
@ -566,8 +553,7 @@ map (MutterWindow *mcw)
/* /*
* Destroy effect completion callback; this is a simple effect that requires no * Destroy effect completion callback; this is a simple effect that requires no
* further action than decreasing the running effect counter and notifying the * further action than notifying the manager that the effect is completed.
* manager that the effect is completed.
*/ */
static void static void
on_destroy_effect_complete (ClutterActor *actor, gpointer data) on_destroy_effect_complete (ClutterActor *actor, gpointer data)
@ -578,8 +564,6 @@ on_destroy_effect_complete (ClutterActor *actor, gpointer data)
apriv->tml_destroy = NULL; apriv->tml_destroy = NULL;
plugin->running--;
mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_DESTROY); 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_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_CENTER); CLUTTER_GRAVITY_CENTER);
plugin->running++;
apriv->tml_destroy = clutter_effect_scale (priv->destroy_effect, apriv->tml_destroy = clutter_effect_scale (priv->destroy_effect,
actor, actor,
1.0, 1.0,

View File

@ -187,11 +187,6 @@ struct MutterPlugin
* workspaces. */ * workspaces. */
GList *work_areas; 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 void *plugin_private; /* Plugin private data go here; use the plugin init
* function to allocate and initialize any private * function to allocate and initialize any private
* data. * data.