Clean up MutterPlugin effect interface

The current effect API passes an unnecessary list of windows to
switch_workspace() and forces a window to be passed in when killing
the switch_workspace() effect.

We can simplify the interface to correspond more closely to how
it is actually used and fix these problems:

Remove the actors parameter to plugin->switch_workspace
Remove the events parameter to plugin->kill_effect and rename it to kill_window_effects
Add plugin->kill_switch_workspace

Remove mutter_plugin_manager_kill_effect
Add mutter_plugin_manager_kill_window_effects
Add mutter_plugin_manager_kill_switch_workspace

Remove mutter_plugin_effect_completed
Add mutter_plugin_[minimize/map/destroy/maximize/unmaximize]_completed
https://bugzilla.gnome.org/show_bug.cgi?id=621082
This commit is contained in:
Maxim Ermilov 2010-06-17 01:15:56 +04:00
parent ff5a73de49
commit 13ad103823
6 changed files with 164 additions and 138 deletions

View File

@ -790,7 +790,6 @@ meta_compositor_switch_workspace (MetaCompositor *compositor,
if (!info->plugin_mgr ||
!mutter_plugin_manager_switch_workspace (info->plugin_mgr,
(const GList **)&info->windows,
from_indx,
to_indx,
direction))

View File

@ -402,9 +402,8 @@ mutter_plugin_manager_get (MetaScreen *screen)
}
static void
mutter_plugin_manager_kill_effect (MutterPluginManager *plugin_mgr,
MutterWindow *actor,
unsigned long events)
mutter_plugin_manager_kill_window_effects (MutterPluginManager *plugin_mgr,
MutterWindow *actor)
{
GList *l = plugin_mgr->plugins;
@ -414,17 +413,32 @@ mutter_plugin_manager_kill_effect (MutterPluginManager *plugin_mgr,
MutterPluginClass *klass = MUTTER_PLUGIN_GET_CLASS (plugin);
if (!mutter_plugin_disabled (plugin)
&& (mutter_plugin_features (plugin) & events)
&& klass->kill_effect)
klass->kill_effect (plugin, actor, events);
&& klass->kill_window_effects)
klass->kill_window_effects (plugin, actor);
l = l->next;
}
}
static void
mutter_plugin_manager_kill_switch_workspace (MutterPluginManager *plugin_mgr)
{
GList *l = plugin_mgr->plugins;
while (l)
{
MutterPlugin *plugin = l->data;
MutterPluginClass *klass = MUTTER_PLUGIN_GET_CLASS (plugin);
if (!mutter_plugin_disabled (plugin)
&& (mutter_plugin_features (plugin) & MUTTER_PLUGIN_SWITCH_WORKSPACE)
&& klass->kill_switch_workspace)
klass->kill_switch_workspace (plugin);
l = l->next;
}
}
#define ALL_BUT_SWITCH \
MUTTER_PLUGIN_ALL_EFFECTS & \
~MUTTER_PLUGIN_SWITCH_WORKSPACE
/*
* Public method that the compositor hooks into for events that require
* no additional parameters.
@ -461,10 +475,9 @@ mutter_plugin_manager_event_simple (MutterPluginManager *plugin_mgr,
case MUTTER_PLUGIN_MINIMIZE:
if (klass->minimize)
{
mutter_plugin_manager_kill_effect (
mutter_plugin_manager_kill_window_effects (
plugin_mgr,
actor,
ALL_BUT_SWITCH);
actor);
_mutter_plugin_effect_started (plugin);
klass->minimize (plugin, actor);
@ -473,10 +486,9 @@ mutter_plugin_manager_event_simple (MutterPluginManager *plugin_mgr,
case MUTTER_PLUGIN_MAP:
if (klass->map)
{
mutter_plugin_manager_kill_effect (
mutter_plugin_manager_kill_window_effects (
plugin_mgr,
actor,
ALL_BUT_SWITCH);
actor);
_mutter_plugin_effect_started (plugin);
klass->map (plugin, actor);
@ -540,10 +552,9 @@ mutter_plugin_manager_event_maximize (MutterPluginManager *plugin_mgr,
case MUTTER_PLUGIN_MAXIMIZE:
if (klass->maximize)
{
mutter_plugin_manager_kill_effect (
mutter_plugin_manager_kill_window_effects (
plugin_mgr,
actor,
ALL_BUT_SWITCH);
actor);
_mutter_plugin_effect_started (plugin);
klass->maximize (plugin, actor,
@ -554,10 +565,9 @@ mutter_plugin_manager_event_maximize (MutterPluginManager *plugin_mgr,
case MUTTER_PLUGIN_UNMAXIMIZE:
if (klass->unmaximize)
{
mutter_plugin_manager_kill_effect (
mutter_plugin_manager_kill_window_effects (
plugin_mgr,
actor,
ALL_BUT_SWITCH);
actor);
_mutter_plugin_effect_started (plugin);
klass->unmaximize (plugin, actor,
@ -586,7 +596,6 @@ mutter_plugin_manager_event_maximize (MutterPluginManager *plugin_mgr,
*/
gboolean
mutter_plugin_manager_switch_workspace (MutterPluginManager *plugin_mgr,
const GList **actors,
gint from,
gint to,
MetaMotionDirection direction)
@ -604,19 +613,15 @@ mutter_plugin_manager_switch_workspace (MutterPluginManager *plugin_mgr,
MutterPluginClass *klass = MUTTER_PLUGIN_GET_CLASS (plugin);
if (!mutter_plugin_disabled (plugin) &&
(mutter_plugin_features (plugin) & MUTTER_PLUGIN_SWITCH_WORKSPACE) &&
(actors && *actors))
(mutter_plugin_features (plugin) & MUTTER_PLUGIN_SWITCH_WORKSPACE))
{
if (klass->switch_workspace)
{
retval = TRUE;
mutter_plugin_manager_kill_effect (
plugin_mgr,
MUTTER_WINDOW ((*actors)->data),
MUTTER_PLUGIN_SWITCH_WORKSPACE);
mutter_plugin_manager_kill_switch_workspace (plugin_mgr);
_mutter_plugin_effect_started (plugin);
klass->switch_workspace (plugin, actors, from, to, direction);
klass->switch_workspace (plugin, from, to, direction);
}
}

