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
|
2014-01-12 01:42:06 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2008-09-18 15:09:11 +00:00
|
|
|
*/
|
|
|
|
|
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
|
|
|
{
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaCompositor *compositor;
|
2012-04-05 05:29:39 +00:00
|
|
|
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 *
|
2014-03-18 21:31:22 +00:00
|
|
|
meta_plugin_manager_new (MetaCompositor *compositor)
|
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);
|
2014-03-18 21:31:22 +00:00
|
|
|
plugin_mgr->compositor = compositor;
|
2014-03-18 21:41:22 +00:00
|
|
|
plugin_mgr->plugin = plugin = g_object_new (plugin_type, NULL);
|
|
|
|
|
2014-03-18 21:31:22 +00:00
|
|
|
_meta_plugin_set_compositor (plugin, compositor);
|
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,
|
2015-07-06 03:58:40 +00:00
|
|
|
MetaPluginEffect 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);
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = plugin_mgr->compositor->display;
|
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);
|
|
|
|
klass->minimize (plugin, actor);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
2012-04-05 05:29:39 +00:00
|
|
|
break;
|
2013-06-14 01:01:17 +00:00
|
|
|
case META_PLUGIN_UNMINIMIZE:
|
|
|
|
if (klass->unminimize)
|
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
meta_plugin_manager_kill_window_effects (plugin_mgr,
|
|
|
|
actor);
|
|
|
|
klass->unminimize (plugin, actor);
|
|
|
|
}
|
|
|
|
break;
|
2012-04-05 05:29:39 +00:00
|
|
|
case META_PLUGIN_MAP:
|
|
|
|
if (klass->map)
|
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
meta_plugin_manager_kill_window_effects (plugin_mgr,
|
|
|
|
actor);
|
|
|
|
klass->map (plugin, actor);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case META_PLUGIN_DESTROY:
|
|
|
|
if (klass->destroy)
|
|
|
|
{
|
|
|
|
retval = TRUE;
|
|
|
|
klass->destroy (plugin, actor);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2015-07-06 03:58:40 +00:00
|
|
|
g_warning ("Incorrect handler called for event %d", event);
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2016-09-26 13:54:54 +00:00
|
|
|
void
|
|
|
|
meta_plugin_manager_event_size_changed (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindowActor *actor)
|
|
|
|
{
|
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
|
|
|
|
|
|
|
if (klass->size_changed)
|
|
|
|
klass->size_changed (plugin, actor);
|
|
|
|
}
|
|
|
|
|
2008-09-18 15:09:11 +00:00
|
|
|
gboolean
|
2015-07-06 04:08:08 +00:00
|
|
|
meta_plugin_manager_event_size_change (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindowActor *actor,
|
|
|
|
MetaSizeChange which_change,
|
|
|
|
MetaRectangle *old_frame_rect,
|
|
|
|
MetaRectangle *old_buffer_rect)
|
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);
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = plugin_mgr->compositor->display;
|
2009-08-05 18:05:10 +00:00
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return FALSE;
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2015-07-06 04:08:08 +00:00
|
|
|
if (!klass->size_change)
|
|
|
|
return FALSE;
|
2008-09-18 15:09:11 +00:00
|
|
|
|
2015-07-06 04:08:08 +00:00
|
|
|
meta_plugin_manager_kill_window_effects (plugin_mgr, actor);
|
|
|
|
klass->size_change (plugin, actor, which_change, old_frame_rect, old_buffer_rect);
|
|
|
|
return TRUE;
|
2008-09-18 15:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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);
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = plugin_mgr->compositor->display;
|
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);
|
|
|
|
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);
|
|
|
|
}
|
2012-03-24 10:29:39 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_plugin_manager_show_tile_preview (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaRectangle *tile_rect,
|
|
|
|
int tile_monitor_number)
|
|
|
|
{
|
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = plugin_mgr->compositor->display;
|
2012-03-24 10:29:39 +00:00
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (klass->show_tile_preview)
|
|
|
|
{
|
|
|
|
klass->show_tile_preview (plugin, window, tile_rect, tile_monitor_number);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr)
|
|
|
|
{
|
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
2014-03-18 21:31:22 +00:00
|
|
|
MetaDisplay *display = plugin_mgr->compositor->display;
|
2012-03-24 10:29:39 +00:00
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (klass->hide_tile_preview)
|
|
|
|
{
|
|
|
|
klass->hide_tile_preview (plugin);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-03-13 22:34:14 +00:00
|
|
|
|
|
|
|
void
|
2014-05-23 21:14:51 +00:00
|
|
|
meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaWindowMenuType menu,
|
|
|
|
int x,
|
|
|
|
int y)
|
2014-03-13 22:34:14 +00:00
|
|
|
{
|
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
|
|
|
MetaDisplay *display = plugin_mgr->compositor->display;
|
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (klass->show_window_menu)
|
2014-05-23 21:14:51 +00:00
|
|
|
klass->show_window_menu (plugin, window, menu, x, y);
|
2014-03-13 22:34:14 +00:00
|
|
|
}
|
2014-05-30 22:52:06 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_plugin_manager_show_window_menu_for_rect (MetaPluginManager *plugin_mgr,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaWindowMenuType menu,
|
|
|
|
MetaRectangle *rect)
|
|
|
|
{
|
|
|
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
|
|
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
|
|
|
MetaDisplay *display = plugin_mgr->compositor->display;
|
|
|
|
|
|
|
|
if (display->display_opening)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (klass->show_window_menu_for_rect)
|
|
|
|
klass->show_window_menu_for_rect (plugin, window, menu, rect);
|
|
|
|
}
|