Removed plugin .features member (no longer required); reanambled all effects in scratch plugin by popular demand.

This commit is contained in:
Tomas Frydrych 2008-10-20 13:04:46 +01:00
parent 73f90dfd69
commit 775cb1f4a4
4 changed files with 36 additions and 72 deletions

View File

@ -55,7 +55,7 @@ typedef struct MutterPluginPrivate
/* We use this to track the number of effects currently being managed /* We use this to track the number of effects currently being managed
* by a plugin. Currently this is used to block unloading while effects * by a plugin. Currently this is used to block unloading while effects
* are in progress. */ * are in progress. */
gint running; gint running;
gboolean disabled : 1; gboolean disabled : 1;
} MutterPluginPrivate; } MutterPluginPrivate;
@ -122,9 +122,32 @@ update_plugin_workspaces (MetaScreen *screen,
* the user has disabled. * the user has disabled.
*/ */
static gulong static gulong
parse_disable_params (const char *params, gulong features) parse_disable_params (const char *params, MutterPlugin *plugin)
{ {
char *p; char *p;
gulong features = 0;
/*
* Feature flags: identify events that the plugin can handle; a plugin can
* handle one or more events.
*/
if (plugin->minimize)
features |= MUTTER_PLUGIN_MINIMIZE;
if (plugin->maximize)
features |= MUTTER_PLUGIN_MAXIMIZE;
if (plugin->unmaximize)
features |= MUTTER_PLUGIN_UNMAXIMIZE;
if (plugin->map)
features |= MUTTER_PLUGIN_MAP;
if (plugin->destroy)
features |= MUTTER_PLUGIN_DESTROY;
if (plugin->switch_workspace)
features |= MUTTER_PLUGIN_SWITCH_WORKSPACE;
if (!params) if (!params)
return features; return features;
@ -191,7 +214,7 @@ mutter_plugin_load (
update_plugin_workspaces (plugin_mgr->screen, plugin); update_plugin_workspaces (plugin_mgr->screen, plugin);
priv->features = parse_disable_params (params, plugin->features); priv->features = parse_disable_params (params, plugin);
/* /*
* Check for and run the plugin init function. * Check for and run the plugin init function.
@ -516,7 +539,7 @@ mutter_plugin_manager_kill_effect (
MutterPluginPrivate *priv = plugin->manager_private; MutterPluginPrivate *priv = plugin->manager_private;
if (!priv->disabled if (!priv->disabled
&& (plugin->features & events) && (priv->features & events)
&& plugin->kill_effect) && plugin->kill_effect)
plugin->kill_effect (actor, events); plugin->kill_effect (actor, events);
@ -550,7 +573,7 @@ mutter_plugin_manager_event_simple (
MutterPlugin *plugin = l->data; MutterPlugin *plugin = l->data;
MutterPluginPrivate *priv = plugin->manager_private; MutterPluginPrivate *priv = plugin->manager_private;
if (!priv->disabled && (plugin->features & event)) if (!priv->disabled && (priv->features & event))
{ {
retval = TRUE; retval = TRUE;
@ -625,7 +648,7 @@ mutter_plugin_manager_event_maximize (
MutterPlugin *plugin = l->data; MutterPlugin *plugin = l->data;
MutterPluginPrivate *priv = plugin->manager_private; MutterPluginPrivate *priv = plugin->manager_private;
if (!priv->disabled && (plugin->features & event)) if (!priv->disabled && (priv->features & event))
{ {
retval = TRUE; retval = TRUE;
@ -692,7 +715,7 @@ mutter_plugin_manager_switch_workspace (
MutterPluginPrivate *priv = plugin->manager_private; MutterPluginPrivate *priv = plugin->manager_private;
if (!priv->disabled && if (!priv->disabled &&
(plugin->features & MUTTER_PLUGIN_SWITCH_WORKSPACE) && (priv->features & MUTTER_PLUGIN_SWITCH_WORKSPACE) &&
(actors && *actors)) (actors && *actors))
{ {
if (plugin->switch_workspace) if (plugin->switch_workspace)

View File

@ -79,16 +79,7 @@ G_MODULE_EXPORT MutterPlugin mutter_plugin =
/* Plugin load time initialiser */ /* Plugin load time initialiser */
.do_init = do_init, .do_init = do_init,
/* Which types of events this plugin supports */ /* Effect handlers */
.features = MUTTER_PLUGIN_MINIMIZE |
MUTTER_PLUGIN_DESTROY |
MUTTER_PLUGIN_MAP |
MUTTER_PLUGIN_MAXIMIZE |
MUTTER_PLUGIN_UNMAXIMIZE |
MUTTER_PLUGIN_SWITCH_WORKSPACE,
/* And the corresponding handlers */
.minimize = minimize, .minimize = minimize,
.destroy = destroy, .destroy = destroy,
.map = map, .map = map,
@ -590,12 +581,6 @@ kill_effect (MutterWindow *mc_window, gulong event)
ActorPrivate *apriv; ActorPrivate *apriv;
ClutterActor *actor = CLUTTER_ACTOR (mc_window); ClutterActor *actor = CLUTTER_ACTOR (mc_window);
if (!(plugin->features & event))
{
/* Event we do not support */
return;
}
if (event & MUTTER_PLUGIN_SWITCH_WORKSPACE) if (event & MUTTER_PLUGIN_SWITCH_WORKSPACE)
{ {
PluginState *state = plugin_state; PluginState *state = plugin_state;

View File

@ -83,12 +83,7 @@ G_MODULE_EXPORT MutterPlugin mutter_plugin =
/* Plugin load time initialiser */ /* Plugin load time initialiser */
.do_init = do_init, .do_init = do_init,
/* Which types of events this plugin supports */ /* Effect handlers */
/* This plugin only uses the xevent callback for now */
.features = 0,
/* And the corresponding handlers */
.minimize = minimize, .minimize = minimize,
.destroy = destroy, .destroy = destroy,
.map = map, .map = map,
@ -649,12 +644,6 @@ kill_effect (MutterWindow *mcw, gulong event)
ActorPrivate *apriv; ActorPrivate *apriv;
ClutterActor *actor = CLUTTER_ACTOR (mcw); ClutterActor *actor = CLUTTER_ACTOR (mcw);
if (!(plugin->features & event))
{
/* Event we do not support */
return;
}
if (event & MUTTER_PLUGIN_SWITCH_WORKSPACE) if (event & MUTTER_PLUGIN_SWITCH_WORKSPACE)
{ {
PluginPrivate *ppriv = plugin->plugin_private; PluginPrivate *ppriv = plugin->plugin_private;
@ -814,8 +803,6 @@ do_init (const char *params)
if (params) if (params)
{ {
gchar *p;
if (strstr (params, "debug")) if (strstr (params, "debug"))
{ {
g_debug ("%s: Entering debug mode.", g_debug ("%s: Entering debug mode.",
@ -832,36 +819,6 @@ do_init (const char *params)
map_timeout *= 2; map_timeout *= 2;
switch_timeout *= 2; switch_timeout *= 2;
} }
if ((p = strstr (params, "disable:")))
{
gchar *d = g_strdup (p+8);
p = strchr (d, ';');
if (p)
*p = 0;
if (strstr (d, "minimize"))
plugin->features &= ~ MUTTER_PLUGIN_MINIMIZE;
if (strstr (d, "maximize"))
plugin->features &= ~ MUTTER_PLUGIN_MAXIMIZE;
if (strstr (d, "unmaximize"))
plugin->features &= ~ MUTTER_PLUGIN_UNMAXIMIZE;
if (strstr (d, "map"))
plugin->features &= ~ MUTTER_PLUGIN_MAP;
if (strstr (d, "destroy"))
plugin->features &= ~ MUTTER_PLUGIN_DESTROY;
if (strstr (d, "switch-workspace"))
plugin->features &= ~MUTTER_PLUGIN_SWITCH_WORKSPACE;
g_free (d);
}
} }
priv->destroy_effect priv->destroy_effect

View File

@ -44,8 +44,8 @@
typedef struct MutterPlugin MutterPlugin; typedef struct MutterPlugin MutterPlugin;
/* /*
* Feature flags: identify events that the plugin can handle; a plugin can * Effect flags: identify events that the plugin can handle, used by kill_effect
* handle one or more events. * function.
*/ */
#define MUTTER_PLUGIN_MINIMIZE (1<<0) #define MUTTER_PLUGIN_MINIMIZE (1<<0)
#define MUTTER_PLUGIN_MAXIMIZE (1<<1) #define MUTTER_PLUGIN_MAXIMIZE (1<<1)
@ -78,7 +78,6 @@ struct MutterPlugin
const const
#endif #endif
gchar *name; /* Human-readable name for UI */ gchar *name; /* Human-readable name for UI */
gulong features; /* or-ed feature flags */
/* /*
* This function is called once the plugin has been loaded. * This function is called once the plugin has been loaded.
@ -170,7 +169,7 @@ struct MutterPlugin
* killed. * killed.
*/ */
void (*kill_effect) (MutterWindow *actor, void (*kill_effect) (MutterWindow *actor,
gulong events); gulong events);
/* /*
* The plugin manager will call this function when module should be reloaded. * The plugin manager will call this function when module should be reloaded.