~ubuntu-branches/debian/sid/gnome-shell/sid

« back to all changes in this revision

Viewing changes to .pc/04_remove-glx-dependency-on-armel.patch/src/gnome-shell-plugin.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2012-04-30 20:37:44 UTC
  • Revision ID: package-import@ubuntu.com-20120430203744-bv9x3ydt4t3dkk85
Tags: 3.2.2.1-4
Fold 04_remove-glx-dependency-on-armel.patch and
14_require_gl_directly.patch into a new patch named
14_make-GLX-optional.patch. Use pkg-config to check if gl.pc is available
and build the GLX/GL bits conditionally. This fixes a build failure on
arm{el,hf} where clutter/cogl uses GLES. Closes: #670850

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
 
 
3
 
/*
4
 
 * Copyright (c) 2008 Red Hat, Inc.
5
 
 * Copyright (c) 2008 Intel Corp.
6
 
 *
7
 
 * Based on plugin skeleton by:
8
 
 * Author: Tomas Frydrych <tf@linux.intel.com>
9
 
 *
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.
14
 
 *
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.
19
 
 *
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
23
 
 * 02111-1307, USA.
24
 
 */
25
 
 
26
 
#include "config.h"
27
 
 
28
 
#include <stdlib.h>
29
 
#include <string.h>
30
 
 
31
 
#include <clutter/clutter.h>
32
 
#include <clutter/x11/clutter-x11.h>
33
 
#include <GL/glx.h>
34
 
#include <GL/glxext.h>
35
 
#include <gjs/gjs.h>
36
 
#include <meta/display.h>
37
 
#include <meta/meta-plugin.h>
38
 
 
39
 
#include "shell-global-private.h"
40
 
#include "shell-perf-log.h"
41
 
#include "shell-wm-private.h"
42
 
 
43
 
static void gnome_shell_plugin_dispose     (GObject *object);
44
 
static void gnome_shell_plugin_finalize    (GObject *object);
45
 
 
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,
51
 
                                                 gint                 x,
52
 
                                                 gint                 y,
53
 
                                                 gint                 width,
54
 
                                                 gint                 height);
55
 
static void gnome_shell_plugin_unmaximize       (MetaPlugin          *plugin,
56
 
                                                 MetaWindowActor     *actor,
57
 
                                                 gint                 x,
58
 
                                                 gint                 y,
59
 
                                                 gint                 width,
60
 
                                                 gint                 height);
61
 
static void gnome_shell_plugin_map              (MetaPlugin          *plugin,
62
 
                                                 MetaWindowActor     *actor);
63
 
static void gnome_shell_plugin_destroy          (MetaPlugin          *plugin,
64
 
                                                 MetaWindowActor     *actor);
65
 
 
66
 
static void gnome_shell_plugin_switch_workspace (MetaPlugin          *plugin,
67
 
                                                 gint                 from,
68
 
                                                 gint                 to,
69
 
                                                 MetaMotionDirection  direction);
70
 
 
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);
74
 
 
75
 
 
76
 
static gboolean              gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
77
 
                                                               XEvent     *event);
78
 
static const MetaPluginInfo *gnome_shell_plugin_plugin_info   (MetaPlugin *plugin);
79
 
 
80
 
 
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))
87
 
 
88
 
typedef struct _GnomeShellPlugin        GnomeShellPlugin;
89
 
typedef struct _GnomeShellPluginClass   GnomeShellPluginClass;
90
 
 
91
 
struct _GnomeShellPlugin
92
 
{
93
 
  MetaPlugin parent;
94
 
 
95
 
  Atom panel_action;
96
 
  Atom panel_action_run_dialog;
97
 
  Atom panel_action_main_menu;
98
 
 
99
 
  int glx_error_base;
100
 
  int glx_event_base;
101
 
  guint have_swap_event : 1;
102
 
 
103
 
  ShellGlobal *global;
104
 
};
105
 
 
106
 
struct _GnomeShellPluginClass
107
 
{
108
 
  MetaPluginClass parent_class;
109
 
};
110
 
 
111
 
GType gnome_shell_plugin_get_type (void);
112
 
 
113
 
G_DEFINE_TYPE (GnomeShellPlugin, gnome_shell_plugin, META_TYPE_PLUGIN)
114
 
 
115
 
static void
116
 
gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
117
 
