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"
|
2009-08-12 00:12:52 -04:00
|
|
|
#include "compositor-private.h"
|
2010-10-18 13:27:14 -04:00
|
|
|
#include "meta-plugin-manager.h"
|
2008-09-18 11:09:11 -04:00
|
|
|
#include "prefs.h"
|
|
|
|
#include "errors.h"
|
|
|
|
#include "workspace.h"
|
2010-10-18 13:27:14 -04:00
|
|
|
#include "meta-module.h"
|
2009-08-05 14:05:10 -04:00
|
|
|
#include "../core/window-private.h"
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
#include <string.h>
|
2011-02-03 12:51:35 -05:00
|
|
|
#include <stdlib.h>
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2009-07-22 14:37:43 -04:00
|
|
|
#include <clutter/x11/clutter-x11.h>
|
|
|
|
|
2011-03-04 15:11:38 -05:00
|
|
|
static GSList *plugin_types;
|
2008-12-17 04:33:56 -05:00
|
|
|
|
2010-04-12 17:42:46 -04:00
|
|
|
/*
|
|
|
|
* We have one "default plugin manager" that acts for the first screen,
|
|
|
|
* but also can be used before we open any screens, and additional
|
|
|
|
* plugin managers for each screen. (This is ugly. Probably we should
|
|
|
|
* have one plugin manager and only make the plugins per-screen.)
|
|
|
|
*/
|
2010-10-18 13:27:14 -04:00
|
|
|
static MetaPluginManager *default_plugin_manager;
|
2010-04-12 17:42:46 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
struct MetaPluginManager
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
MetaScreen *screen;
|
|
|
|
|
2011-03-04 15:11:38 -05:00
|
|
|
GList /* MetaPlugin */ *plugins; /* TODO -- maybe use hash table */
|
2008-09-18 11:09:11 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2011-03-04 15:11:38 -05:00
|
|
|
* Loads the given plugin.
|
2008-09-18 11:09:11 -04:00
|
|
|
*/
|
2011-03-04 15:11:38 -05:00
|
|
|
void
|
|
|
|
meta_plugin_manager_load (MetaPluginManager *plugin_mgr,
|
|
|
|
const gchar *plugin_name)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-10-29 06:28:48 -04:00
|
|
|
const gchar *dpath = MUTTER_PLUGIN_DIR "/";
|
2011-03-04 15:11:38 -05:00
|
|
|
gchar *path;
|
|
|
|
MetaModule *module;
|
|
|
|
GType plugin_type;
|
2011-02-25 14:38:04 -05:00
|
|
|
|
2011-03-04 15:11:38 -05:00
|
|
|
if (g_path_is_absolute (plugin_name))
|
|
|
|
path = g_strdup (plugin_name);
|
|
|
|
else
|
|
|
|
path = g_strconcat (dpath, plugin_name, ".so", NULL);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2011-03-04 15:11:38 -05:00
|
|
|
module = g_object_new (META_TYPE_MODULE, "path", path, NULL);
|
|
|
|
if (!module || !g_type_module_use (G_TYPE_MODULE (module)))
|
2008-10-09 10:33:06 -04:00
|
|
|
{
|
2011-03-04 15:11:38 -05:00
|
|
|
/* This is fatal under the assumption that a monitoring
|
|
|
|
* process like gnome-session will take over and handle
|
|
|
|
* our untimely exit.
|
2008-10-09 10:33:06 -04:00
|
|
|
*/
|
2011-03-04 15:11:38 -05:00
|
|
|
g_printerr ("Unable to load plugin module [%s]: %s",
|
|
|
|
path, g_module_error());
|
|
|
|
exit (1);
|
2008-10-09 10:33:06 -04:00
|
|
|
}
|
|
|
|
|
2011-03-04 15:11:38 -05:00
|
|
|
plugin_type = meta_module_get_plugin_type (module);
|
2011-03-05 16:16:26 -05:00
|
|
|
meta_plugin_manager_register (plugin_mgr, plugin_type);
|
|
|
|
|
|
|
|
g_type_module_unuse (G_TYPE_MODULE (module));
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Registers the given plugin type
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
meta_plugin_manager_register (MetaPluginManager *plugin_mgr,
|
|
|
|
GType plugin_type)
|
|
|
|
{
|
|
|
|
MetaPlugin *plugin;
|
|
|
|
|
2011-03-04 15:11:38 -05:00
|
|
|
plugin_types = g_slist_prepend (plugin_types, GSIZE_TO_POINTER (plugin_type));
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2011-03-04 15:11:38 -05:00
|
|
|
plugin = g_object_new (plugin_type, NULL);
|
|
|
|
plugin_mgr->plugins = g_list_prepend (plugin_mgr->plugins, plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2011-03-04 15:11:38 -05:00
|
|
|
void
|
|
|
|
meta_plugin_manager_initialize (MetaPluginManager *plugin_mgr)
|
2011-02-25 14:38:04 -05:00
|
|
|
{
|
|
|
|
GList *iter;
|
|
|
|
|
2011-03-04 15:11:38 -05:00
|
|
|
if (!plugin_mgr->plugins)
|
2011-02-25 14:38:04 -05:00
|
|
|
{
|
2011-03-04 15:11:38 -05:00
|
|
|
/*
|
|
|
|
* If no plugins are specified, load the default plugin.
|
|
|
|
*/
|
|
|
|
meta_plugin_manager_load (plugin_mgr, "default");
|
2011-02-25 14:38:04 -05:00
|
|
|
}
|
|
|
|
|
2010-04-12 17:34:49 -04:00
|
|
|
for (iter = plugin_mgr->plugins; iter; iter = iter->next)
|
2008-11-13 17:06:07 -05:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPlugin *plugin = (MetaPlugin*) iter->data;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2008-11-13 17:06:07 -05:00
|
|
|
|
2010-04-12 17:34:49 -04:00
|
|
|
g_object_set (plugin,
|
|
|
|
"screen", plugin_mgr->screen,
|
|
|
|
NULL);
|
2008-11-13 17:06:07 -05:00
|
|
|
|
2010-04-12 17:34:49 -04:00
|
|
|
if (klass->start)
|
|
|
|
klass->start (plugin);
|
2008-11-13 17:06:07 -05:00
|
|
|
}
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
static MetaPluginManager *
|
|
|
|
meta_plugin_manager_new (MetaScreen *screen)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPluginManager *plugin_mgr;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
plugin_mgr = g_new0 (MetaPluginManager, 1);
|
2011-03-04 15:11:38 -05:00
|
|
|
plugin_mgr->screen = screen;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2010-04-12 17:42:46 -04:00
|
|
|
if (screen)
|
2010-10-18 13:27:14 -04:00
|
|
|
g_object_set_data (G_OBJECT (screen), "meta-plugin-manager", plugin_mgr);
|
2010-04-12 17:42:46 -04:00
|
|
|
|
2008-10-13 07:23:47 -04:00
|
|
|
return plugin_mgr;
|
2008-09-18 11:09:11 -04:00
|
|
|
}
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPluginManager *
|
|
|
|
meta_plugin_manager_get_default (void)
|
2010-04-12 17:42:46 -04:00
|
|
|
{
|
|
|
|
if (!default_plugin_manager)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
default_plugin_manager = meta_plugin_manager_new (NULL);
|
2010-04-12 17:42:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return default_plugin_manager;
|
|
|
|
}
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPluginManager *
|
|
|
|
meta_plugin_manager_get (MetaScreen *screen)
|
2010-04-12 17:42:46 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPluginManager *plugin_mgr;
|
2010-04-12 17:42:46 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
plugin_mgr = g_object_get_data (G_OBJECT (screen), "meta-plugin-manager");
|
2010-04-12 17:42:46 -04:00
|
|
|
if (plugin_mgr)
|
|
|
|
return plugin_mgr;
|
|
|
|
|
|
|
|
if (!default_plugin_manager)
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_get_default ();
|
2010-04-12 17:42:46 -04:00
|
|
|
|
|
|
|
if (!default_plugin_manager->screen)
|
|
|
|
{
|
|
|
|
/* The default plugin manager is so far unused, we can recycle it */
|
|
|
|
default_plugin_manager->screen = screen;
|
2010-10-18 13:27:14 -04:00
|
|
|
g_object_set_data (G_OBJECT (screen), "meta-plugin-manager", default_plugin_manager);
|
2010-04-12 17:42:46 -04:00
|
|
|
|
|
|
|
return default_plugin_manager;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-04 15:11:38 -05:00
|
|
|
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;
|
2010-04-12 17:42:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-07 11:29:03 -04:00
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_kill_window_effects (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindowActor *actor)
|
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)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPlugin *plugin = l->data;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!meta_plugin_disabled (plugin)
|
2010-06-16 17:15:56 -04:00
|
|
|
&& klass->kill_window_effects)
|
|
|
|
klass->kill_window_effects (plugin, actor);
|
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_kill_switch_workspace (MetaPluginManager *plugin_mgr)
|
2010-06-16 17:15:56 -04:00
|
|
|
{
|
|
|
|
GList *l = plugin_mgr->plugins;
|
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPlugin *plugin = l->data;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2010-06-16 17:15:56 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!meta_plugin_disabled (plugin)
|
|
|
|
&& (meta_plugin_features (plugin) & META_PLUGIN_SWITCH_WORKSPACE)
|
2010-06-16 17:15:56 -04:00
|
|
|
&& klass->kill_switch_workspace)
|
|
|
|
klass->kill_switch_workspace (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_event_simple (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindowActor *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;
|
2009-08-05 14:05:10 -04:00
|
|
|
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return FALSE;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPlugin *plugin = l->data;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!meta_plugin_disabled (plugin) &&
|
|
|
|
(meta_plugin_features (plugin) & event))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
case META_PLUGIN_MINIMIZE:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->minimize)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_kill_window_effects (
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr,
|
2010-06-16 17:15:56 -04:00
|
|
|
actor);
|
2008-10-13 07:23:47 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
_meta_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;
|
2010-10-18 13:27:14 -04:00
|
|
|
case META_PLUGIN_MAP:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->map)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_kill_window_effects (
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr,
|
2010-06-16 17:15:56 -04:00
|
|
|
actor);
|
2008-10-13 07:23:47 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
_meta_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;
|
2010-10-18 13:27:14 -04:00
|
|
|
case META_PLUGIN_DESTROY:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->destroy)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
_meta_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
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_event_maximize (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindowActor *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;
|
2009-08-05 14:05:10 -04:00
|
|
|
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return FALSE;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPlugin *plugin = l->data;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!meta_plugin_disabled (plugin) &&
|
|
|
|
(meta_plugin_features (plugin) & event))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
case META_PLUGIN_MAXIMIZE:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->maximize)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_kill_window_effects (
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr,
|
2010-06-16 17:15:56 -04:00
|
|
|
actor);
|
2008-10-13 07:23:47 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
_meta_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;
|
2010-10-18 13:27:14 -04:00
|
|
|
case META_PLUGIN_UNMAXIMIZE:
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->unmaximize)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_kill_window_effects (
|
2008-10-13 07:23:47 -04:00
|
|
|
plugin_mgr,
|
2010-06-16 17:15:56 -04:00
|
|
|
actor);
|
2008-12-22 16:53:10 -05:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
_meta_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
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_switch_workspace (MetaPluginManager *plugin_mgr,
|
|
|
|
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;
|
2009-08-05 14:05:10 -04:00
|
|
|
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return FALSE;
|
2008-09-18 11:09:11 -04:00
|
|
|
|
|
|
|
while (l)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPlugin *plugin = l->data;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2008-09-18 11:09:11 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
if (!meta_plugin_disabled (plugin) &&
|
|
|
|
(meta_plugin_features (plugin) & META_PLUGIN_SWITCH_WORKSPACE))
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
2008-12-17 04:33:56 -05:00
|
|
|
if (klass->switch_workspace)
|
2008-09-18 11:09:11 -04:00
|
|
|
{
|
|
|
|
retval = TRUE;
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_kill_switch_workspace (plugin_mgr);
|
2008-10-13 07:23:47 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
_meta_plugin_effect_started (plugin);
|
2010-06-16 17:15:56 -04:00
|
|
|
klass->switch_workspace (plugin, 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
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_plugin_manager_xevent_filter (MetaPluginManager *plugin_mgr,
|
|
|
|
XEvent *xev)
|
2008-10-02 07:16:15 -04:00
|
|
|
{
|
2008-10-07 11:29:03 -04:00
|
|
|
GList *l;
|
2009-07-22 14:37:43 -04:00
|
|
|
gboolean have_plugin_xevent_func;
|
2008-10-07 11:29:03 -04:00
|
|
|
|
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
|
|
|
|
2009-07-22 14:37:43 -04:00
|
|
|
/* We need to make sure that clutter gets certain events, like
|
|
|
|
* ConfigureNotify on the stage window. If there is a plugin that
|
|
|
|
* provides an xevent_filter function, then it's the responsibility
|
|
|
|
* of that plugin to pass events to Clutter. Otherwise, we send the
|
|
|
|
* event directly to Clutter ourselves.
|
|
|
|
*
|
|
|
|
* What happens if there are two plugins with xevent_filter functions
|
|
|
|
* is undefined; in general, multiple competing plugins are something
|
|
|
|
* we don't support well or care much about.
|
|
|
|
*
|
|
|
|
* FIXME: Really, we should just always handle sending the event to
|
|
|
|
* clutter if a plugin doesn't report the event as handled by
|
|
|
|
* returning TRUE, but it doesn't seem worth breaking compatibility
|
|
|
|
* of the plugin interface right now to achieve this; the way it is
|
|
|
|
* now works fine in practice.
|
|
|
|
*/
|
|
|
|
have_plugin_xevent_func = FALSE;
|
|
|
|
|
2008-10-02 07:16:15 -04:00
|
|
|
while (l)
|
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaPlugin *plugin = l->data;
|
|
|
|
MetaPluginClass *klass = META_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
|
|
|
{
|
2009-07-22 14:37:43 -04:00
|
|
|
have_plugin_xevent_func = TRUE;
|
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;
|
|
|
|
}
|
|
|
|
|
2009-07-22 14:37:43 -04:00
|
|
|
if (!have_plugin_xevent_func)
|
|
|
|
return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE;
|
|
|
|
|
2008-10-02 07:16:15 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|