~mterry/ubuntu/natty/gnome-shell/wip

« back to all changes in this revision

Viewing changes to src/shell-wm.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2009-10-12 22:44:00 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091012224400-k91p42yvou07i525
Tags: 2.28.0-0ubuntu1
* New upstream version
* debian/control:
  - updated build requirement
* debian/patches/80_git_change_fix_alt_tab_ressource_usage.patch:
  - git change to fix ressources not being freed on alt-tab

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
2
 
 
3
#include <string.h>
 
4
 
3
5
#include "shell-wm.h"
4
6
#include "shell-global.h"
5
7
#include "shell-marshal.h"
6
8
 
 
9
#include <keybindings.h>
 
10
 
7
11
struct _ShellWM {
8
12
  GObject parent;
9
13
 
27
31
  SWITCH_WORKSPACE,
28
32
  KILL_SWITCH_WORKSPACE,
29
33
 
30
 
  BEGIN_ALT_TAB,
 
34
  KEYBINDING,
31
35
 
32
36
  LAST_SIGNAL
33
37
};
42
46
static void
43
47
shell_wm_init (ShellWM *wm)
44
48
{
45
 
  meta_alt_tab_handler_register (SHELL_TYPE_ALT_TAB_HANDLER);
46
49
}
47
50
 
48
51
static void
169
172
                  NULL, NULL,
170
173
                  g_cclosure_marshal_VOID__VOID,
171
174
                  G_TYPE_NONE, 0);
172
 
  shell_wm_signals[BEGIN_ALT_TAB] =
173
 
    g_signal_new ("begin-alt-tab",
 
175
 
 
176
  /**
 
177
   * ShellWM::keybinding:
 
178
   * @shellwm: the #ShellWM
 
179
   * @binding: the keybinding name
 
180
   * @window: for window keybindings, the #MetaWindow
 
181
   * @backwards: for "reversible" keybindings, whether or not
 
182
   * the backwards (Shifted) variant was invoked
 
183
   *
 
184
   * Emitted when a keybinding captured via
 
185
   * shell_wm_takeover_keybinding() is invoked. The keybinding name
 
186
   * (which has underscores, not hyphens) is also included as the
 
187
   * detail of the signal name, so you can connect just specific
 
188
   * keybindings.
 
189
   */
 
190
  shell_wm_signals[KEYBINDING] =
 
191
    g_signal_new ("keybinding",
174
192
                  G_TYPE_FROM_CLASS (klass),
175
 
                  G_SIGNAL_RUN_LAST,
 
193
                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
176
194
                  0,
177
195
                  NULL, NULL,
178
 
                  g_cclosure_marshal_VOID__OBJECT,
179
 
                  G_TYPE_NONE, 1,
180
 
                  META_TYPE_ALT_TAB_HANDLER);
 
196
                  _shell_marshal_VOID__STRING_OBJECT_BOOLEAN,
 
197
                  G_TYPE_NONE, 3,
 
198
                  G_TYPE_STRING,
 
199
                  META_TYPE_WINDOW,
 
200
                  G_TYPE_BOOLEAN);
181
201
}
182
202
 
183
203
void
391
411
  g_signal_emit (wm, shell_wm_signals[DESTROY], 0, actor);
392
412
}
393
413
 
394
 
/* Called from shell-alttab.c */
395
 
void
396
 
_shell_wm_begin_alt_tab (ShellWM              *wm,
397
 
                         ShellAltTabHandler   *handler)
398
 
{
399
 
  g_signal_emit (wm, shell_wm_signals[BEGIN_ALT_TAB], 0, handler);
400
 
}
401
 
 
402
414
/**
403
415
 * shell_wm_new:
404
416
 * @plugin: the #MutterPlugin
417
429
 
418
430
  return wm;
419
431
}
 
432
 
 
433
static void
 
434
shell_wm_key_handler (MetaDisplay    *display,
 
435
                      MetaScreen     *screen,
 
436
                      MetaWindow     *window,
 
437
                      XEvent         *event,
 
438
                      MetaKeyBinding *binding,
 
439
                      gpointer        data)
 
440
{
 
441
  ShellWM *wm = data;
 
442
  gboolean backwards = (event->xkey.state & ShiftMask);
 
443
 
 
444
  g_signal_emit (wm, shell_wm_signals[KEYBINDING],
 
445
                 g_quark_from_string (binding->name),
 
446
                 binding->name, window, backwards);
 
447
}
 
448
 
 
449
/**
 
450
 * shell_wm_takeover_keybinding:
 
451
 * @wm: the #ShellWM
 
452
 * @binding_name: a mutter keybinding name
 
453
 *
 
454
 * Tells mutter to forward keypresses for @binding_name to the shell
 
455
 * rather than processing them internally. This will cause a
 
456
 * #ShellWM::keybinding signal to be emitted when that key is pressed.
 
457
 */
 
458
void
 
459
shell_wm_takeover_keybinding (ShellWM      *wm,
 
460
                              const char   *binding_name)
 
461
{
 
462
  meta_keybindings_set_custom_handler (binding_name,
 
463
                                       shell_wm_key_handler,
 
464
                                       wm, NULL);
 
465
}