{
118
 
  GObjectClass      *gobject_class = G_OBJECT_CLASS (klass);
119
 
  MetaPluginClass *plugin_class  = META_PLUGIN_CLASS (klass);
120
 
 
121
 
  gobject_class->dispose         = gnome_shell_plugin_dispose;
122
 
  gobject_class->finalize        = gnome_shell_plugin_finalize;
123
 
 
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;
130
 
 
131
 
  plugin_class->switch_workspace = gnome_shell_plugin_switch_workspace;
132
 
 
133
 
  plugin_class->kill_window_effects   = gnome_shell_plugin_kill_window_effects;
134
 
  plugin_class->kill_switch_workspace = gnome_shell_plugin_kill_switch_workspace;
135
 
 
136
 
  plugin_class->xevent_filter    = gnome_shell_plugin_xevent_filter;
137
 
  plugin_class->plugin_info      = gnome_shell_plugin_plugin_info;
138
 
}
139
 
 
140
 
static void
141
 
gnome_shell_plugin_init (GnomeShellPlugin *shell_plugin)
142
 
{
143
 
}
144
 
 
145
 
static void
146
 
gnome_shell_plugin_start (MetaPlugin *plugin)
147
 
{
148
 
  GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
149
 
  MetaScreen *screen;
150
 
  MetaDisplay *display;
151
 
  Display *xdisplay;
152
 
  GError *error = NULL;
153
 
  int status;
154
 
  const char *glx_extensions;
155
 
  GjsContext *gjs_context;
156
 
 
157
 
  screen = meta_plugin_get_screen (plugin);
158
 
  display = meta_screen_get_display (screen);
159
 
 
160
 
  xdisplay = meta_display_get_xdisplay (display);
161
 
 
162
 
  glXQueryExtension (xdisplay,
163
 
                     &shell_plugin->glx_error_base,
164
 
                     &shell_plugin->glx_event_base);
165
 
 
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;
169
 
 
170
 
  shell_perf_log_define_event (shell_perf_log_get_default (),
171
 
                               "glx.swapComplete",
172
 
                               "GL buffer swap complete event received (with timestamp of completion)",
173
 
                               "x");
174
 
 
175
 
  shell_plugin->global = shell_global_get ();
176
 
  _shell_global_set_plugin (shell_plugin->global, META_PLUGIN (shell_plugin));
177
 
 
178
 
  gjs_context = _shell_global_get_gjs_context (shell_plugin->global);
179
 
 
180
 
  if (!gjs_context_eval (gjs_context,
181
 
                         "imports.ui.environment.init();"
182
 
                         "imports.ui.main.start();",
183
 
                         -1,
184
 
                         "<main>",
185
 
                         &status,
186
 
                         &error))
187
 
    {
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.
193
 
       *
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.
197
 
       *
198
 
       * If there was a generic "hook into bug-buddy for non-C crashes"
199
 
       * infrastructure, here would be the place to put it.
200
 
       */
201
 
      exit (1);
202
 
    }
203
 
}
204
 
 
205
 
static void
206
 
gnome_shell_plugin_dispose (GObject *object)
207
 
{
208
 
  G_OBJECT_CLASS(gnome_shell_plugin_parent_class)->dispose (object);
209
 
}
210
 
 
211
 
static void
212
 
gnome_shell_plugin_finalize (GObject *object)
213
 
{
214
 
  G_OBJECT_CLASS(gnome_shell_plugin_parent_class)->finalize (object);
215
 
}
216
 
 
217
 
static ShellWM *
218
 
get_shell_wm (void)
219
 
{
220
 
  ShellWM *wm;
221
 
 
222
 
  g_object_get (shell_global_get (),
223
 
                "window-manager", &wm,
224
 
                NULL);
225
 
  /* drop extra ref added by g_object_get */
226
 
  g_object_unref (wm);
227
 
 
228
 
  return wm;
229
 
}
230
 
 
231
 
static void
232
 
gnome_shell_plugin_minimize (MetaPlugin         *plugin,
233
 
                             MetaWindowActor    *actor)
234
 
{
235
 
  _shell_wm_minimize (get_shell_wm (),
236
 
                      actor);
237
 
 
238
 
}
239
 
 
240
 
static void
241
 
