1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
4
* Copyright (c) 2008 Red Hat, Inc.
5
* Copyright (c) 2008 Intel Corp.
7
* Based on plugin skeleton by:
8
* Author: Tomas Frydrych <tf@linux.intel.com>
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU General Public License as
12
* published by the Free Software Foundation; either version 2 of the
13
* License, or (at your option) any later version.
15
* This program is distributed in the hope that it will be useful, but
16
* WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
* General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
31
#include <clutter/clutter.h>
32
#include <clutter/x11/clutter-x11.h>
34
#include <GL/glxext.h>
36
#include <meta/display.h>
37
#include <meta/meta-plugin.h>
39
#include "shell-global-private.h"
40
#include "shell-perf-log.h"
41
#include "shell-wm-private.h"
43
static void gnome_shell_plugin_dispose (GObject *object);
44
static void gnome_shell_plugin_finalize (GObject *object);
46
static void gnome_shell_plugin_start (MetaPlugin *plugin);
47
static void gnome_shell_plugin_minimize (MetaPlugin *plugin,
48
MetaWindowActor *actor);
49
static void gnome_shell_plugin_maximize (MetaPlugin *plugin,
50
MetaWindowActor *actor,
55
static void gnome_shell_plugin_unmaximize (MetaPlugin *plugin,
56
MetaWindowActor *actor,
61
static void gnome_shell_plugin_map (MetaPlugin *plugin,
62
MetaWindowActor *actor);
63
static void gnome_shell_plugin_destroy (MetaPlugin *plugin,
64
MetaWindowActor *actor);
66
static void gnome_shell_plugin_switch_workspace (MetaPlugin *plugin,
69
MetaMotionDirection direction);
71
static void gnome_shell_plugin_kill_window_effects (MetaPlugin *plugin,
72
MetaWindowActor *actor);
73
static void gnome_shell_plugin_kill_switch_workspace (MetaPlugin *plugin);
76
static gboolean gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
78
static const MetaPluginInfo *gnome_shell_plugin_plugin_info (MetaPlugin *plugin);
81
#define GNOME_TYPE_SHELL_PLUGIN (gnome_shell_plugin_get_type ())
82
#define GNOME_SHELL_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_SHELL_PLUGIN, GnomeShellPlugin))
83
#define GNOME_SHELL_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_SHELL_PLUGIN, GnomeShellPluginClass))
84
#define GNOME_IS_SHELL_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_SHELL_PLUGIN_TYPE))
85
#define GNOME_IS_SHELL_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_SHELL_PLUGIN))
86
#define GNOME_SHELL_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_SHELL_PLUGIN, GnomeShellPluginClass))
88
typedef struct _GnomeShellPlugin GnomeShellPlugin;
89
typedef struct _GnomeShellPluginClass GnomeShellPluginClass;
91
struct _GnomeShellPlugin
96
Atom panel_action_run_dialog;
97
Atom panel_action_main_menu;
101
guint have_swap_event : 1;
106
struct _GnomeShellPluginClass
108
MetaPluginClass parent_class;
111
GType gnome_shell_plugin_get_type (void);
113
G_DEFINE_TYPE (GnomeShellPlugin, gnome_shell_plugin, META_TYPE_PLUGIN)
116
gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
118
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
119
MetaPluginClass *plugin_class = META_PLUGIN_CLASS (klass);
121
gobject_class->dispose = gnome_shell_plugin_dispose;
122
gobject_class->finalize = gnome_shell_plugin_finalize;
124
plugin_class->start = gnome_shell_plugin_start;
125
plugin_class->map = gnome_shell_plugin_map;
126
plugin_class->minimize = gnome_shell_plugin_minimize;
127
plugin_class->maximize = gnome_shell_plugin_maximize;
128
plugin_class->unmaximize = gnome_shell_plugin_unmaximize;
129
plugin_class->destroy = gnome_shell_plugin_destroy;
131
plugin_class->switch_workspace = gnome_shell_plugin_switch_workspace;
133
plugin_class->kill_window_effects = gnome_shell_plugin_kill_window_effects;
134
plugin_class->kill_switch_workspace = gnome_shell_plugin_kill_switch_workspace;
136
plugin_class->xevent_filter = gnome_shell_plugin_xevent_filter;
137
plugin_class->plugin_info = gnome_shell_plugin_plugin_info;
141
gnome_shell_plugin_init (GnomeShellPlugin *shell_plugin)
146
gnome_shell_plugin_start (MetaPlugin *plugin)
148
GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
150
MetaDisplay *display;
152
GError *error = NULL;
154
const char *glx_extensions;
155
GjsContext *gjs_context;
157
screen = meta_plugin_get_screen (plugin);
158
display = meta_screen_get_display (screen);
160
xdisplay = meta_display_get_xdisplay (display);
162
glXQueryExtension (xdisplay,
163
&shell_plugin->glx_error_base,
164
&shell_plugin->glx_event_base);
166
glx_extensions = glXQueryExtensionsString (xdisplay,
167
meta_screen_get_screen_number (screen));
168
shell_plugin->have_swap_event = strstr (glx_extensions, "GLX_INTEL_swap_event") != NULL;
170
shell_perf_log_define_event (shell_perf_log_get_default (),
172
"GL buffer swap complete event received (with timestamp of completion)",
175
shell_plugin->global = shell_global_get ();
176
_shell_global_set_plugin (shell_plugin->global, META_PLUGIN (shell_plugin));
178
gjs_context = _shell_global_get_gjs_context (shell_plugin->global);
180
if (!gjs_context_eval (gjs_context,
181
"imports.ui.environment.init();"
182
"imports.ui.main.start();",
188
g_message ("Execution of main.js threw exception: %s", error->message);
189
g_error_free (error);
190
/* We just exit() here, since in a development environment you'll get the
191
* error in your shell output, and it's way better than a busted WM,
192
* which typically manifests as a white screen.
194
* In production, we shouldn't crash =) But if we do, we should get
195
* restarted by the session infrastructure, which is likely going
196
* to be better than some undefined state.
198
* If there was a generic "hook into bug-buddy for non-C crashes"
199
* infrastructure, here would be the place to put it.
206
gnome_shell_plugin_dispose (GObject *object)
208
G_OBJECT_CLASS(gnome_shell_plugin_parent_class)->dispose (object);
212
gnome_shell_plugin_finalize (GObject *object)
214
G_OBJECT_CLASS(gnome_shell_plugin_parent_class)->finalize (object);
222
g_object_get (shell_global_get (),
223
"window-manager", &wm,
225
/* drop extra ref added by g_object_get */
232
gnome_shell_plugin_minimize (MetaPlugin *plugin,
233
MetaWindowActor *actor)
235
_shell_wm_minimize (get_shell_wm (),
241
gnome_shell_plugin_maximize (MetaPlugin *plugin,
242
MetaWindowActor *actor,
248
_shell_wm_maximize (get_shell_wm (),
249
actor, x, y, width, height);
253
gnome_shell_plugin_unmaximize (MetaPlugin *plugin,
254
MetaWindowActor *actor,
260
_shell_wm_unmaximize (get_shell_wm (),
261
actor, x, y, width, height);
265
gnome_shell_plugin_map (MetaPlugin *plugin,
266
MetaWindowActor *actor)
268
_shell_wm_map (get_shell_wm (),
273
gnome_shell_plugin_destroy (MetaPlugin *plugin,
274
MetaWindowActor *actor)
276
_shell_wm_destroy (get_shell_wm (),
281
gnome_shell_plugin_switch_workspace (MetaPlugin *plugin,
284
MetaMotionDirection direction)
286
_shell_wm_switch_workspace (get_shell_wm(), from, to, direction);
290
gnome_shell_plugin_kill_window_effects (MetaPlugin *plugin,
291
MetaWindowActor *actor)
293
_shell_wm_kill_window_effects (get_shell_wm(), actor);
297
gnome_shell_plugin_kill_switch_workspace (MetaPlugin *plugin)
299
_shell_wm_kill_switch_workspace (get_shell_wm());
303
gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
307
GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
308
#ifdef GLX_INTEL_swap_event
309
if (shell_plugin->have_swap_event &&
310
xev->type == (shell_plugin->glx_event_base + GLX_BufferSwapComplete))
312
GLXBufferSwapComplete *swap_complete_event;
313
swap_complete_event = (GLXBufferSwapComplete *)xev;
315
/* Buggy early versions of the INTEL_swap_event implementation in Mesa
316
* can send this with a ust of 0. Simplify life for consumers
317
* by ignoring such events */
318
if (swap_complete_event->ust != 0)
319
shell_perf_log_event_x (shell_perf_log_get_default (),
321
swap_complete_event->ust);
325
if ((xev->xany.type == EnterNotify || xev->xany.type == LeaveNotify)
326
&& xev->xcrossing.window == clutter_x11_get_stage_window (CLUTTER_STAGE (clutter_stage_get_default ())))
328
/* If the pointer enters a child of the stage window (eg, a
329
* trayicon), we want to consider it to still be in the stage,
330
* so don't let Clutter see the event.
332
if (xev->xcrossing.detail == NotifyInferior)
335
/* If the pointer is grabbed by a window it is not currently in,
336
* filter that out as well. In particular, if a trayicon grabs
337
* the pointer after a click on its label, we don't want to hide
338
* the message tray. Filtering out this event will leave Clutter
339
* out of sync, but that happens fairly often with grabs, and we
340
* can work around it. (Eg, shell_global_sync_pointer().)
342
if (xev->xcrossing.mode == NotifyGrab &&
343
(xev->xcrossing.detail == NotifyNonlinear ||
344
xev->xcrossing.detail == NotifyNonlinearVirtual))
349
* Pass the event to shell-global
351
if (_shell_global_check_xdnd_event (shell_plugin->global, xev))
354
return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE;
358
MetaPluginInfo *gnome_shell_plugin_plugin_info (MetaPlugin *plugin)
360
static const MetaPluginInfo info = {
361
.name = "GNOME Shell",
365
.description = "Provides GNOME Shell core functionality"
373
Add a non-static function that calls into libgnome-bluetooth-applet.so,
374
to avoid the linker being too smart and removing the dependency.
375
This function is never actually called.
377
extern GType bluetooth_applet_get_type(void);
378
void _shell_link_to_bluetooth(void);
380
void _shell_link_to_bluetooth(void) {
381
bluetooth_applet_get_type();