View File

@ -31,6 +31,15 @@
#include "mutter-plugin.h"
#undef MUTTER_PLUGIN_FROM_MANAGER_
#define MUTTER_PLUGIN_MINIMIZE (1<<0)
#define MUTTER_PLUGIN_MAXIMIZE (1<<1)
#define MUTTER_PLUGIN_UNMAXIMIZE (1<<2)
#define MUTTER_PLUGIN_MAP (1<<3)
#define MUTTER_PLUGIN_DESTROY (1<<4)
#define MUTTER_PLUGIN_SWITCH_WORKSPACE (1<<5)
#define MUTTER_PLUGIN_ALL_EFFECTS (~0)
typedef struct MutterPluginManager MutterPluginManager;
MutterPluginManager * mutter_plugin_manager_get (MetaScreen *screen);
@ -54,7 +63,6 @@ void mutter_plugin_manager_update_workspaces (MutterPluginManager *mgr);
void mutter_plugin_manager_update_workspace (MutterPluginManager *mgr, MetaWorkspace *w);
gboolean mutter_plugin_manager_switch_workspace (MutterPluginManager *mgr,
const GList **actors,
gint from,
gint to,
MetaMotionDirection direction);

View File

@ -367,9 +367,25 @@ _mutter_plugin_effect_started (MutterPlugin *plugin)
}
void
mutter_plugin_effect_completed (MutterPlugin *plugin,
MutterWindow *actor,
unsigned long event)
mutter_plugin_switch_workspace_completed (MutterPlugin *plugin)
{
MutterPluginPrivate *priv = MUTTER_PLUGIN (plugin)->priv;
MetaScreen *screen = mutter_plugin_get_screen (plugin);
if (priv->running-- < 0)
{
g_warning ("Error in running effect accounting, adjusting.");
priv->running = 0;
}
mutter_switch_workspace_completed (screen);
}
static void
mutter_plugin_window_effect_completed (MutterPlugin *plugin,
MutterWindow *actor,
unsigned long event)
{
MutterPluginPrivate *priv = MUTTER_PLUGIN (plugin)->priv;
@ -391,17 +407,42 @@ mutter_plugin_effect_completed (MutterPlugin *plugin,
name ? name : "unknown");
}
if (event == MUTTER_PLUGIN_SWITCH_WORKSPACE)
{
/* The window is just used to identify the screen */
MetaWindow *window = mutter_window_get_meta_window (actor);
MetaScreen *screen = meta_window_get_screen (window);
mutter_switch_workspace_completed (screen);
}
else
{
mutter_window_effect_completed (actor, event);
}
mutter_window_effect_completed (actor, event);
}
void
mutter_plugin_minimize_completed (MutterPlugin *plugin,
MutterWindow *actor)
{
mutter_plugin_window_effect_completed (plugin, actor, MUTTER_PLUGIN_MINIMIZE);
}
void
mutter_plugin_maximize_completed (MutterPlugin *plugin,
MutterWindow *actor)
{
mutter_plugin_window_effect_completed (plugin, actor, MUTTER_PLUGIN_MAXIMIZE);
}
void
mutter_plugin_unmaximize_completed (MutterPlugin *plugin,
MutterWindow *actor)
{
mutter_plugin_window_effect_completed (plugin, actor, MUTTER_PLUGIN_UNMAXIMIZE);
}
void
mutter_plugin_map_completed (MutterPlugin *plugin,
MutterWindow *actor)
{
mutter_plugin_window_effect_completed (plugin, actor, MUTTER_PLUGIN_MAP);
}
void
mutter_plugin_destroy_completed (MutterPlugin *plugin,
MutterWindow *actor)
{
mutter_plugin_window_effect_completed (plugin, actor, MUTTER_PLUGIN_DESTROY);
}
void

