~darkxst/ubuntu/saucy/gnome-shell/upstart_log

« back to all changes in this revision

Viewing changes to src/gnome-shell-plugin.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-31 12:01:12 UTC
  • mfrom: (1.1.49) (19.1.36 experimental)
  • Revision ID: package-import@ubuntu.com-20130531120112-ew91khxf051x9i2r
Tags: 3.8.2-1ubuntu1
* Merge with Debian (LP: #1185869, #1185721). Remaining changes:
  - debian/control.in:
    + Build-depend on libsystemd-login-dev & libsystemd-daemon-dev
    + Depend on gdm instead of gdm3
    + Don't recommend gnome-session-fallback
  - debian/patches/40_change-pam-name-to-match-gdm.patch:
  - debian/patches/revert-suspend-break.patch:
    + Disabled, not needed on Ubuntu
  - debian/patches/ubuntu-lightdm-user-switching.patch:
    + Allow user switching when using LightDM. Thanks Gerhard Stein
      for rebasing against gnome-shell 3.8!
  - debian/patches/ubuntu_lock_on_suspend.patch
    + Respect Ubuntu's lock-on-suspend setting.
      Disabled until it can be rewritten.
  - debian/patches/git_relock_screen_after_crash.patch:
    + Add Upstream fix for unlocked session after crash (LP: #1064584)
* Note that the new GNOME Classic mode (which requires installing
  gnome-shell-extensions) won't work until gnome-session 3.8 is
  available in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <stdlib.h>
29
29
#include <string.h>
30
30
 
 
31
#define CLUTTER_ENABLE_EXPERIMENTAL_API
 
32
#define COGL_ENABLE_EXPERIMENTAL_API
31
33
#include <clutter/clutter.h>
32
34
#include <clutter/x11/clutter-x11.h>
33
 
#ifdef HAVE_GLX
34
 
#include <GL/glx.h>
35
 
#include <GL/glxext.h>
36
 
#endif
37
35
#include <gjs/gjs.h>
38
36
#include <meta/display.h>
39
37
#include <meta/meta-plugin.h>
74
72
 
75
73
static gboolean              gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
76
74
                                                               XEvent     *event);
 
75
 
 
76
static gboolean              gnome_shell_plugin_keybinding_filter (MetaPlugin *plugin,
 
77
                                                                   MetaKeyBinding *binding);
77
78
static const MetaPluginInfo *gnome_shell_plugin_plugin_info   (MetaPlugin *plugin);
78
79
 
79
80
 
98
99
  int glx_error_base;
99
100
  int glx_event_base;
100
101
  guint have_swap_event : 1;
 
102
  CoglContext *cogl_context;
101
103
 
102
104
  ShellGlobal *global;
103
105
};
128
130
  plugin_class->kill_window_effects   = gnome_shell_plugin_kill_window_effects;
129
131
  plugin_class->kill_switch_workspace = gnome_shell_plugin_kill_switch_workspace;
130
132
 
131
 
  plugin_class->xevent_filter    = gnome_shell_plugin_xevent_filter;
132
 
  plugin_class->plugin_info      = gnome_shell_plugin_plugin_info;
 
133
  plugin_class->xevent_filter     = gnome_shell_plugin_xevent_filter;
 
134
  plugin_class->keybinding_filter = gnome_shell_plugin_keybinding_filter;
 
135
  plugin_class->plugin_info       = gnome_shell_plugin_plugin_info;
133
136
}
134
137
 
135
138
static void
137
140
{
138
141
}
139
142
 
140
 
static void
141
 
gnome_shell_plugin_start (MetaPlugin *plugin)
 
143
static gboolean
 
144
gnome_shell_plugin_has_swap_event (GnomeShellPlugin *shell_plugin)
142
145
{
143
 
  GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
144
 
#ifdef HAVE_GLX
 
146
  MetaPlugin *plugin = META_PLUGIN (shell_plugin);
 
147
  CoglDisplay *cogl_display =
 
148
    cogl_context_get_display (shell_plugin->cogl_context);
 
149
  CoglRenderer *renderer = cogl_display_get_renderer (cogl_display);
 
150
  const char * (* query_extensions_string) (Display *dpy, int screen);
 
151
  Bool (* query_extension) (Display *dpy, int *error, int *event);
145
152
  MetaScreen *screen;
146
153
  MetaDisplay *display;
147
154
  Display *xdisplay;
148
155
  const char *glx_extensions;
149
 
#endif
 
156
 
 
157
  /* We will only get swap events if Cogl is using GLX */
 
158
  if (cogl_renderer_get_winsys_id (renderer) != COGL_WINSYS_ID_GLX)
 
159
    return FALSE;
 
160
 
 
161
  screen = meta_plugin_get_screen (plugin);
 
162
  display = meta_screen_get_display (screen);
 
163
 
 
164
  xdisplay = meta_display_get_xdisplay (display);
 
165
 
 
166
  query_extensions_string =
 
167
    (void *) cogl_get_proc_address ("glXQueryExtensionsString");
 
168
  query_extension =
 
169
    (void *) cogl_get_proc_address ("glXQueryExtension");
 
170
 
 
171
  query_extension (xdisplay,
 
172
                   &shell_plugin->glx_error_base,
 
173
                   &shell_plugin->glx_event_base);
 
174
 
 
175
  glx_extensions =
 
176
    query_extensions_string (xdisplay,
 
177
                             meta_screen_get_screen_number (screen));
 
178
 
 
179
  return strstr (glx_extensions, "GLX_INTEL_swap_event") != NULL;
 
180
}
 
181
 
 
182
static void
 
183
gnome_shell_plugin_start (MetaPlugin *plugin)
 
