2008-09-18 11:09:11 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2008 Intel Corp.
|
|
|
|
*
|
|
|
|
* Author: Tomas Frydrych <tf@linux.intel.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2008-10-28 06:45:45 -04:00
|
|
|
#include "config.h"
|
2008-10-16 07:50:01 -04:00
|
|
|
#include "mutter-plugin-manager.h"
|
2008-09-18 11:09:11 -04:00
|
|
|
#include "prefs.h"
|
|
|
|
#include "errors.h"
|
|
|
|
#include "workspace.h"
|
2008-12-17 04:33:56 -05:00
|
|
|
#include "mutter-module.h"
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
/*
|
|
|
|
* There is only one instace of each module per the process.
|
|
|
|
*/
|
|
|
|
static GHashTable *plugin_modules = NULL;
|
|
|
|
|
|
|
|
static gboolean mutter_plugin_manager_reload (MutterPluginManager *plugin_mgr);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
struct MutterPluginManager
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
MetaScreen *screen;
|
|
|
|
|
2008-11-13 17:06:07 -05:00
|
|
|
GList /* MutterPluginPending */ *pending_plugin_modules; /* Plugins not yet fully loaded */
|
|
|
|
GList /* MutterPlugin */ *plugins; /* TODO -- maybe use hash table */
|
|
|
|
GList *unload; /* Plugins that are disabled and pending unload */
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
guint idle_unload_id;
|
|
|
|
};
|
|
|
|
|
2008-11-13 17:06:07 -05:00
|
|
|
typedef struct MutterPluginPending
|
|
|
|
{
|
|
|
|
MutterModule *module;
|
|
|
|
char *path;
|
|
|
|
char *params;
|
|
|
|
} MutterPluginPending;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Checks that the plugin is compatible with the WM and sets up the plugin
|
|
|
|
* struct.
|
|
|
|
*/
|
2008-10-16 07:50:01 -04:00
|
|
|
static MutterPlugin *
|
2008-12-17 04:33:56 -05:00
|
|
|
mutter_plugin_load (MutterPluginManager *mgr,
|
|
|
|
MutterModule *module,
|
2008-11-03 04:59:01 -05:00
|
|
|
const gchar *params)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
MutterPlugin *plugin = NULL;
|
|
|
|
GType plugin_type = mutter_module_get_plugin_type (module);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
if (!plugin_type)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
g_warning ("Plugin type not registered !!!");
|
|
|
|
return NULL;
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
plugin = g_object_new (plugin_type,
|
|
|
|
"screen", mgr->screen,
|
|
|
|
"params", params,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return plugin;
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_unload (MutterPlugin *plugin)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
if (mutter_plugin_running (plugin))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
g_object_set (plugin, "disabled", TRUE, NULL);
|
2008-09-18 11:09:11 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
g_object_unref (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iddle callback to remove plugins that could not be removed directly and are
|
|
|
|
* pending for removal.
|
|
|
|
*/
|
|
|
|
static gboolean
|
2008-11-03 04:59:01 -05:00
|
|
|
mutter_plugin_manager_idle_unload (MutterPluginManager *plugin_mgr)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
GList *l = plugin_mgr->unload;
|
2008-09-18 11:09:11 -04:00
|
|
|
gboolean dont_remove = TRUE;
|
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPlugin *plugin = l->data;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
if (mutter_plugin_unload (plugin))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
/* Remove from list */
|
|
|
|
GList *p = l->prev;
|
|
|
|
GList *n = l->next;
|
|
|
|
|
|
|
|
if (!p)
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr->unload = n;
|
2008-09-18 11:09:11 -04:00
|
|
|
else
|
|
|
|
p->next = n;
|
|
|
|
|
|
|
|
if (n)
|
|
|
|
n->prev = p;
|
|
|
|
|
|
|
|
g_list_free_1 (l);
|
|
|
|
|
|
|
|
l = n;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
if (!plugin_mgr->unload)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
/* If no more unloads are pending, remove the handler as well */
|
|
|
|
dont_remove = FALSE;
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr->idle_unload_id = 0;
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return dont_remove;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unloads all plugins
|
|
|
|
*/
|
|
|
|
static void
|
2008-11-03 04:59:01 -05:00
|
|
|
mutter_plugin_manager_unload (MutterPluginManager *plugin_mgr)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
GList *plugins = plugin_mgr->plugins;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
while (plugins)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPlugin *plugin = plugins->data;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
/* If the plugin could not be removed, move it to the unload list */
|
2008-10-16 07:50:01 -04:00
|
|
|
if (!mutter_plugin_unload (plugin))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr->unload = g_list_prepend (plugin_mgr->unload, plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
if (!plugin_mgr->idle_unload_id)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr->idle_unload_id = g_idle_add ((GSourceFunc)
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_idle_unload,
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
plugins = plugins->next;
|
|
|
|
}
|
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
g_list_free (plugin_mgr->plugins);
|
|
|
|
plugin_mgr->plugins = NULL;
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
prefs_changed_callback (MetaPreference pref,
|
|
|
|
void *data)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPluginManager *plugin_mgr = data;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
if (pref == META_PREF_CLUTTER_PLUGINS)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_reload (plugin_mgr);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-12-17 04:33:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static MutterModule *
|
|
|
|
mutter_plugin_manager_get_module (const gchar *path)
|
|
|
|
{
|
|
|
|
MutterModule *module = g_hash_table_lookup (plugin_modules, path);
|
|
|
|
|
|
|
|
if (!module &&
|
|
|
|
(module = g_object_new (MUTTER_TYPE_MODULE, "path", path, NULL)))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
g_hash_table_insert (plugin_modules, g_strdup (path), module);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-12-17 04:33:56 -05:00
|
|
|
|
|
|
|
return module;
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loads all plugins listed in gconf registry.
|
|
|
|
*/
|
2008-11-13 17:06:07 -05:00
|
|
|
gboolean
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-29 06:28:48 -04:00
|
|
|
const gchar *dpath = MUTTER_PLUGIN_DIR "/";
|
2008-10-09 10:33:06 -04:00
|
|
|
GSList *plugins, *fallback = NULL;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
plugins = meta_prefs_get_clutter_plugins ();
|
|
|
|
|
2008-10-09 10:33:06 -04:00
|
|
|
if (!plugins)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If no plugins are specified, try to load the default plugin.
|
|
|
|
*/
|
|
|
|
fallback = g_slist_append (fallback, "default");
|
|
|
|
plugins = fallback;
|
|
|
|
}
|
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
while (plugins)
|
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
gchar *plugin_string;
|
2008-09-18 11:09:11 -04:00
|
|
|
gchar *params;
|
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_string = g_strdup (plugins->data);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
if (plugin_string)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
MutterModule *module;
|
|
|
|
gchar *path;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
params = strchr (plugin_string, ':');
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
if (params)
|
|
|
|
{
|
|
|
|
*params = 0;
|
|
|
|
++params;
|
|
|
|
}
|
|
|
|
|
2008-10-31 02:13:53 -04:00
|
|
|
if (g_path_is_absolute (plugin_string))
|
|
|
|
path = g_strdup (plugin_string);
|
|
|
|
else
|
|
|
|
path = g_strconcat (dpath, plugin_string, ".so", NULL);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
module = mutter_plugin_manager_get_module (path);
|
|
|
|
|
|
|
|
if (module)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-18 07:56:32 -05:00
|
|
|
gboolean use_succeeded;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-12-18 07:56:32 -05:00
|
|
|
use_succeeded = g_type_module_use (G_TYPE_MODULE (module));
|
2008-12-17 04:33:56 -05:00
|
|
|
|
2008-11-13 17:06:07 -05:00
|
|
|
if (use_succeeded)
|
2008-10-07 11:29:03 -04:00
|
|
|
{
|
2008-11-13 17:06:07 -05:00
|
|
|
MutterPluginPending *pending = g_new0 (MutterPluginPending, 1);
|
|
|
|
pending->module = module;
|
|
|
|
pending->path = g_strdup (path);
|
|
|
|
pending->params = g_strdup (params);
|
|
|
|
plugin_mgr->pending_plugin_modules =
|
|
|
|
g_list_prepend (plugin_mgr->pending_plugin_modules, pending);
|
2008-10-07 11:29:03 -04:00
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
2008-10-07 11:29:03 -04:00
|
|
|
else
|
2008-12-17 04:33:56 -05:00
|
|
|
g_warning ("Unable to load plugin module [%s]: %s",
|
|
|
|
path, g_module_error());
|
2008-10-28 07:30:29 -04:00
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
g_free (path);
|
2008-10-13 07:23:47 -04:00
|
|
|
g_free (plugin_string);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
plugins = plugins->next;
|
|
|
|
}
|
|
|
|
|
2008-10-09 10:33:06 -04:00
|
|
|
|
|
|
|
if (fallback)
|
|
|
|
g_slist_free (fallback);
|
|
|
|
|
2008-11-13 17:06:07 -05:00
|
|
|
if (plugin_mgr->pending_plugin_modules != NULL)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
meta_prefs_add_listener (prefs_changed_callback, plugin_mgr);
|
2008-09-18 11:09:11 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-11-13 17:06:07 -05:00
|
|
|
gboolean
|
|
|
|
mutter_plugin_manager_initialize (MutterPluginManager *plugin_mgr)
|
|
|
|
{
|
|
|
|
GList *iter;
|
|
|
|
|
|
|
|
for (iter = plugin_mgr->pending_plugin_modules; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
MutterPluginPending *pending = (MutterPluginPending*) iter->data;
|
|
|
|
MutterPlugin *p;
|
|
|
|
|
|
|
|
if ((p = mutter_plugin_load (plugin_mgr, pending->module, pending->params)))
|
|
|
|
{
|
|
|
|
plugin_mgr->plugins = g_list_prepend (plugin_mgr->plugins, p);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("Plugin load for [%s] failed", pending->path);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_type_module_unuse (G_TYPE_MODULE (pending->module));
|
|
|
|
g_free (pending->path);
|
|
|
|
g_free (pending->params);
|
|
|
|
g_free (pending);
|
|
|
|
}
|
|
|
|
g_list_free (plugin_mgr->pending_plugin_modules);
|
|
|
|
plugin_mgr->pending_plugin_modules = NULL;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-09-18 11:09:11 -04:00
|
|
|
/*
|
|
|
|
* Reloads all plugins
|
|
|
|
*/
|
|
|
|
static gboolean
|
2008-11-03 04:59:01 -05:00
|
|
|
mutter_plugin_manager_reload (MutterPluginManager *plugin_mgr)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
/* 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.
|
|
|
|
*/
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_unload (plugin_mgr);
|
|
|
|
return mutter_plugin_manager_load (plugin_mgr);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPluginManager *
|
|
|
|
mutter_plugin_manager_new (MetaScreen *screen)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPluginManager *plugin_mgr;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
if (!plugin_modules)
|
|
|
|
{
|
|
|
|
plugin_modules = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2008-10-16 07:50:01 -04:00
|
|
|
plugin_mgr = g_new0 (MutterPluginManager, 1);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr->screen = screen;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
return plugin_mgr;
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2008-10-07 11:29:03 -04:00
|
|
|
static void
|
2008-11-03 04:59:01 -05:00
|
|
|
mutter_plugin_manager_kill_effect (MutterPluginManager *plugin_mgr,
|
|
|
|
MutterWindow *actor,
|
|
|
|
unsigned long events)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
GList *l = plugin_mgr->plugins;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPlugin *plugin = l->data;
|
2008-12-17 04:33:56 -05:00
|
|
|
MutterPluginClass *klass = MUTTER_PLUGIN_GET_CLASS (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
if (!mutter_plugin_disabled (plugin)
|
|
|
|
&& (mutter_plugin_features (plugin) & events)
|
|
|
|
&& klass->kill_effect)
|
|
|
|
klass->kill_effect (plugin, actor, events);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ALL_BUT_SWITCH \
|
2008-10-16 07:50:01 -04:00
|
|
|
MUTTER_PLUGIN_ALL_EFFECTS & \
|
|
|
|
~MUTTER_PLUGIN_SWITCH_WORKSPACE
|
2008-09-18 11:09:11 -04:00
|
|
|
/*
|
|
|
|
* Public method that the compositor hooks into for events that require
|
|
|
|
* no additional parameters.
|
|
|
|
*
|
|
|
|
* Returns TRUE if at least one of the plugins handled the event type (i.e.,
|
|
|
|
* if the return value is FALSE, there will be no subsequent call to the
|
|
|
|
* manager completed() callback, and the compositor must ensure that any
|
|
|
|
* appropriate post-effect cleanup is carried out.
|
|
|
|
*/
|
|
|
|
gboolean
|
2008-11-03 04:59:01 -05:00
|
|
|
mutter_plugin_manager_event_simple (MutterPluginManager *plugin_mgr,
|
|
|
|
MutterWindow *actor,
|
|
|
|
unsigned long event)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
GList *l = plugin_mgr->plugins;
|
2008-09-18 11:09:11 -04:00
|
|
|
gboolean retval = FALSE;
|
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPlugin *plugin = l->data;
|
2008-12-17 04:33:56 -05:00
|
|
|
MutterPluginClass *klass = MUTTER_PLUGIN_GET_CLASS (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
if (!mutter_plugin_disabled (plugin) &&
|
|
|
|
(mutter_plugin_features (plugin) & event))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
case MUTTER_PLUGIN_MINIMIZE:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->minimize)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_kill_effect (
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr,
|
|
|
|
actor,
|
|
|
|
ALL_BUT_SWITCH);
|
|
|
|
|
2008-12-22 16:53:10 -05:00
|
|
|
_mutter_plugin_effect_started (plugin);
|
2008-12-17 04:33:56 -05:00
|
|
|
klass->minimize (plugin, actor);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
break;
|
2008-10-16 07:50:01 -04:00
|
|
|
case MUTTER_PLUGIN_MAP:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->map)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_kill_effect (
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr,
|
|
|
|
actor,
|
|
|
|
ALL_BUT_SWITCH);
|
|
|
|
|
2008-12-22 16:53:10 -05:00
|
|
|
_mutter_plugin_effect_started (plugin);
|
2008-12-17 04:33:56 -05:00
|
|
|
klass->map (plugin, actor);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
break;
|
2008-10-16 07:50:01 -04:00
|
|
|
case MUTTER_PLUGIN_DESTROY:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->destroy)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-22 16:53:10 -05:00
|
|
|
_mutter_plugin_effect_started (plugin);
|
2008-12-17 04:33:56 -05:00
|
|
|
klass->destroy (plugin, actor);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("Incorrect handler called for event %lu", event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-10-07 04:01:58 -04:00
|
|
|
* The public method that the compositor hooks into for maximize and unmaximize
|
|
|
|
* events.
|
2008-09-18 11:09:11 -04:00
|
|
|
*
|
|
|
|
* Returns TRUE if at least one of the plugins handled the event type (i.e.,
|
|
|
|
* if the return value is FALSE, there will be no subsequent call to the
|
|
|
|
* manager completed() callback, and the compositor must ensure that any
|
|
|
|
* appropriate post-effect cleanup is carried out.
|
|
|
|
*/
|
|
|
|
gboolean
|
2008-11-03 04:59:01 -05:00
|
|
|
mutter_plugin_manager_event_maximize (MutterPluginManager *plugin_mgr,
|
|
|
|
MutterWindow *actor,
|
|
|
|
unsigned long event,
|
|
|
|
gint target_x,
|
|
|
|
gint target_y,
|
|
|
|
gint target_width,
|
|
|
|
gint target_height)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
GList *l = plugin_mgr->plugins;
|
2008-09-18 11:09:11 -04:00
|
|
|
gboolean retval = FALSE;
|
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPlugin *plugin = l->data;
|
2008-12-17 04:33:56 -05:00
|
|
|
MutterPluginClass *klass = MUTTER_PLUGIN_GET_CLASS (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
if (!mutter_plugin_disabled (plugin) &&
|
|
|
|
(mutter_plugin_features (plugin) & event))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
case MUTTER_PLUGIN_MAXIMIZE:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->maximize)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_kill_effect (
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr,
|
|
|
|
actor,
|
|
|
|
ALL_BUT_SWITCH);
|
|
|
|
|
2008-12-22 16:53:10 -05:00
|
|
|
_mutter_plugin_effect_started (plugin);
|
2008-12-17 04:33:56 -05:00
|
|
|
klass->maximize (plugin, actor,
|
|
|
|
target_x, target_y,
|
|
|
|
target_width, target_height);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
break;
|
2008-10-16 07:50:01 -04:00
|
|
|
case MUTTER_PLUGIN_UNMAXIMIZE:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->unmaximize)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_kill_effect (
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr,
|
|
|
|
actor,
|
|
|
|
ALL_BUT_SWITCH);
|
2008-12-22 16:53:10 -05:00
|
|
|
|
|
|
|
_mutter_plugin_effect_started (plugin);
|
2008-12-17 04:33:56 -05:00
|
|
|
klass->unmaximize (plugin, actor,
|
|
|
|
target_x, target_y,
|
|
|
|
target_width, target_height);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("Incorrect handler called for event %lu", event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The public method that the compositor hooks into for desktop switching.
|
|
|
|
*
|
|
|
|
* Returns TRUE if at least one of the plugins handled the event type (i.e.,
|
|
|
|
* if the return value is FALSE, there will be no subsequent call to the
|
|
|
|
* manager completed() callback, and the compositor must ensure that any
|
|
|
|
* appropriate post-effect cleanup is carried out.
|
|
|
|
*/
|
|
|
|
gboolean
|
2008-11-03 04:59:01 -05:00
|
|
|
mutter_plugin_manager_switch_workspace (MutterPluginManager *plugin_mgr,
|
|
|
|
const GList **actors,
|
|
|
|
gint from,
|
|
|
|
gint to,
|
|
|
|
MetaMotionDirection direction)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-13 07:23:47 -04:00
|
|
|
GList *l = plugin_mgr->plugins;
|
2008-09-18 11:09:11 -04:00
|
|
|
gboolean retval = FALSE;
|
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2008-10-16 07:50:01 -04:00
|
|
|
MutterPlugin *plugin = l->data;
|
2008-12-17 04:33:56 -05:00
|
|
|
MutterPluginClass *klass = MUTTER_PLUGIN_GET_CLASS (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
if (!mutter_plugin_disabled (plugin) &&
|
|
|
|
(mutter_plugin_features (plugin) & MUTTER_PLUGIN_SWITCH_WORKSPACE) &&
|
2008-09-18 11:09:11 -04:00
|
|
|
(actors && *actors))
|
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->switch_workspace)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
retval = TRUE;
|
2008-10-16 07:50:01 -04:00
|
|
|
mutter_plugin_manager_kill_effect (
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr,
|
2008-10-16 07:50:01 -04:00
|
|
|
MUTTER_WINDOW ((*actors)->data),
|
|
|
|
MUTTER_PLUGIN_SWITCH_WORKSPACE);
|
2008-10-13 07:23:47 -04:00
|
|
|
|
2008-12-22 16:53:10 -05:00
|
|
|
_mutter_plugin_effect_started (plugin);
|
2008-12-17 04:33:56 -05:00
|
|
|
klass->switch_workspace (plugin, actors, from, to, direction);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2008-10-02 07:16:15 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The public method that the compositor hooks into for desktop switching.
|
|
|
|
*
|
|
|
|
* Returns TRUE if at least one of the plugins handled the event type (i.e.,
|
|
|
|
* if the return value is FALSE, there will be no subsequent call to the
|
|
|
|
* manager completed() callback, and the compositor must ensure that any
|
|
|
|
* appropriate post-effect cleanup is carried out.
|
|
|
|
*/
|
|
|
|
gboolean
|
2008-11-03 04:59:01 -05:00
|
|
|
mutter_plugin_manager_xevent_filter (MutterPluginManager *plugin_mgr,
|
|
|
|
XEvent *xev)
|
2008-10-02 07:16:15 -04:00
|
|
|
{
|
2008-10-07 11:29:03 -04:00
|
|
|
GList *l;
|
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
if (!plugin_mgr)
|
2008-10-07 11:29:03 -04:00
|
|
|
return FALSE;
|
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
l = plugin_mgr->plugins;
|
2008-10-02 07:16:15 -04:00
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
MutterPlugin *plugin = l->data;
|
|
|
|
MutterPluginClass *klass = MUTTER_PLUGIN_GET_CLASS (plugin);
|
2008-10-02 07:16:15 -04:00
|
|
|
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->xevent_filter)
|
2008-10-02 07:16:15 -04:00
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->xevent_filter (plugin, xev) == TRUE)
|
2008-10-02 07:16:15 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|