View File

@ -81,11 +81,12 @@ static void unmaximize (MutterPlugin *plugin,
gint x, gint y, gint width, gint height);
static void switch_workspace (MutterPlugin *plugin,
const GList **actors, gint from, gint to,
gint from, gint to,
MetaMotionDirection direction);
static void kill_effect (MutterPlugin *plugin,
MutterWindow *actor, gulong event);
static void kill_window_effects (MutterPlugin *plugin,
MutterWindow *actor);
static void kill_switch_workspace (MutterPlugin *plugin);
static const MutterPluginInfo * plugin_info (MutterPlugin *plugin);
@ -99,7 +100,6 @@ struct _MutterDefaultPluginPrivate
/* Valid only when switch_workspace effect is in progress */
ClutterTimeline *tml_switch_workspace1;
ClutterTimeline *tml_switch_workspace2;
GList **actors;
ClutterActor *desktop1;
ClutterActor *desktop2;
@ -220,8 +220,9 @@ mutter_default_plugin_class_init (MutterDefaultPluginClass *klass)
plugin_class->unmaximize = unmaximize;
plugin_class->destroy = destroy;
plugin_class->switch_workspace = switch_workspace;
plugin_class->kill_effect = kill_effect;
plugin_class->plugin_info = plugin_info;
plugin_class->kill_window_effects = kill_window_effects;
plugin_class->kill_switch_workspace = kill_switch_workspace;
g_type_class_add_private (gobject_class, sizeof (MutterDefaultPluginPrivate));
}
@ -270,20 +271,12 @@ get_actor_private (MutterWindow *actor)
return priv;
}
typedef struct SwitchWorkspaceData
{
MutterPlugin *plugin;
const GList **actors;
} SwitchWorkspaceData;
static void
on_switch_workspace_effect_complete (ClutterTimeline *timeline, gpointer data)
{
SwitchWorkspaceData *sw_data = data;
MutterPlugin *plugin = sw_data->plugin;
MutterPlugin *plugin = MUTTER_PLUGIN (data);
MutterDefaultPluginPrivate *priv = MUTTER_DEFAULT_PLUGIN (plugin)->priv;
GList *l = *((GList**)sw_data->actors);
MutterWindow *actor_for_cb = l->data;
GList *l = mutter_plugin_get_windows (plugin);
while (l)
{
@ -303,21 +296,17 @@ on_switch_workspace_effect_complete (ClutterTimeline *timeline, gpointer data)
clutter_actor_destroy (priv->desktop1);
clutter_actor_destroy (priv->desktop2);
priv->actors = NULL;
priv->tml_switch_workspace1 = NULL;
priv->tml_switch_workspace2 = NULL;
priv->desktop1 = NULL;
priv->desktop2 = NULL;
g_free (data);
mutter_plugin_effect_completed (plugin, actor_for_cb,
MUTTER_PLUGIN_SWITCH_WORKSPACE);
mutter_plugin_switch_workspace_completed (plugin);
}
static void
switch_workspace (MutterPlugin *plugin,
const GList **actors, gint from, gint to,
gint from, gint to,
MetaMotionDirection direction)
{
MutterDefaultPluginPrivate *priv = MUTTER_DEFAULT_PLUGIN (plugin)->priv;
@ -328,12 +317,8 @@ switch_workspace (MutterPlugin *plugin,
ClutterActor *stage;
int screen_width, screen_height;
MetaScreen *screen = mutter_plugin_get_screen (plugin);
SwitchWorkspaceData *sw_data = g_new (SwitchWorkspaceData, 1);
ClutterAnimation *animation;
sw_data->plugin = plugin;
sw_data->actors = actors;
stage = mutter_plugin_get_stage (plugin);
mutter_plugin_query_screen_size (plugin,
@ -353,14 +338,13 @@ switch_workspace (MutterPlugin *plugin,
if (from == to)
{
mutter_plugin_effect_completed (plugin, NULL,
MUTTER_PLUGIN_SWITCH_WORKSPACE);
mutter_plugin_switch_workspace_completed (plugin);
return;
}
n_workspaces = meta_screen_get_n_workspaces (screen);
l = g_list_last (*((GList**) actors));
l = g_list_last (mutter_plugin_get_windows (plugin));
while (l)
{
@ -395,7 +379,6 @@ switch_workspace (MutterPlugin *plugin,
l = l->prev;
}
priv->actors = (GList **)actors;
priv->desktop1 = workspace0;
priv->desktop2 = workspace1;
@ -408,7 +391,7 @@ switch_workspace (MutterPlugin *plugin,
g_signal_connect (priv->tml_switch_workspace1,
"completed",
G_CALLBACK (on_switch_workspace_effect_complete),
sw_data);
plugin);
animation = clutter_actor_animate (workspace1, CLUTTER_EASE_IN_SINE,
SWITCH_TIMEOUT,
@ -446,8 +429,7 @@ on_minimize_effect_complete (ClutterTimeline *timeline, EffectCompleteData *data
CLUTTER_GRAVITY_NORTH_WEST);
/* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (plugin, mc_window,
MUTTER_PLUGIN_MINIMIZE);
mutter_plugin_minimize_completed (plugin, mc_window);
g_free (data);
}
@ -490,8 +472,7 @@ minimize (MutterPlugin *plugin, MutterWindow *mc_window)
}
else
mutter_plugin_effect_completed (plugin, mc_window,
MUTTER_PLUGIN_MINIMIZE);
mutter_plugin_minimize_completed (plugin, mc_window);
}
/*
@ -516,8 +497,7 @@ on_maximize_effect_complete (ClutterTimeline *timeline, EffectCompleteData *data
CLUTTER_GRAVITY_NORTH_WEST);
/* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (plugin, mc_window,
MUTTER_PLUGIN_MAXIMIZE);
mutter_plugin_maximize_completed (plugin, mc_window);
g_free (data);
}
@ -587,8 +567,7 @@ maximize (MutterPlugin *plugin,
return;
}
mutter_plugin_effect_completed (plugin, mc_window,
MUTTER_PLUGIN_MAXIMIZE);
mutter_plugin_maximize_completed (plugin, mc_window);
}
/*
@ -611,8 +590,7 @@ unmaximize (MutterPlugin *plugin,
}
/* Do this conditionally, if the effect requires completion callback. */
mutter_plugin_effect_completed (plugin, mc_window,
MUTTER_PLUGIN_UNMAXIMIZE);
mutter_plugin_unmaximize_completed (plugin, mc_window);
}
static void
@ -631,7 +609,7 @@ on_map_effect_complete (ClutterTimeline *timeline, EffectCompleteData *data)
CLUTTER_GRAVITY_NORTH_WEST);
/* Now notify the manager that we are done with this effect */
mutter_plugin_effect_completed (plugin, mc_window, MUTTER_PLUGIN_MAP);
mutter_plugin_map_completed (plugin, mc_window);
g_free (data);
}
@ -677,8 +655,7 @@ map (MutterPlugin *plugin, MutterWindow *mc_window)
}
else
mutter_plugin_effect_completed (plugin, mc_window,
MUTTER_PLUGIN_MAP);
mutter_plugin_map_completed (plugin, mc_window);
}
/*
@ -694,8 +671,7 @@ on_destroy_effect_complete (ClutterTimeline *timeline, EffectCompleteData *data)
apriv->tml_destroy = NULL;
mutter_plugin_effect_completed (plugin, mc_window,
MUTTER_PLUGIN_DESTROY);
mutter_plugin_destroy_completed (plugin, mc_window);
}
/*
@ -732,54 +708,48 @@ destroy (MutterPlugin *plugin, MutterWindow *mc_window)
data);
}
else
mutter_plugin_effect_completed (plugin, mc_window,
MUTTER_PLUGIN_DESTROY);
mutter_plugin_destroy_completed (plugin, mc_window);
}
static void
kill_effect (MutterPlugin *plugin, MutterWindow *mc_window, gulong event)
kill_switch_workspace (MutterPlugin *plugin)
{
MutterDefaultPluginPrivate *priv = MUTTER_DEFAULT_PLUGIN (plugin)->priv;
if (priv->tml_switch_workspace1)
{
clutter_timeline_stop (priv->tml_switch_workspace1);
clutter_timeline_stop (priv->tml_switch_workspace2);
g_signal_emit_by_name (priv->tml_switch_workspace1, "completed", NULL);
}
}
static void
kill_window_effects (MutterPlugin *plugin, MutterWindow *mc_window)
{
ActorPrivate *apriv;
if (event & MUTTER_PLUGIN_SWITCH_WORKSPACE)
{
MutterDefaultPluginPrivate *priv = MUTTER_DEFAULT_PLUGIN (plugin)->priv;
if (priv->tml_switch_workspace1)
{
clutter_timeline_stop (priv->tml_switch_workspace1);
clutter_timeline_stop (priv->tml_switch_workspace2);
g_signal_emit_by_name (priv->tml_switch_workspace1, "completed", NULL);
}
if (!(event & ~MUTTER_PLUGIN_SWITCH_WORKSPACE))
{
/* Workspace switch only, nothing more to do */
return;
}
}
apriv = get_actor_private (mc_window);
if ((event & MUTTER_PLUGIN_MINIMIZE) && apriv->tml_minimize)
if (apriv->tml_minimize)
{
clutter_timeline_stop (apriv->tml_minimize);
g_signal_emit_by_name (apriv->tml_minimize, "completed", NULL);
}
if ((event & MUTTER_PLUGIN_MAXIMIZE) && apriv->tml_maximize)
if (apriv->tml_maximize)
{
clutter_timeline_stop (apriv->tml_maximize);
g_signal_emit_by_name (apriv->tml_maximize, "completed", NULL);
}
if ((event & MUTTER_PLUGIN_MAP) && apriv->tml_map)
if (apriv->tml_map)
{
clutter_timeline_stop (apriv->tml_map);
g_signal_emit_by_name (apriv->tml_map, "completed", NULL);
}
if ((event & MUTTER_PLUGIN_DESTROY) && apriv->tml_destroy)
if (apriv->tml_destroy)
{
clutter_timeline_stop (apriv->tml_destroy);
g_signal_emit_by_name (apriv->tml_destroy, "completed", NULL);

View File

@ -32,19 +32,6 @@
#include <X11/extensions/Xfixes.h>
#include <gmodule.h>
/*
* FIXME -- move these to a private include
* Required by plugin manager.
*/
#define MUTTER_PLUGIN_MINIMIZE (1<<0)
#define MUTTER_PLUGIN_MAXIMIZE (1<<1)
#define MUTTER_PLUGIN_UNMAXIMIZE (1<<2)
#define MUTTER_PLUGIN_MAP (1<<3)
#define MUTTER_PLUGIN_DESTROY (1<<4)
#define MUTTER_PLUGIN_SWITCH_WORKSPACE (1<<5)
#define MUTTER_PLUGIN_ALL_EFFECTS (~0)
#define MUTTER_TYPE_PLUGIN (mutter_plugin_get_type ())
#define MUTTER_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MUTTER_TYPE_PLUGIN, MutterPlugin))
#define MUTTER_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MUTTER_TYPE_PLUGIN, MutterPluginClass))
@ -95,20 +82,18 @@ struct _MutterPluginClass
MutterWindow *actor);
void (*switch_workspace) (MutterPlugin *plugin,
const GList **actors,
gint from,
gint to,
MetaMotionDirection direction);
/*
* Called if an effect should be killed prematurely; the plugin must
* Called if an effects should be killed prematurely; the plugin must
* call the completed() callback as if the effect terminated naturally.
* The events parameter is a bitmask indicating which effects are to be
* killed.
*/
void (*kill_effect) (MutterPlugin *plugin,
MutterWindow *actor,
gulong events);
void (*kill_window_effects) (MutterPlugin *plugin,
MutterWindow *actor);
void (*kill_switch_workspace) (MutterPlugin *plugin);
/* General XEvent filter. This is fired *before* mutter itself handles
* an event. Return TRUE to block any further processing.
@ -227,9 +212,27 @@ struct _MutterPluginVersion
} \
void
mutter_plugin_effect_completed (MutterPlugin *plugin,
MutterWindow *actor,
unsigned long event);
mutter_plugin_switch_workspace_completed (MutterPlugin *plugin);
void
mutter_plugin_minimize_completed (MutterPlugin *plugin,
MutterWindow *actor);
void
mutter_plugin_maximize_completed (MutterPlugin *plugin,
MutterWindow *actor);
void
mutter_plugin_unmaximize_completed (MutterPlugin *plugin,
MutterWindow *actor);
void
mutter_plugin_map_completed (MutterPlugin *plugin,
MutterWindow *actor);
void
mutter_plugin_destroy_completed (MutterPlugin *plugin,
MutterWindow *actor);
ClutterActor *
mutter_plugin_get_overlay_group (MutterPlugin *plugin);