184
{
 
185
  GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
150
186
  GError *error = NULL;
151
187
  int status;
152
188
  GjsContext *gjs_context;
153
 
 
154
 
#ifdef HAVE_GLX
155
 
  screen = meta_plugin_get_screen (plugin);
156
 
  display = meta_screen_get_display (screen);
157
 
 
158
 
  xdisplay = meta_display_get_xdisplay (display);
159
 
 
160
 
  glXQueryExtension (xdisplay,
161
 
                     &shell_plugin->glx_error_base,
162
 
                     &shell_plugin->glx_event_base);
163
 
 
164
 
  glx_extensions = glXQueryExtensionsString (xdisplay,
165
 
                                             meta_screen_get_screen_number (screen));
166
 
  shell_plugin->have_swap_event = strstr (glx_extensions, "GLX_INTEL_swap_event") != NULL;
167
 
#else
168
 
  shell_plugin->have_swap_event = 0;
169
 
#endif
 
189
  ClutterBackend *backend;
 
190
 
 
191
  backend = clutter_get_default_backend ();
 
192
  shell_plugin->cogl_context = clutter_backend_get_cogl_context (backend);
 
193
 
 
194
  shell_plugin->have_swap_event =
 
195
    gnome_shell_plugin_has_swap_event (shell_plugin);
170
196
 
171
197
  shell_perf_log_define_event (shell_perf_log_get_default (),
172
198
                               "glx.swapComplete",
289
315
}
290
316
 
291
317
static gboolean
 
318
ignore_crossing_event (MetaPlugin   *plugin,
 
319
                       XIEnterEvent *enter_event)
 
320
{
 
321
  MetaScreen *screen = meta_plugin_get_screen (plugin);
 
322
  ClutterStage *stage = CLUTTER_STAGE (meta_get_stage_for_screen (screen));
 
323
 
 
324
  if (enter_event->event == clutter_x11_get_stage_window (stage))
 
325
    {
 
326
      /* If the pointer enters a child of the stage window (eg, a
 
327
       * trayicon), we want to consider it to still be in the stage,
 
328
       * so don't let Clutter see the event.
 
329
       */
 
330
      if (enter_event->detail == XINotifyInferior)
 
331
        return TRUE;
 
332
 
 
333
      /* If the pointer is grabbed by a window it is not currently in,
 
334
       * filter that out as well. In particular, if a trayicon grabs
 
335
       * the pointer after a click on its label, we don't want to hide
 
336
       * the message tray. Filtering out this event will leave Clutter
 
337
       * out of sync, but that happens fairly often with grabs, and we
 
338
       * can work around it. (Eg, shell_global_sync_pointer().)
 
339
       */
 
340
      if (enter_event->mode == XINotifyGrab &&
 
341
          (enter_event->detail == XINotifyNonlinear ||
 
342
           enter_event->detail == XINotifyNonlinearVirtual))
 
343
        return TRUE;
 
344
    }
 
345
 
 
346
  return FALSE;
 
347
}
 
348
 
 
349
static gboolean
292
350
gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
293
351
                                  XEvent     *xev)
294
352
{
295
353
  MetaScreen *screen = meta_plugin_get_screen (plugin);
296
 
  ClutterStage *stage = CLUTTER_STAGE (meta_get_stage_for_screen (screen));
 
354
  MetaDisplay *display = meta_screen_get_display (screen);
297
355
 
298
356
  GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
299
357
#ifdef GLX_INTEL_swap_event
313
371
    }
314
372
#endif
315
373
 
316
 
  if ((xev->xany.type == EnterNotify || xev->xany.type == LeaveNotify)
317
 
      && xev->xcrossing.window == clutter_x11_get_stage_window (stage))
 
374
  /* Make sure that Clutter doesn't see certain focus change events,
 
375
   * so that when we're moving into something like a tray icon, we
 
376
   * don't unfocus the container. */
 
377
  if (xev->type == GenericEvent &&
 
378
      xev->xcookie.extension == meta_display_get_xinput_opcode (display))
318
379
    {
319
 
      /* If the pointer enters a child of the stage window (eg, a
320
 
       * trayicon), we want to consider it to still be in the stage,
321
 
       * so don't let Clutter see the event.
322
 
       */
323
 
      if (xev->xcrossing.detail == NotifyInferior)
324
 
        return TRUE;
325
 
 
326
 
      /* If the pointer is grabbed by a window it is not currently in,
327
 
       * filter that out as well. In particular, if a trayicon grabs
328
 
       * the pointer after a click on its label, we don't want to hide
329
 
       * the message tray. Filtering out this event will leave Clutter
330
 
       * out of sync, but that happens fairly often with grabs, and we
331
 
       * can work around it. (Eg, shell_global_sync_pointer().)
332
 
       */
333
 
      if (xev->xcrossing.mode == NotifyGrab &&
334
 
          (xev->xcrossing.detail == NotifyNonlinear ||
335
 
           xev->xcrossing.detail == NotifyNonlinearVirtual))
 
380
      XIEvent *input_event = (XIEvent *) xev->xcookie.data;
 
381
      if ((input_event->evtype == XI_Enter || input_event->evtype == XI_Leave) &&
 
382
          ignore_crossing_event (plugin, (XIEnterEvent *) input_event))
336
383
        return TRUE;
337
384
    }
338
385
 
345
392
  return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE;
346
393
}
347
394
 
 
395
static gboolean
 
396
gnome_shell_plugin_keybinding_filter (MetaPlugin     *plugin,
 
397
                                      MetaKeyBinding *binding)
 
398
{
 
399
  return _shell_wm_filter_keybinding (get_shell_wm (), binding);
 
400
}
 
401
 
348
402
static const
349
403
MetaPluginInfo *gnome_shell_plugin_plugin_info (MetaPlugin *plugin)
350
404
{