gnome_shell_plugin_maximize (MetaPlugin         *plugin,
242
 
                             MetaWindowActor    *actor,
243
 
                             gint                x,
244
 
                             gint                y,
245
 
                             gint                width,
246
 
                             gint                height)
247
 
{
248
 
  _shell_wm_maximize (get_shell_wm (),
249
 
                      actor, x, y, width, height);
250
 
}
251
 
 
252
 
static void
253
 
gnome_shell_plugin_unmaximize (MetaPlugin         *plugin,
254
 
                               MetaWindowActor    *actor,
255
 
                               gint                x,
256
 
                               gint                y,
257
 
                               gint                width,
258
 
                               gint                height)
259
 
{
260
 
  _shell_wm_unmaximize (get_shell_wm (),
261
 
                        actor, x, y, width, height);
262
 
}
263
 
 
264
 
static void
265
 
gnome_shell_plugin_map (MetaPlugin         *plugin,
266
 
                        MetaWindowActor    *actor)
267
 
{
268
 
  _shell_wm_map (get_shell_wm (),
269
 
                 actor);
270
 
}
271
 
 
272
 
static void
273
 
gnome_shell_plugin_destroy (MetaPlugin         *plugin,
274
 
                            MetaWindowActor    *actor)
275
 
{
276
 
  _shell_wm_destroy (get_shell_wm (),
277
 
                     actor);
278
 
}
279
 
 
280
 
static void
281
 
gnome_shell_plugin_switch_workspace (MetaPlugin         *plugin,
282
 
                                     gint                from,
283
 
                                     gint                to,
284
 
                                     MetaMotionDirection direction)
285
 
{
286
 
  _shell_wm_switch_workspace (get_shell_wm(), from, to, direction);
287
 
}
288
 
 
289
 
static void
290
 
gnome_shell_plugin_kill_window_effects (MetaPlugin         *plugin,
291
 
                                        MetaWindowActor    *actor)
292
 
{
293
 
  _shell_wm_kill_window_effects (get_shell_wm(), actor);
294
 
}
295
 
 
296
 
static void
297
 
gnome_shell_plugin_kill_switch_workspace (MetaPlugin         *plugin)
298
 
{
299
 
  _shell_wm_kill_switch_workspace (get_shell_wm());
300
 
}
301
 
 
302
 
static gboolean
303
 
gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
304
 
                                  XEvent     *xev)
305
 
{
306
 
 
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))
311
 
    {
312
 
      GLXBufferSwapComplete *swap_complete_event;
313
 
      swap_complete_event = (GLXBufferSwapComplete *)xev;
314
 
 
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 (),
320
 
                                "glx.swapComplete",
321
 
                                swap_complete_event->ust);
322
 
    }
323
 
#endif
324
 
 
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 ())))
327
 
    {
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.
331
 
       */
332
 
      if (xev->xcrossing.detail == NotifyInferior)
333
 
        return TRUE;
334
 
 
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().)
341
 
       */
342
 
      if (xev->xcrossing.mode == NotifyGrab &&
343
 
          (xev->xcrossing.detail == NotifyNonlinear ||
344
 
           xev->xcrossing.detail == NotifyNonlinearVirtual))
345
 
        return TRUE;
346
 
    }
347
 
 
348
 
  /*
349
 
   * Pass the event to shell-global
350
 
   */
351
 
  if (_shell_global_check_xdnd_event (shell_plugin->global, xev))
352
 
    return TRUE;
353
 
 
354
 
  return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE;
355
 
}
356
 
 
357
 
static const
358
 
MetaPluginInfo *gnome_shell_plugin_plugin_info (MetaPlugin *plugin)
359
 
{
360
 
  static const MetaPluginInfo info = {
361
 
    .name = "GNOME Shell",
362
 
    .version = "0.1",
363
 
    .author = "Various",
364
 
    .license = "GPLv2+",
365
 
    .description = "Provides GNOME Shell core functionality"
366
 
  };
367
 
 
368
 
  return &info;
369
 
}
370
 
 
371
 
#if HAVE_BLUETOOTH
372
 
/* HACK:
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.
376
 
*/
377
 
extern GType bluetooth_applet_get_type(void);
378
 
void _shell_link_to_bluetooth(void);
379
 
 
380
 
void _shell_link_to_bluetooth(void) {
381
 
  bluetooth_applet_get_type();
382
 
}
383
 
#endif