2008-10-31 04:22:44 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2008 Red Hat, Inc.
|
|
|
|
* Copyright (c) 2008 Intel Corp.
|
|
|
|
*
|
|
|
|
* Based on plugin skeleton by:
|
|
|
|
* 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-07 21:32:37 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2008-10-31 04:22:44 +00:00
|
|
|
*/
|
|
|
|
|
2009-11-24 14:07:40 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-05-04 18:28:07 +00:00
|
|
|
#include <stdlib.h>
|
2008-10-31 04:22:44 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-03-15 15:58:36 +00:00
|
|
|
#define CLUTTER_ENABLE_EXPERIMENTAL_API
|
|
|
|
#define COGL_ENABLE_EXPERIMENTAL_API
|
2011-03-05 15:49:24 +00:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
#include <clutter/x11/clutter-x11.h>
|
|
|
|
#include <gjs/gjs.h>
|
|
|
|
#include <meta/display.h>
|
|
|
|
#include <meta/meta-plugin.h>
|
2013-09-11 15:50:18 +00:00
|
|
|
#include <meta/util.h>
|
2008-11-07 18:42:23 +00:00
|
|
|
|
2009-10-24 17:40:13 +00:00
|
|
|
#include "shell-global-private.h"
|
2010-05-11 19:53:55 +00:00
|
|
|
#include "shell-perf-log.h"
|
2010-09-02 00:48:11 +00:00
|
|
|
#include "shell-wm-private.h"
|
2011-02-25 19:41:39 +00:00
|
|
|
|
2010-10-19 18:55:43 +00:00
|
|
|
static void gnome_shell_plugin_start (MetaPlugin *plugin);
|
|
|
|
static void gnome_shell_plugin_minimize (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor);
|
|
|
|
static void gnome_shell_plugin_maximize (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
|
|
|
static void gnome_shell_plugin_unmaximize (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
|
|
|
static void gnome_shell_plugin_map (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor);
|
|
|
|
static void gnome_shell_plugin_destroy (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor);
|
|
|
|
|
|
|
|
static void gnome_shell_plugin_switch_workspace (MetaPlugin *plugin,
|
|
|
|
gint from,
|
|
|
|
gint to,
|
|
|
|
MetaMotionDirection direction);
|
|
|
|
|
|
|
|
static void gnome_shell_plugin_kill_window_effects (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor);
|
|
|
|
static void gnome_shell_plugin_kill_switch_workspace (MetaPlugin *plugin);
|
|
|
|
|
2013-09-01 22:26:12 +00:00
|
|
|
static void gnome_shell_plugin_show_tile_preview (MetaPlugin *plugin,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaRectangle *tile_rect,
|
|
|
|
int tile_monitor);
|
|
|
|
static void gnome_shell_plugin_hide_tile_preview (MetaPlugin *plugin);
|
|
|
|
|
2010-10-19 18:55:43 +00:00
|
|
|
|
|
|
|
static gboolean gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
|
|
|
|
XEvent *event);
|
2012-08-20 08:38:13 +00:00
|
|
|
|
|
|
|
static gboolean gnome_shell_plugin_keybinding_filter (MetaPlugin *plugin,
|
|
|
|
MetaKeyBinding *binding);
|
2013-08-17 15:42:39 +00:00
|
|
|
|
|
|
|
static void gnome_shell_plugin_confirm_display_change (MetaPlugin *plugin);
|
|
|
|
|
2010-10-19 18:55:43 +00:00
|
|
|
static const MetaPluginInfo *gnome_shell_plugin_plugin_info (MetaPlugin *plugin);
|
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
|
|
|
|
#define GNOME_TYPE_SHELL_PLUGIN (gnome_shell_plugin_get_type ())
|
|
|
|
#define GNOME_SHELL_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_SHELL_PLUGIN, GnomeShellPlugin))
|
|
|
|
#define GNOME_SHELL_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_SHELL_PLUGIN, GnomeShellPluginClass))
|
|
|
|
#define GNOME_IS_SHELL_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_SHELL_PLUGIN_TYPE))
|
|
|
|
#define GNOME_IS_SHELL_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_SHELL_PLUGIN))
|
|
|
|
#define GNOME_SHELL_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_SHELL_PLUGIN, GnomeShellPluginClass))
|
|
|
|
|
|
|
|
typedef struct _GnomeShellPlugin GnomeShellPlugin;
|
|
|
|
typedef struct _GnomeShellPluginClass GnomeShellPluginClass;
|
|
|
|
|
|
|
|
struct _GnomeShellPlugin
|
|
|
|
{
|
2010-10-19 18:55:43 +00:00
|
|
|
MetaPlugin parent;
|
2008-10-31 04:22:44 +00:00
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
Atom panel_action;
|
|
|
|
Atom panel_action_run_dialog;
|
|
|
|
Atom panel_action_main_menu;
|
2010-05-24 13:52:25 +00:00
|
|
|
|
|
|
|
int glx_error_base;
|
|
|
|
int glx_event_base;
|
|
|
|
guint have_swap_event : 1;
|
2012-03-15 15:58:36 +00:00
|
|
|
CoglContext *cogl_context;
|
2011-01-05 14:47:27 +00:00
|
|
|
|
|
|
|
ShellGlobal *global;
|
2008-12-22 21:05:08 +00:00
|
|
|
};
|
2008-10-31 04:22:44 +00:00
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
struct _GnomeShellPluginClass
|
|
|
|
{
|
2010-10-19 18:55:43 +00:00
|
|
|
MetaPluginClass parent_class;
|
2008-12-22 21:05:08 +00:00
|
|
|
};
|
2008-10-31 04:22:44 +00:00
|
|
|
|
2011-02-25 16:20:27 +00:00
|
|
|
GType gnome_shell_plugin_get_type (void);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GnomeShellPlugin, gnome_shell_plugin, META_TYPE_PLUGIN)
|
2008-10-31 04:22:44 +00:00
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
static void
|
|
|
|
gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
|
2008-10-31 04:22:44 +00:00
|
|
|
{
|
2010-10-19 18:55:43 +00:00
|
|
|
MetaPluginClass *plugin_class = META_PLUGIN_CLASS (klass);
|
2008-12-22 21:05:08 +00:00
|
|
|
|
2010-04-12 21:59:44 +00:00
|
|
|
plugin_class->start = gnome_shell_plugin_start;
|
2008-12-22 21:05:08 +00:00
|
|
|
plugin_class->map = gnome_shell_plugin_map;
|
|
|
|
plugin_class->minimize = gnome_shell_plugin_minimize;
|
|
|
|
plugin_class->maximize = gnome_shell_plugin_maximize;
|
|
|
|
plugin_class->unmaximize = gnome_shell_plugin_unmaximize;
|
|
|
|
plugin_class->destroy = gnome_shell_plugin_destroy;
|
|
|
|
|
|
|
|
plugin_class->switch_workspace = gnome_shell_plugin_switch_workspace;
|
2010-06-16 21:28:57 +00:00
|
|
|
|
|
|
|
plugin_class->kill_window_effects = gnome_shell_plugin_kill_window_effects;
|
|
|
|
plugin_class->kill_switch_workspace = gnome_shell_plugin_kill_switch_workspace;
|
2008-12-22 21:05:08 +00:00
|
|
|
|
2013-09-01 22:26:12 +00:00
|
|
|
plugin_class->show_tile_preview = gnome_shell_plugin_show_tile_preview;
|
|
|
|
plugin_class->hide_tile_preview = gnome_shell_plugin_hide_tile_preview;
|
|
|
|
|
2012-08-20 08:38:13 +00:00
|
|
|
plugin_class->xevent_filter = gnome_shell_plugin_xevent_filter;
|
|
|
|
plugin_class->keybinding_filter = gnome_shell_plugin_keybinding_filter;
|
2013-08-17 15:42:39 +00:00
|
|
|
|
|
|
|
plugin_class->confirm_display_change = gnome_shell_plugin_confirm_display_change;
|
|
|
|
|
2012-08-20 08:38:13 +00:00
|
|
|
plugin_class->plugin_info = gnome_shell_plugin_plugin_info;
|
2008-12-22 21:05:08 +00:00
|
|
|
}
|
2008-10-31 04:22:44 +00:00
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
static void
|
|
|
|
gnome_shell_plugin_init (GnomeShellPlugin *shell_plugin)
|
2008-10-31 04:22:44 +00:00
|
|
|
{
|
2011-02-25 19:41:39 +00:00
|
|
|
}
|
|
|
|
|
2012-03-15 15:58:36 +00:00
|
|
|
static void
|
|
|
|
gnome_shell_plugin_start (MetaPlugin *plugin)
|
|
|
|
{
|
|
|
|
GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
|
|
|
|
GError *error = NULL;
|
|
|
|
int status;
|
|
|
|
GjsContext *gjs_context;
|
|
|
|
ClutterBackend *backend;
|
|
|
|
|
|
|
|
backend = clutter_get_default_backend ();
|
|
|
|
shell_plugin->cogl_context = clutter_backend_get_cogl_context (backend);
|
2010-05-24 13:52:25 +00:00
|
|
|
|
2014-02-21 10:50:42 +00:00
|
|
|
shell_plugin->have_swap_event = clutter_feature_available (CLUTTER_FEATURE_SWAP_EVENTS);
|
2010-05-24 13:52:25 +00:00
|
|
|
|
|
|
|
shell_perf_log_define_event (shell_perf_log_get_default (),
|
|
|
|
"glx.swapComplete",
|
|
|
|
"GL buffer swap complete event received (with timestamp of completion)",
|
|
|
|
"x");
|
|
|
|
|
2011-01-05 14:47:27 +00:00
|
|
|
shell_plugin->global = shell_global_get ();
|
2011-02-25 16:20:27 +00:00
|
|
|
_shell_global_set_plugin (shell_plugin->global, META_PLUGIN (shell_plugin));
|
2010-05-11 14:35:27 +00:00
|
|
|
|
2011-02-25 16:20:27 +00:00
|
|
|
gjs_context = _shell_global_get_gjs_context (shell_plugin->global);
|
2010-05-11 19:53:55 +00:00
|
|
|
|
2011-02-25 16:20:27 +00:00
|
|
|
if (!gjs_context_eval (gjs_context,
|
2011-04-30 14:27:36 +00:00
|
|
|
"imports.ui.environment.init();"
|
|
|
|
"imports.ui.main.start();",
|
2008-10-31 04:22:44 +00:00
|
|
|
-1,
|
|
|
|
"<main>",
|
|
|
|
&status,
|
|
|
|
&error))
|
|
|
|
{
|
2009-03-10 21:53:05 +00:00
|
|
|
g_message ("Execution of main.js threw exception: %s", error->message);
|
2008-10-31 04:22:44 +00:00
|
|
|
g_error_free (error);
|
2009-03-10 21:53:05 +00:00
|
|
|
/* We just exit() here, since in a development environment you'll get the
|
|
|
|
* error in your shell output, and it's way better than a busted WM,
|
|
|
|
* which typically manifests as a white screen.
|
|
|
|
*
|
|
|
|
* In production, we shouldn't crash =) But if we do, we should get
|
|
|
|
* restarted by the session infrastructure, which is likely going
|
|
|
|
* to be better than some undefined state.
|
|
|
|
*
|
|
|
|
* If there was a generic "hook into bug-buddy for non-C crashes"
|
|
|
|
* infrastructure, here would be the place to put it.
|
|
|
|
*/
|
|
|
|
exit (1);
|
2008-10-31 04:22:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
static ShellWM *
|
|
|
|
get_shell_wm (void)
|
2008-10-31 04:22:44 +00:00
|
|
|
{
|
2008-12-22 21:05:08 +00:00
|
|
|
ShellWM *wm;
|
2008-10-31 04:22:44 +00:00
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
g_object_get (shell_global_get (),
|
|
|
|
"window-manager", &wm,
|
|
|
|
NULL);
|
|
|
|
/* drop extra ref added by g_object_get */
|
|
|
|
g_object_unref (wm);
|
2008-10-31 04:22:44 +00:00
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
return wm;
|
|
|
|
}
|
2008-10-31 04:22:44 +00:00
|
|
|
|
2008-12-29 04:44:03 +00:00
|
|
|
static void
|
2010-10-19 18:55:43 +00:00
|
|
|
gnome_shell_plugin_minimize (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor)
|
2008-12-29 04:44:03 +00:00
|
|
|
{
|
|
|
|
_shell_wm_minimize (get_shell_wm (),
|
|
|
|
actor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-19 18:55:43 +00:00
|
|
|
gnome_shell_plugin_maximize (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
2008-12-29 04:44:03 +00:00
|
|
|
{
|
|
|
|
_shell_wm_maximize (get_shell_wm (),
|
|
|
|
actor, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-19 18:55:43 +00:00
|
|
|
gnome_shell_plugin_unmaximize (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
2008-12-29 04:44:03 +00:00
|
|
|
{
|
|
|
|
_shell_wm_unmaximize (get_shell_wm (),
|
|
|
|
actor, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-19 18:55:43 +00:00
|
|
|
gnome_shell_plugin_map (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor)
|
2008-12-29 04:44:03 +00:00
|
|
|
{
|
|
|
|
_shell_wm_map (get_shell_wm (),
|
|
|
|
actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-19 18:55:43 +00:00
|
|
|
gnome_shell_plugin_destroy (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor)
|
2008-12-29 04:44:03 +00:00
|
|
|
{
|
|
|
|
_shell_wm_destroy (get_shell_wm (),
|
|
|
|
actor);
|
|
|
|
}
|
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
static void
|
2010-10-19 18:55:43 +00:00
|
|
|
gnome_shell_plugin_switch_workspace (MetaPlugin *plugin,
|
|
|
|
gint from,
|
|
|
|
gint to,
|
|
|
|
MetaMotionDirection direction)
|
2008-12-22 21:05:08 +00:00
|
|
|
{
|
2010-06-16 21:28:57 +00:00
|
|
|
_shell_wm_switch_workspace (get_shell_wm(), from, to, direction);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-19 18:55:43 +00:00
|
|
|
gnome_shell_plugin_kill_window_effects (MetaPlugin *plugin,
|
|
|
|
MetaWindowActor *actor)
|
2010-06-16 21:28:57 +00:00
|
|
|
{
|
|
|
|
_shell_wm_kill_window_effects (get_shell_wm(), actor);
|
2008-12-22 21:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-19 18:55:43 +00:00
|
|
|
gnome_shell_plugin_kill_switch_workspace (MetaPlugin *plugin)
|
2008-12-22 21:05:08 +00:00
|
|
|
{
|
2010-06-16 21:28:57 +00:00
|
|
|
_shell_wm_kill_switch_workspace (get_shell_wm());
|
2008-10-31 04:22:44 +00:00
|
|
|
}
|
|
|
|
|
2013-09-01 22:26:12 +00:00
|
|
|
static void
|
|
|
|
gnome_shell_plugin_show_tile_preview (MetaPlugin *plugin,
|
|
|
|
MetaWindow *window,
|
|
|
|
MetaRectangle *tile_rect,
|
|
|
|
int tile_monitor)
|
|
|
|
{
|
|
|
|
_shell_wm_show_tile_preview (get_shell_wm (), window, tile_rect, tile_monitor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gnome_shell_plugin_hide_tile_preview (MetaPlugin *plugin)
|
|
|
|
{
|
|
|
|
_shell_wm_hide_tile_preview (get_shell_wm ());
|
|
|
|
}
|
|
|
|
|
2012-12-21 02:39:22 +00:00
|
|
|
static gboolean
|
|
|
|
gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
|
|
|
|
XEvent *xev)
|
|
|
|
{
|
|
|
|
GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
|
2013-08-27 00:06:20 +00:00
|
|
|
|
2012-12-21 02:39:22 +00:00
|
|
|
#ifdef GLX_INTEL_swap_event
|
|
|
|
if (shell_plugin->have_swap_event &&
|
|
|
|
xev->type == (shell_plugin->glx_event_base + GLX_BufferSwapComplete))
|
|
|
|
{
|
|
|
|
GLXBufferSwapComplete *swap_complete_event;
|
|
|
|
swap_complete_event = (GLXBufferSwapComplete *)xev;
|
|
|
|
|
|
|
|
/* Buggy early versions of the INTEL_swap_event implementation in Mesa
|
|
|
|
* can send this with a ust of 0. Simplify life for consumers
|
|
|
|
* by ignoring such events */
|
|
|
|
if (swap_complete_event->ust != 0)
|
|
|
|
shell_perf_log_event_x (shell_perf_log_get_default (),
|
|
|
|
"glx.swapComplete",
|
|
|
|
swap_complete_event->ust);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-09-11 15:50:18 +00:00
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
if (meta_is_wayland_compositor ())
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
|
|
|
|
2011-01-05 14:47:27 +00:00
|
|
|
/*
|
2013-09-11 15:50:18 +00:00
|
|
|
* Pass the event to shell-global for XDND
|
2011-01-05 14:47:27 +00:00
|
|
|
*/
|
|
|
|
if (_shell_global_check_xdnd_event (shell_plugin->global, xev))
|
|
|
|
return TRUE;
|
|
|
|
|
2012-03-14 17:14:46 +00:00
|
|
|
return FALSE;
|
2008-10-31 18:02:52 +00:00
|
|
|
}
|
|
|
|
|
2012-08-20 08:38:13 +00:00
|
|
|
static gboolean
|
|
|
|
gnome_shell_plugin_keybinding_filter (MetaPlugin *plugin,
|
|
|
|
MetaKeyBinding *binding)
|
|
|
|
{
|
|
|
|
return _shell_wm_filter_keybinding (get_shell_wm (), binding);
|
|
|
|
}
|
|
|
|
|
2013-08-17 15:42:39 +00:00
|
|
|
static void
|
|
|
|
gnome_shell_plugin_confirm_display_change (MetaPlugin *plugin)
|
|
|
|
{
|
|
|
|
_shell_wm_confirm_display_change (get_shell_wm ());
|
|
|
|
}
|
|
|
|
|
2008-12-22 21:05:08 +00:00
|
|
|
static const
|
2010-10-19 18:55:43 +00:00
|
|
|
MetaPluginInfo *gnome_shell_plugin_plugin_info (MetaPlugin *plugin)
|
2008-10-31 04:22:44 +00:00
|
|
|
{
|
2010-10-19 18:55:43 +00:00
|
|
|
static const MetaPluginInfo info = {
|
2008-12-22 21:05:08 +00:00
|
|
|
.name = "GNOME Shell",
|
|
|
|
.version = "0.1",
|
|
|
|
.author = "Various",
|
|
|
|
.license = "GPLv2+",
|
|
|
|
.description = "Provides GNOME Shell core functionality"
|
|
|
|
};
|
|
|
|
|
|
|
|
return &info;
|
2008-10-31 04:22:44 +00:00
|
|
|
}
|