2008-09-18 15:09:11 +00: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 10:45:45 +00:00
|
|
|
#include "config.h"
|
2009-08-12 04:12:52 +00:00
|
|
|
#include "compositor-private.h"
|
2010-10-18 17:27:14 +00:00
|
|
|
#include "meta-plugin-manager.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#include <meta/prefs.h>
|
|
|
|
#include <meta/errors.h>
|
|
|
|
#include <meta/workspace.h>
|
2010-10-18 17:27:14 +00:00
|
|
|
#include "meta-module.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#include "window-private.h"
|
2008-09-18 15:09:11 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
2011-02-03 17:51:35 +00:00
|
|
|
#include <stdlib.h>
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2009-07-22 18:37:43 +00:00
|
|
|
#include <clutter/x11/clutter-x11.h>
|
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
static GType plugin_type = G_TYPE_NONE;
|
2010-04-12 21:42:46 +00:00
|
|
|
|
2010-10-18 17:27:14 +00:00
|
|
|
struct MetaPluginManager
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
MetaScreen *screen;
|
|
|
|
MetaPlugin *plugin;
|
2008-09-18 15:09:11 +00:00
|
|
|
};
|
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
void
|
|
|
|
meta_plugin_manager_set_plugin_type (GType gtype)
|
|
|
|
{
|
|
|
|
if (plugin_type != G_TYPE_NONE)
|
|
|
|
meta_fatal ("Mutter plugin already set: %s", g_type_name (plugin_type));
|
|
|
|
|
|
|
|
plugin_type = gtype;
|
|
|
|
}
|
|
|
|
|
2008-09-18 15:09:11 +00:00
|
|
|
/*
|
2011-03-04 20:11:38 +00:00
|
|
|
* Loads the given plugin.
|
2008-09-18 15:09:11 +00:00
|
|
|
*/
|
2011-03-04 20:11:38 +00:00
|
|
|
void
|
2012-04-05 05:29:39 +00:00
|
|
|
meta_plugin_manager_load (const gchar *plugin_name)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2008-10-29 10:28:48 +00:00
|
|
|
const gchar *dpath = MUTTER_PLUGIN_DIR "/";
|
2011-03-04 20:11:38 +00:00
|
|
|
gchar *path;
|
|
|
|
MetaModule *module;
|
2011-02-25 19:38:04 +00:00
|
|
|
|
2011-03-04 20:11:38 +00: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 15:09:11 +00:00
|
|
|
|
2011-03-04 20:11:38 +00:00
|
|
|
module = g_object_new (META_TYPE_MODULE, "path", path, NULL);
|
|
|
|
if (!module || !g_type_module_use (G_TYPE_MODULE (module)))
|
2008-10-09 14:33:06 +00:00
|
|
|
{
|
2011-03-04 20:11:38 +00: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 14:33:06 +00:00
|
|
|
*/
|
2011-03-04 20:11:38 +00:00
|
|
|
g_printerr ("Unable to load plugin module [%s]: %s",
|
|
|
|
path, g_module_error());
|
|
|
|
exit (1);
|
2008-10-09 14:33:06 +00:00
|
|
|
}
|
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
meta_plugin_manager_set_plugin_type (meta_module_get_plugin_type (module));
|
2011-03-05 21:16:26 +00:00
|
|
|
|
|
|
|
g_type_module_unuse (G_TYPE_MODULE (module));
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
2013-07-29 08:12:24 +00:00
|
|
|
static void
|
|
|
|
on_confirm_display_change (MetaMonitorManager *monitors,
|
|
|
|
MetaPluginManager *plugin_mgr)
|
|
|
|
{
|
|
|
|
meta_plugin_manager_confirm_display_change (plugin_mgr);
|
|
|
|
}
|
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
MetaPluginManager *
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_plugin_manager_new (MetaScreen *screen)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2010-10-18 17:27:14 +00:00
|
|
|
MetaPluginManager *plugin_mgr;
|
2012-06-17 04:56:48 +00:00
|
|
|
MetaPluginClass *klass;
|
2012-04-05 05:29:39 +00:00
|
|
|
MetaPlugin *plugin;
|
2013-07-29 08:12:24 +00:00
|
|
|
MetaMonitorManager *monitors;
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2010-10-18 17:27:14 +00:00
|
|
|
plugin_mgr = g_new0 (MetaPluginManager, 1);
|
2011-03-04 20:11:38 +00:00
|
|
|
plugin_mgr->screen = screen;
|
2012-04-05 05:29:39 +00:00
|
|
|
plugin_mgr->plugin = plugin = g_object_new (plugin_type, "screen", screen, NULL);
|
2012-06-17 04:56:48 +00:00
|
|
|
|
|
|
|
klass = META_PLUGIN_GET_CLASS (plugin);
|
|
|
|
|
|
|
|
if (klass->start)
|
|
|
|
klass->start (plugin);
|
2010-04-12 21:42:46 +00:00
|
|
|
|
2013-07-29 08:12:24 +00:00
|
|
|
monitors = meta_monitor_manager_get ();
|
|
|
|
g_signal_connect (monitors, "confirm-display-change",
|
|
|
|
G_CALLBACK (on_confirm_display_change), plugin_mgr);
|
|
|
|
|
2008-10-13 11:23:47 +00:00
|
|
|
return plugin_mgr;
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
|
|
|
|
2008-10-07 15:29:03 +00:00
|
|
|
static void
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_plugin_manager_kill_window_effects (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindowActor *actor)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2010-06-16 21:15:56 +00:00
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
if (klass->kill_window_effects)
|
|
|
|
klass->kill_window_effects (plugin, actor);
|
2010-06-16 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_plugin_manager_kill_switch_workspace (MetaPluginManager *plugin_mgr)
|
2010-06-16 21:15:56 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
if (klass->kill_switch_workspace)
|
|
|
|
klass->kill_switch_workspace (plugin);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Public method that the compositor hooks into for events that require
|
|
|
|
* no additional parameters.
|
|
|
|
*
|
2012-04-05 05:29:39 +00:00
|
|
|
* Returns TRUE if the plugin handled the event type (i.e.,
|
2008-09-18 15:09:11 +00:00
|
|
|
* 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 17:27:14 +00:00
|
|
|
meta_plugin_manager_event_simple (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindowActor *actor,
|
|
|
|
unsigned long event)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2009-08-05 18:05:10 +00:00
|
|
|
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
2012-04-05 05:29:39 +00:00
|
|
|
gboolean retval = FALSE;
|
2009-08-05 18:05:10 +00:00
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return FALSE;
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
switch (event)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
case META_PLUGIN_MINIMIZE:
|
|
|
|
if (klass->minimize)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
retval = TRUE;
|
|
|
|
meta_plugin_manager_kill_window_effects (plugin_mgr,
|
|
|
|
actor);
|
|
|
|
|
|
|
|
_meta_plugin_effect_started (plugin);
|
|
|
|
klass->minimize (plugin, actor);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
2012-04-05 05:29:39 +00:00
|
|
|
break;
|
|
|
|
case META_PLUGIN_MAP:
|
|
|
|
if (klass->map)
|
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
meta_plugin_manager_kill_window_effects (plugin_mgr,
|
|
|
|
actor);
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
_meta_plugin_effect_started (plugin);
|
|
|
|
klass->map (plugin, actor);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case META_PLUGIN_DESTROY:
|
|
|
|
if (klass->destroy)
|
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
_meta_plugin_effect_started (plugin);
|
|
|
|
klass->destroy (plugin, actor);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("Incorrect handler called for event %lu", event);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-10-07 08:01:58 +00:00
|
|
|
* The public method that the compositor hooks into for maximize and unmaximize
|
|
|
|
* events.
|
2008-09-18 15:09:11 +00:00
|
|
|
*
|
2012-04-05 05:29:39 +00:00
|
|
|
* Returns TRUE if the plugin handled the event type (i.e.,
|
2008-09-18 15:09:11 +00:00
|
|
|
* 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 17:27:14 +00: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 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
|
|
|
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
2008-09-18 15:09:11 +00:00
|
|
|
gboolean retval = FALSE;
|
2009-08-05 18:05:10 +00:00
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return FALSE;
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
switch (event)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
case META_PLUGIN_MAXIMIZE:
|
|
|
|
if (klass->maximize)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
retval = TRUE;
|
|
|
|
meta_plugin_manager_kill_window_effects (plugin_mgr,
|
|
|
|
actor);
|
|
|
|
|
|
|
|
_meta_plugin_effect_started (plugin);
|
|
|
|
klass->maximize (plugin, actor,
|
|
|
|
target_x, target_y,
|
|
|
|
target_width, target_height);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
2012-04-05 05:29:39 +00:00
|
|
|
break;
|
|
|
|
case META_PLUGIN_UNMAXIMIZE:
|
|
|
|
if (klass->unmaximize)
|
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
meta_plugin_manager_kill_window_effects (plugin_mgr,
|
|
|
|
actor);
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
_meta_plugin_effect_started (plugin);
|
|
|
|
klass->unmaximize (plugin, actor,
|
|
|
|
target_x, target_y,
|
|
|
|
target_width, target_height);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("Incorrect handler called for event %lu", event);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The public method that the compositor hooks into for desktop switching.
|
|
|
|
*
|
2012-04-05 05:29:39 +00:00
|
|
|
* Returns TRUE if the plugin handled the event type (i.e.,
|
2008-09-18 15:09:11 +00:00
|
|
|
* 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 17:27:14 +00:00
|
|
|
meta_plugin_manager_switch_workspace (MetaPluginManager *plugin_mgr,
|
|
|
|
gint from,
|
|
|
|
gint to,
|
|
|
|
MetaMotionDirection direction)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
|
|
|
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
2008-09-18 15:09:11 +00:00
|
|
|
gboolean retval = FALSE;
|
2009-08-05 18:05:10 +00:00
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return FALSE;
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
if (klass->switch_workspace)
|
2008-09-18 15:09:11 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
retval = TRUE;
|
|
|
|
meta_plugin_manager_kill_switch_workspace (plugin_mgr);
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2012-04-05 05:29:39 +00:00
|
|
|
_meta_plugin_effect_started (plugin);
|
|
|
|
klass->switch_workspace (plugin, from, to, direction);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2008-10-02 11:16:15 +00:00
|
|
|
|
2012-08-10 00:27:18 +00:00
|
|
|
gboolean
|
|
|
|
meta_plugin_manager_filter_keybinding (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaKeyBinding *binding)
|
|
|
|
{
|
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
|
|
|
|
|
|
|
if (klass->keybinding_filter)
|
|
|
|
return klass->keybinding_filter (plugin, binding);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-10-02 11:16:15 +00:00
|
|
|
gboolean
|
2010-10-18 17:27:14 +00:00
|
|
|
meta_plugin_manager_xevent_filter (MetaPluginManager *plugin_mgr,
|
|
|
|
XEvent *xev)
|
2008-10-02 11:16:15 +00:00
|
|
|
{
|
2012-04-05 05:29:39 +00:00
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
2012-01-07 22:21:32 +00:00
|
|
|
|
2013-09-04 16:11:43 +00:00
|
|
|
return _meta_plugin_xevent_filter (plugin, xev);
|
2008-10-02 11:16:15 +00:00
|
|
|
}
|
2013-07-29 08:12:24 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_plugin_manager_confirm_display_change (MetaPluginManager *plugin_mgr)
|
|
|
|
{
|
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
|
|
|
|
|
|
|
if (klass->confirm_display_change)
|
|
|
|
return klass->confirm_display_change (plugin);
|
|
|
|
else
|
|
|
|
return meta_plugin_complete_display_change (plugin, TRUE);
|
|
|
|
}
|