mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
Remove some unused plugin functionality
Revert the early_initialize changes (which get in the way in the "libmutter-wm" paradigm), remove the GConf key for setting plugins, and remove plugin "params", which weren't being used. Also remove all the logic for unloading and reloading plugins, since the list never changes after startup now. https://bugzilla.gnome.org/show_bug.cgi?id=643959
This commit is contained in:
parent
a66ae4ad55
commit
4c76791d4c
@ -7,7 +7,7 @@ m4_define([mutter_micro_version], [90])
|
||||
m4_define([mutter_version],
|
||||
[mutter_major_version.mutter_minor_version.mutter_micro_version])
|
||||
|
||||
m4_define([mutter_plugin_api_version], [4])
|
||||
m4_define([mutter_plugin_api_version], [3])
|
||||
|
||||
AC_INIT([mutter], [mutter_version],
|
||||
[http://bugzilla.gnome.org/enter_bug.cgi?product=mutter])
|
||||
|
@ -550,18 +550,7 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
||||
|
||||
info->plugin_mgr =
|
||||
meta_plugin_manager_get (screen);
|
||||
|
||||
if (info->plugin_mgr != meta_plugin_manager_get_default ())
|
||||
{
|
||||
/* The default plugin manager has been initialized during
|
||||
* global preferences load.
|
||||
*/
|
||||
if (!meta_plugin_manager_load (info->plugin_mgr))
|
||||
g_critical ("failed to load plugins");
|
||||
}
|
||||
|
||||
if (!meta_plugin_manager_initialize (info->plugin_mgr))
|
||||
g_critical ("failed to initialize plugins");
|
||||
meta_plugin_manager_initialize (info->plugin_mgr);
|
||||
|
||||
/*
|
||||
* Delay the creation of the overlay window as long as we can, to avoid
|
||||
|
@ -35,10 +35,7 @@
|
||||
|
||||
#include <clutter/x11/clutter-x11.h>
|
||||
|
||||
/*
|
||||
* There is only one instace of each module per the process.
|
||||
*/
|
||||
static GHashTable *plugin_modules = NULL;
|
||||
static GSList *plugin_types;
|
||||
|
||||
/*
|
||||
* We have one "default plugin manager" that acts for the first screen,
|
||||
@ -46,250 +43,35 @@ static GHashTable *plugin_modules = NULL;
|
||||
* plugin managers for each screen. (This is ugly. Probably we should
|
||||
* have one plugin manager and only make the plugins per-screen.)
|
||||
*/
|
||||
|
||||
static MetaPluginManager *default_plugin_manager;
|
||||
|
||||
static gboolean meta_plugin_manager_reload (MetaPluginManager *plugin_mgr);
|
||||
|
||||
struct MetaPluginManager
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
||||
gboolean plugin_load_attempted;
|
||||
|
||||
GList /* MetaPlugin */ *plugins; /* TODO -- maybe use hash table */
|
||||
GList *unload; /* Plugins that are disabled and pending unload */
|
||||
|
||||
guint idle_unload_id;
|
||||
};
|
||||
|
||||
/*
|
||||
* Checks that the plugin is compatible with the WM and sets up the plugin
|
||||
* struct.
|
||||
* Loads the given plugin.
|
||||
*/
|
||||
static MetaPlugin *
|
||||
meta_plugin_load (MetaPluginManager *mgr,
|
||||
MetaModule *module,
|
||||
const gchar *params)
|
||||
{
|
||||
MetaPlugin *plugin = NULL;
|
||||
GType plugin_type = meta_module_get_plugin_type (module);
|
||||
|
||||
if (!plugin_type)
|
||||
{
|
||||
g_warning ("Plugin type not registered !!!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
plugin = g_object_new (plugin_type,
|
||||
"params", params,
|
||||
NULL);
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempst to unload a plugin; returns FALSE if plugin cannot be unloaded at
|
||||
* present (e.g., and effect is in progress) and should be scheduled for
|
||||
* removal later.
|
||||
*/
|
||||
static gboolean
|
||||
meta_plugin_unload (MetaPlugin *plugin)
|
||||
{
|
||||
if (meta_plugin_running (plugin))
|
||||
{
|
||||
g_object_set (plugin, "disabled", TRUE, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_object_unref (plugin);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Iddle callback to remove plugins that could not be removed directly and are
|
||||
* pending for removal.
|
||||
*/
|
||||
static gboolean
|
||||
meta_plugin_manager_idle_unload (MetaPluginManager *plugin_mgr)
|
||||
{
|
||||
GList *l = plugin_mgr->unload;
|
||||
gboolean dont_remove = TRUE;
|
||||
|
||||
while (l)
|
||||
{
|
||||
MetaPlugin *plugin = l->data;
|
||||
|
||||
if (meta_plugin_unload (plugin))
|
||||
{
|
||||
/* Remove from list */
|
||||
GList *p = l->prev;
|
||||
GList *n = l->next;
|
||||
|
||||
if (!p)
|
||||
plugin_mgr->unload = n;
|
||||
else
|
||||
p->next = n;
|
||||
|
||||
if (n)
|
||||
n->prev = p;
|
||||
|
||||
g_list_free_1 (l);
|
||||
|
||||
l = n;
|
||||
}
|
||||
else
|
||||
l = l->next;
|
||||
}
|
||||
|
||||
if (!plugin_mgr->unload)
|
||||
{
|
||||
/* If no more unloads are pending, remove the handler as well */
|
||||
dont_remove = FALSE;
|
||||
plugin_mgr->idle_unload_id = 0;
|
||||
}
|
||||
|
||||
return dont_remove;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unloads all plugins
|
||||
*/
|
||||
static void
|
||||
meta_plugin_manager_unload (MetaPluginManager *plugin_mgr)
|
||||
{
|
||||
GList *plugins = plugin_mgr->plugins;
|
||||
|
||||
while (plugins)
|
||||
{
|
||||
MetaPlugin *plugin = plugins->data;
|
||||
|
||||
/* If the plugin could not be removed, move it to the unload list */
|
||||
if (!meta_plugin_unload (plugin))
|
||||
{
|
||||
plugin_mgr->unload = g_list_prepend (plugin_mgr->unload, plugin);
|
||||
|
||||
if (!plugin_mgr->idle_unload_id)
|
||||
{
|
||||
plugin_mgr->idle_unload_id = g_idle_add ((GSourceFunc)
|
||||
meta_plugin_manager_idle_unload,
|
||||
plugin_mgr);
|
||||
}
|
||||
}
|
||||
|
||||
plugins = plugins->next;
|
||||
}
|
||||
|
||||
g_list_free (plugin_mgr->plugins);
|
||||
plugin_mgr->plugins = NULL;
|
||||
|
||||
plugin_mgr->plugin_load_attempted = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_changed_callback (MetaPreference pref,
|
||||
void *data)
|
||||
{
|
||||
MetaPluginManager *plugin_mgr = data;
|
||||
|
||||
if (pref == META_PREF_CLUTTER_PLUGINS)
|
||||
{
|
||||
meta_plugin_manager_reload (plugin_mgr);
|
||||
}
|
||||
}
|
||||
|
||||
static MetaModule *
|
||||
meta_plugin_manager_get_module (const gchar *path)
|
||||
{
|
||||
MetaModule *module = g_hash_table_lookup (plugin_modules, path);
|
||||
|
||||
if (!module &&
|
||||
(module = g_object_new (META_TYPE_MODULE, "path", path, NULL)))
|
||||
{
|
||||
g_hash_table_insert (plugin_modules, g_strdup (path), module);
|
||||
}
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads all plugins listed in gconf registry.
|
||||
*/
|
||||
gboolean
|
||||
meta_plugin_manager_load (MetaPluginManager *plugin_mgr)
|
||||
void
|
||||
meta_plugin_manager_load (MetaPluginManager *plugin_mgr,
|
||||
const gchar *plugin_name)
|
||||
{
|
||||
const gchar *dpath = MUTTER_PLUGIN_DIR "/";
|
||||
GSList *plugins, *fallback = NULL;
|
||||
|
||||
if (plugin_mgr->plugin_load_attempted)
|
||||
return TRUE;
|
||||
plugin_mgr->plugin_load_attempted = TRUE;
|
||||
|
||||
plugins = meta_prefs_get_clutter_plugins ();
|
||||
|
||||
if (!plugins)
|
||||
{
|
||||
/*
|
||||
* If no plugins are specified, try to load the default plugin.
|
||||
*/
|
||||
fallback = g_slist_append (fallback, "default");
|
||||
plugins = fallback;
|
||||
}
|
||||
|
||||
while (plugins)
|
||||
{
|
||||
gchar *plugin_string;
|
||||
gchar *params;
|
||||
|
||||
plugin_string = g_strdup (plugins->data);
|
||||
|
||||
if (plugin_string)
|
||||
{
|
||||
MetaModule *module;
|
||||
gchar *path;
|
||||
MetaModule *module;
|
||||
GType plugin_type;
|
||||
MetaPlugin *plugin;
|
||||
|
||||
params = strchr (plugin_string, ':');
|
||||
|
||||
if (params)
|
||||
{
|
||||
*params = 0;
|
||||
++params;
|
||||
}
|
||||
|
||||
if (g_path_is_absolute (plugin_string))
|
||||
path = g_strdup (plugin_string);
|
||||
if (g_path_is_absolute (plugin_name))
|
||||
path = g_strdup (plugin_name);
|
||||
else
|
||||
path = g_strconcat (dpath, plugin_string, ".so", NULL);
|
||||
path = g_strconcat (dpath, plugin_name, ".so", NULL);
|
||||
|
||||
module = meta_plugin_manager_get_module (path);
|
||||
|
||||
if (module)
|
||||
{
|
||||
gboolean use_succeeded;
|
||||
|
||||
/*
|
||||
* This dlopens the module and registers the plugin type with the
|
||||
* GType system, if the module is not already loaded. When we
|
||||
* create a plugin, the type system also calls g_type_module_use()
|
||||
* to guarantee the module will not be unloaded during the plugin
|
||||
* life time. Consequently we can unuse() the module again.
|
||||
*/
|
||||
use_succeeded = g_type_module_use (G_TYPE_MODULE (module));
|
||||
|
||||
if (use_succeeded)
|
||||
{
|
||||
MetaPlugin *plugin = meta_plugin_load (plugin_mgr, module, params);
|
||||
|
||||
if (plugin)
|
||||
plugin_mgr->plugins = g_list_prepend (plugin_mgr->plugins, plugin);
|
||||
else
|
||||
g_warning ("Plugin load for [%s] failed", path);
|
||||
|
||||
g_type_module_unuse (G_TYPE_MODULE (module));
|
||||
}
|
||||
}
|
||||
else
|
||||
module = g_object_new (META_TYPE_MODULE, "path", path, NULL);
|
||||
if (!module || !g_type_module_use (G_TYPE_MODULE (module)))
|
||||
{
|
||||
/* This is fatal under the assumption that a monitoring
|
||||
* process like gnome-session will take over and handle
|
||||
@ -300,59 +82,29 @@ meta_plugin_manager_load (MetaPluginManager *plugin_mgr)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
plugin_type = meta_module_get_plugin_type (module);
|
||||
plugin_types = g_slist_prepend (plugin_types, GSIZE_TO_POINTER (plugin_type));
|
||||
|
||||
plugin = g_object_new (plugin_type, NULL);
|
||||
plugin_mgr->plugins = g_list_prepend (plugin_mgr->plugins, plugin);
|
||||
|
||||
g_type_module_unuse (G_TYPE_MODULE (module));
|
||||
g_free (path);
|
||||
g_free (plugin_string);
|
||||
}
|
||||
|
||||
plugins = plugins->next;
|
||||
}
|
||||
|
||||
|
||||
if (fallback)
|
||||
g_slist_free (fallback);
|
||||
|
||||
if (plugin_mgr->plugins != NULL)
|
||||
{
|
||||
meta_prefs_add_listener (prefs_changed_callback, plugin_mgr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_plugin_manager_initialize_early:
|
||||
* @plugin_mgr: a #MetaPluginManager
|
||||
*
|
||||
* This function invokes any plugin handling code that needs to be run
|
||||
* effectively immediately after we know which plugins are going to be
|
||||
* used. This means before the process has an X connection, or
|
||||
* talks to the session manager, for example.
|
||||
*
|
||||
* An example intended use is claiming DBus names.
|
||||
*/
|
||||
gboolean
|
||||
meta_plugin_manager_initialize_early (MetaPluginManager *plugin_mgr)
|
||||
{
|
||||
GList *iter;
|
||||
|
||||
for (iter = plugin_mgr->plugins; iter; iter = iter->next)
|
||||
{
|
||||
MetaPlugin *plugin = (MetaPlugin*) iter->data;
|
||||
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
||||
|
||||
if (klass->early_initialize)
|
||||
klass->early_initialize (plugin);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
meta_plugin_manager_initialize (MetaPluginManager *plugin_mgr)
|
||||
{
|
||||
GList *iter;
|
||||
|
||||
if (!plugin_mgr->plugins)
|
||||
{
|
||||
/*
|
||||
* If no plugins are specified, load the default plugin.
|
||||
*/
|
||||
meta_plugin_manager_load (plugin_mgr, "default");
|
||||
}
|
||||
|
||||
for (iter = plugin_mgr->plugins; iter; iter = iter->next)
|
||||
{
|
||||
MetaPlugin *plugin = (MetaPlugin*) iter->data;
|
||||
@ -365,26 +117,6 @@ meta_plugin_manager_initialize (MetaPluginManager *plugin_mgr)
|
||||
if (klass->start)
|
||||
klass->start (plugin);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reloads all plugins
|
||||
*/
|
||||
static gboolean
|
||||
meta_plugin_manager_reload (MetaPluginManager *plugin_mgr)
|
||||
{
|
||||
/* TODO -- brute force; should we build a list of plugins to load and list of
|
||||
* plugins to unload? We are probably not going to have large numbers of
|
||||
* plugins loaded at the same time, so it might not be worth it.
|
||||
*/
|
||||
|
||||
/* Prevent stale grabs on unloaded plugins */
|
||||
meta_check_end_modal (plugin_mgr->screen);
|
||||
|
||||
meta_plugin_manager_unload (plugin_mgr);
|
||||
return meta_plugin_manager_load (plugin_mgr);
|
||||
}
|
||||
|
||||
static MetaPluginManager *
|
||||
@ -392,14 +124,7 @@ meta_plugin_manager_new (MetaScreen *screen)
|
||||
{
|
||||
MetaPluginManager *plugin_mgr;
|
||||
|
||||
if (!plugin_modules)
|
||||
{
|
||||
plugin_modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
|
||||
NULL);
|
||||
}
|
||||
|
||||
plugin_mgr = g_new0 (MetaPluginManager, 1);
|
||||
|
||||
plugin_mgr->screen = screen;
|
||||
|
||||
if (screen)
|
||||
@ -441,7 +166,20 @@ meta_plugin_manager_get (MetaScreen *screen)
|
||||
}
|
||||
else
|
||||
{
|
||||
return meta_plugin_manager_new (screen);
|
||||
GSList *iter;
|
||||
GType plugin_type;
|
||||
MetaPlugin *plugin;
|
||||
|
||||
plugin_mgr = meta_plugin_manager_new (screen);
|
||||
|
||||
for (iter = plugin_types; iter; iter = iter->next)
|
||||
{
|
||||
plugin_type = (GType)GPOINTER_TO_SIZE (iter->data);
|
||||
plugin = g_object_new (plugin_type, "screen", screen, NULL);
|
||||
plugin_mgr->plugins = g_list_prepend (plugin_mgr->plugins, plugin);
|
||||
}
|
||||
|
||||
return plugin_mgr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,10 @@ typedef struct MetaPluginManager MetaPluginManager;
|
||||
MetaPluginManager * meta_plugin_manager_get (MetaScreen *screen);
|
||||
MetaPluginManager * meta_plugin_manager_get_default (void);
|
||||
|
||||
gboolean meta_plugin_manager_load (MetaPluginManager *mgr);
|
||||
gboolean meta_plugin_manager_initialize_early (MetaPluginManager *plugin_mgr);
|
||||
gboolean meta_plugin_manager_initialize (MetaPluginManager *plugin_mgr);
|
||||
void meta_plugin_manager_load (MetaPluginManager *mgr,
|
||||
const gchar *plugin_name);
|
||||
void meta_plugin_manager_initialize (MetaPluginManager *mgr);
|
||||
|
||||
gboolean meta_plugin_manager_event_simple (MetaPluginManager *mgr,
|
||||
MetaWindowActor *actor,
|
||||
unsigned long event);
|
||||
|
@ -43,7 +43,6 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_SCREEN,
|
||||
PROP_PARAMS,
|
||||
PROP_FEATURES,
|
||||
PROP_DISABLED,
|
||||
PROP_DEBUG_MODE,
|
||||
@ -52,7 +51,6 @@ enum
|
||||
struct _MetaPluginPrivate
|
||||
{
|
||||
MetaScreen *screen;
|
||||
gchar *params;
|
||||
gulong features;
|
||||
|
||||
gint running;
|
||||
@ -70,95 +68,38 @@ meta_plugin_dispose (GObject *object)
|
||||
static void
|
||||
meta_plugin_finalize (GObject *object)
|
||||
{
|
||||
MetaPluginPrivate *priv = META_PLUGIN (object)->priv;
|
||||
|
||||
g_free (priv->params);
|
||||
priv->params = NULL;
|
||||
|
||||
G_OBJECT_CLASS (meta_plugin_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_plugin_parse_params (MetaPlugin *plugin)
|
||||
meta_plugin_set_features (MetaPlugin *plugin)
|
||||
{
|
||||
char *p;
|
||||
gulong features = 0;
|
||||
MetaPluginPrivate *priv = plugin->priv;
|
||||
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
||||
|
||||
/*
|
||||
priv->features = 0;
|
||||
|
||||
/*
|
||||
* Feature flags: identify events that the plugin can handle; a plugin can
|
||||
* handle one or more events.
|
||||
*/
|
||||
if (klass->minimize)
|
||||
features |= META_PLUGIN_MINIMIZE;
|
||||
priv->features |= META_PLUGIN_MINIMIZE;
|
||||
|
||||
if (klass->maximize)
|
||||
features |= META_PLUGIN_MAXIMIZE;
|
||||
priv->features |= META_PLUGIN_MAXIMIZE;
|
||||
|
||||
if (klass->unmaximize)
|
||||
features |= META_PLUGIN_UNMAXIMIZE;
|
||||
priv->features |= META_PLUGIN_UNMAXIMIZE;
|
||||
|
||||
if (klass->map)
|
||||
features |= META_PLUGIN_MAP;
|
||||
priv->features |= META_PLUGIN_MAP;
|
||||
|
||||
if (klass->destroy)
|
||||
features |= META_PLUGIN_DESTROY;
|
||||
priv->features |= META_PLUGIN_DESTROY;
|
||||
|
||||
if (klass->switch_workspace)
|
||||
features |= META_PLUGIN_SWITCH_WORKSPACE;
|
||||
|
||||
if (priv->params)
|
||||
{
|
||||
gboolean debug = FALSE;
|
||||
|
||||
if ((p = strstr (priv->params, "disable:")))
|
||||
{
|
||||
gchar *d = g_strdup (p+8);
|
||||
|
||||
p = strchr (d, ';');
|
||||
|
||||
if (p)
|
||||
*p = 0;
|
||||
|
||||
if (strstr (d, "minimize"))
|
||||
features &= ~ META_PLUGIN_MINIMIZE;
|
||||
|
||||
if (strstr (d, "maximize"))
|
||||
features &= ~ META_PLUGIN_MAXIMIZE;
|
||||
|
||||
if (strstr (d, "unmaximize"))
|
||||
features &= ~ META_PLUGIN_UNMAXIMIZE;
|
||||
|
||||
if (strstr (d, "map"))
|
||||
features &= ~ META_PLUGIN_MAP;
|
||||
|
||||
if (strstr (d, "destroy"))
|
||||
features &= ~ META_PLUGIN_DESTROY;
|
||||
|
||||
if (strstr (d, "switch-workspace"))
|
||||
features &= ~META_PLUGIN_SWITCH_WORKSPACE;
|
||||
|
||||
g_free (d);
|
||||
}
|
||||
|
||||
if (strstr (priv->params, "debug"))
|
||||
debug = TRUE;
|
||||
|
||||
if (debug != priv->debug)
|
||||
{
|
||||
priv->debug = debug;
|
||||
|
||||
g_object_notify (G_OBJECT (plugin), "debug-mode");
|
||||
}
|
||||
}
|
||||
|
||||
if (features != priv->features)
|
||||
{
|
||||
priv->features = features;
|
||||
|
||||
g_object_notify (G_OBJECT (plugin), "features");
|
||||
}
|
||||
priv->features |= META_PLUGIN_SWITCH_WORKSPACE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -174,10 +115,6 @@ meta_plugin_set_property (GObject *object,
|
||||
case PROP_SCREEN:
|
||||
priv->screen = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_PARAMS:
|
||||
priv->params = g_value_dup_string (value);
|
||||
meta_plugin_parse_params (META_PLUGIN (object));
|
||||
break;
|
||||
case PROP_DISABLED:
|
||||
priv->disabled = g_value_get_boolean (value);
|
||||
break;
|
||||
@ -203,9 +140,6 @@ meta_plugin_get_property (GObject *object,
|
||||
case PROP_SCREEN:
|
||||
g_value_set_object (value, priv->screen);
|
||||
break;
|
||||
case PROP_PARAMS:
|
||||
g_value_set_string (value, priv->params);
|
||||
break;
|
||||
case PROP_DISABLED:
|
||||
g_value_set_boolean (value, priv->disabled);
|
||||
break;
|
||||
@ -240,15 +174,6 @@ meta_plugin_class_init (MetaPluginClass *klass)
|
||||
META_TYPE_SCREEN,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_PARAMS,
|
||||
g_param_spec_string ("params",
|
||||
"Parameters",
|
||||
"Plugin Parameters",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_FEATURES,
|
||||
g_param_spec_ulong ("features",
|
||||
@ -282,6 +207,8 @@ meta_plugin_init (MetaPlugin *self)
|
||||
MetaPluginPrivate *priv;
|
||||
|
||||
self->priv = priv = META_PLUGIN_GET_PRIVATE (self);
|
||||
|
||||
meta_plugin_set_features (self);
|
||||
}
|
||||
|
||||
gulong
|
||||
|
@ -1,41 +0,0 @@
|
||||
|
||||
Plugins implement effects associated with WM events, such as window map,
|
||||
minimizing, maximizing, unmaximizing, destruction and workspace switching. The
|
||||
plugin API is documented in src/include/compositor-clutter-plugin.h; in
|
||||
addition the simple plugin can be used as a reference implementation.
|
||||
|
||||
The API is intended to be generic, exposing no implementation details of the WM
|
||||
to the plugins; this will facilitate reuse without modification with another WM
|
||||
(there are plans to use the same plugin API with Matchbox 2).
|
||||
|
||||
Multiple plugins can implement the same effect and be loaded at the same time;
|
||||
however, stacking arbitrary effects in this way might not work as expected;
|
||||
this is particularly true of more complex effects, such as those for workspace
|
||||
switching.
|
||||
|
||||
Plugins are installed in ${prefix}/lib/metacity/plugins/clutter; from there the
|
||||
WM will load plugins listed in the clutter_plugins key in the Metacity gconf
|
||||
general preferences group. Each entry in preferences has the format
|
||||
|
||||
'name: optional parameters'
|
||||
|
||||
where 'name' is the name of the library without the .so suffix.
|
||||
|
||||
As noted above, additional parameters can be passed to the plugin via the
|
||||
preference key. In such case, the plugin name is immediately followed by a
|
||||
colon, separating it from the parameters. Two common parameters should be
|
||||
handled by all plugins:
|
||||
|
||||
'debug' indicates that the plugin is run in a debug mode (what exactly that
|
||||
means is left to the plugin to determine).
|
||||
|
||||
'disable' parameter indicates which effects within the plugin should be
|
||||
disabled; the format of the disable parameter is
|
||||
|
||||
'disable: effect1[, effect2];'
|
||||
|
||||
where effect1, etc., matches the effects listed in the
|
||||
compositor-clutter-plugin.h file (currently one of 'map', 'destroy',
|
||||
'maximize', 'unmaximize', 'switch-workspace'). Example 'disable:
|
||||
minimize, maximize;'.
|
||||
|
@ -481,6 +481,7 @@ main (int argc, char **argv)
|
||||
guint i;
|
||||
GIOChannel *channel;
|
||||
GOptionContext *ctx;
|
||||
MetaPluginManager *mgr;
|
||||
|
||||
if (!g_thread_supported ())
|
||||
g_thread_init (NULL);
|
||||
@ -536,12 +537,18 @@ main (int argc, char **argv)
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
|
||||
#ifdef HAVE_INTROSPECTION
|
||||
g_irepository_prepend_search_path (MUTTER_PKGLIBDIR);
|
||||
#endif
|
||||
|
||||
/* Parse command line arguments.*/
|
||||
ctx = meta_parse_options (&argc, &argv, &meta_args);
|
||||
|
||||
if (meta_args.print_version)
|
||||
version ();
|
||||
|
||||
mgr = meta_plugin_manager_get_default ();
|
||||
|
||||
/* This must come before the introspect below, so we load all the plugins
|
||||
* in order to get their get_type functions.
|
||||
*/
|
||||
@ -549,38 +556,20 @@ main (int argc, char **argv)
|
||||
{
|
||||
char **plugins = g_strsplit (meta_args.mutter_plugins, ",", -1);
|
||||
char **plugin;
|
||||
GSList *plugins_list = NULL;
|
||||
|
||||
for (plugin = plugins; *plugin; plugin++)
|
||||
{
|
||||
g_strstrip (*plugin);
|
||||
plugins_list = g_slist_prepend (plugins_list, *plugin);
|
||||
meta_plugin_manager_load (mgr, *plugin);
|
||||
}
|
||||
|
||||
plugins_list = g_slist_reverse (plugins_list);
|
||||
meta_prefs_override_clutter_plugins (plugins_list);
|
||||
|
||||
g_slist_free(plugins_list);
|
||||
g_strfreev (plugins);
|
||||
}
|
||||
|
||||
#ifdef HAVE_INTROSPECTION
|
||||
g_irepository_prepend_search_path (MUTTER_PKGLIBDIR);
|
||||
if (meta_args.introspect)
|
||||
{
|
||||
GError *error = NULL;
|
||||
if (meta_args.mutter_plugins)
|
||||
{
|
||||
/* We need to load all plugins so that we can call their
|
||||
* get_type functions. We do not call
|
||||
* mutter_plugin_manager_initialize because almost nothing else
|
||||
* is initialized at this point, and we don't plan to run any real
|
||||
* plugin code.
|
||||
*/
|
||||
MetaPluginManager *mgr = meta_plugin_manager_get_default ();
|
||||
if (!meta_plugin_manager_load (mgr))
|
||||
g_critical ("failed to load plugins");
|
||||
}
|
||||
|
||||
if (!g_irepository_dump (meta_args.introspect, &error))
|
||||
{
|
||||
g_printerr ("failed to dump: %s\n", error->message);
|
||||
@ -590,17 +579,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Early initialization for plugins comes before almost anything
|
||||
else here */
|
||||
{
|
||||
MetaPluginManager *mgr = meta_plugin_manager_get_default ();
|
||||
|
||||
if (!meta_plugin_manager_load (mgr))
|
||||
g_error ("failed to load plugins");
|
||||
|
||||
meta_plugin_manager_initialize_early (mgr);
|
||||
}
|
||||
|
||||
meta_set_syncing (meta_args.sync || (g_getenv ("MUTTER_SYNC") != NULL));
|
||||
|
||||
meta_select_display (meta_args.display_name);
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "prefs.h"
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
#include "compositor/meta-plugin-manager.h"
|
||||
#ifdef HAVE_GCONF
|
||||
#include <gconf/gconf-client.h>
|
||||
#endif
|
||||
@ -66,8 +65,6 @@
|
||||
#define KEY_WORKSPACE_NAME_DIRECTORY "/apps/metacity/workspace_names"
|
||||
#define KEY_WORKSPACE_NAME_PREFIX "/apps/metacity/workspace_names/name_"
|
||||
|
||||
#define KEY_CLUTTER_PLUGINS "/apps/mutter/general/clutter_plugins"
|
||||
|
||||
#define KEY_LIVE_HIDDEN_WINDOWS "/apps/mutter/general/live_hidden_windows"
|
||||
|
||||
#define KEY_NO_TAB_POPUP "/apps/metacity/general/no_tab_popup"
|
||||
@ -115,9 +112,6 @@ static char *terminal_command = NULL;
|
||||
|
||||
static char *workspace_names[MAX_REASONABLE_WORKSPACES] = { NULL, };
|
||||
|
||||
static gboolean clutter_plugins_overridden = FALSE;
|
||||
static GSList *clutter_plugins = NULL;
|
||||
|
||||
static gboolean live_hidden_windows = FALSE;
|
||||
|
||||
static gboolean no_tab_popup = FALSE;
|
||||
@ -1051,7 +1045,6 @@ meta_prefs_init (void)
|
||||
#ifdef HAVE_GCONF
|
||||
GError *err = NULL;
|
||||
gchar **gconf_dir_cursor;
|
||||
MetaPluginManager *plugin_manager;
|
||||
|
||||
if (default_client != NULL)
|
||||
return;
|
||||
@ -1070,19 +1063,6 @@ meta_prefs_init (void)
|
||||
cleanup_error (&err);
|
||||
}
|
||||
|
||||
/* The plugin list is special and needs to be handled first */
|
||||
|
||||
if (!clutter_plugins_overridden)
|
||||
clutter_plugins = gconf_client_get_list (default_client, KEY_CLUTTER_PLUGINS,
|
||||
GCONF_VALUE_STRING, &err);
|
||||
|
||||
cleanup_error (&err);
|
||||
|
||||
/* We now initialize plugins so that they can override any preference locations */
|
||||
|
||||
plugin_manager = meta_plugin_manager_get_default ();
|
||||
meta_plugin_manager_load (plugin_manager);
|
||||
|
||||
/* Pick up initial values. */
|
||||
|
||||
handle_preference_init_enum ();
|
||||
@ -1396,23 +1376,6 @@ change_notify (GConfClient *client,
|
||||
{
|
||||
queue_changed (META_PREF_KEYBINDINGS);
|
||||
}
|
||||
else if (g_str_equal (key, KEY_CLUTTER_PLUGINS) && !clutter_plugins_overridden)
|
||||
{
|
||||
GError *err = NULL;
|
||||
GSList *l;
|
||||
|
||||
l = gconf_client_get_list (default_client, KEY_CLUTTER_PLUGINS,
|
||||
GCONF_VALUE_STRING, &err);
|
||||
|
||||
if (!l)
|
||||
{
|
||||
cleanup_error (&err);
|
||||
goto out;
|
||||
}
|
||||
|
||||
clutter_plugins = l;
|
||||
queue_changed (META_PREF_CLUTTER_PLUGINS);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_topic (META_DEBUG_PREFS, "Key %s doesn't mean anything to Mutter\n",
|
||||
@ -2006,9 +1969,6 @@ meta_preference_to_string (MetaPreference pref)
|
||||
case META_PREF_FORCE_FULLSCREEN:
|
||||
return "FORCE_FULLSCREEN";
|
||||
|
||||
case META_PREF_CLUTTER_PLUGINS:
|
||||
return "CLUTTER_PLUGINS";
|
||||
|
||||
case META_PREF_LIVE_HIDDEN_WINDOWS:
|
||||
return "LIVE_HIDDEN_WINDOWS";
|
||||
|
||||
@ -3000,52 +2960,6 @@ meta_prefs_get_force_fullscreen (void)
|
||||
return force_fullscreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_prefs_get_clutter_plugins:
|
||||
*
|
||||
* Returns: (transfer none) (element-type utf8): Plugin names to load
|
||||
*/
|
||||
GSList *
|
||||
meta_prefs_get_clutter_plugins (void)
|
||||
{
|
||||
return clutter_plugins;
|
||||
}
|
||||
|
||||
void
|
||||
meta_prefs_set_clutter_plugins (GSList *list)
|
||||
{
|
||||
#ifdef HAVE_GCONF
|
||||
GError *err = NULL;
|
||||
|
||||
gconf_client_set_list (default_client,
|
||||
KEY_CLUTTER_PLUGINS,
|
||||
GCONF_VALUE_STRING,
|
||||
list,
|
||||
&err);
|
||||
|
||||
if (err)
|
||||
{
|
||||
meta_warning (_("Error setting clutter plugin list: %s\n"),
|
||||
err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
meta_prefs_override_clutter_plugins (GSList *list)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
clutter_plugins_overridden = TRUE;
|
||||
clutter_plugins = NULL;
|
||||
|
||||
for (l = list; l; l = l->next)
|
||||
clutter_plugins = g_slist_prepend (clutter_plugins, g_strdup(l->data));
|
||||
|
||||
clutter_plugins = g_slist_reverse (clutter_plugins);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_prefs_get_live_hidden_windows (void)
|
||||
{
|
||||
|
@ -64,8 +64,6 @@ struct _MetaPluginClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*early_initialize) (MetaPlugin *plugin);
|
||||
|
||||
void (*start) (MetaPlugin *plugin);
|
||||
|
||||
void (*minimize) (MetaPlugin *plugin,
|
||||
|
@ -61,7 +61,6 @@ typedef enum
|
||||
META_PREF_RESIZE_WITH_RIGHT_BUTTON,
|
||||
META_PREF_EDGE_TILING,
|
||||
META_PREF_FORCE_FULLSCREEN,
|
||||
META_PREF_CLUTTER_PLUGINS,
|
||||
META_PREF_LIVE_HIDDEN_WINDOWS,
|
||||
META_PREF_NO_TAB_POPUP
|
||||
} MetaPreference;
|
||||
@ -134,23 +133,6 @@ void meta_prefs_set_compositing_manager (gboolean whether);
|
||||
|
||||
void meta_prefs_set_force_fullscreen (gboolean whether);
|
||||
|
||||
GSList * meta_prefs_get_clutter_plugins (void);
|
||||
|
||||
/**
|
||||
* Sets the list of plugins persistently in GConf
|
||||
*
|
||||
* \param list list of plugin:option pairs
|
||||
*/
|
||||
void meta_prefs_set_clutter_plugins (GSList *list);
|
||||
|
||||
/**
|
||||
* Sets the list of plugins temporarily for this process. The value
|
||||
* from GConf will be ignored.
|
||||
*
|
||||
* \param list list of plugin:option pairs
|
||||
*/
|
||||
void meta_prefs_override_clutter_plugins (GSList *list);
|
||||
|
||||
gboolean meta_prefs_get_live_hidden_windows (void);
|
||||
void meta_prefs_set_live_hidden_windows (gboolean whether);
|
||||
|
||||
|
@ -22,21 +22,6 @@
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/mutter/general/clutter_plugins</key>
|
||||
<applyto>/apps/mutter/general/clutter_plugins</applyto>
|
||||
<owner>mutter</owner>
|
||||
<type>list</type>
|
||||
<list_type>string</list_type>
|
||||
<default>[default]</default>
|
||||
<locale name="C">
|
||||
<short>Clutter Plugins</short>
|
||||
<long>
|
||||
Plugins to load for the Clutter-based compositing manager.
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/mutter/general/attach_modal_dialogs</key>
|
||||
<applyto>/apps/mutter/general/attach_modal_dialogs</applyto>
|
||||
|
Loading…
Reference in New Issue
Block a user