Skip to content
Browse files

shell-wm: Remove takeover_keybinding()

Introspection support is now good enough to set a custom keybinding
handler directly from JS.

https://bugzilla.gnome.org/show_bug.cgi?id=663584
  • Loading branch information...
1 parent 9b87509 commit d591000be224b2fe17ed78212e83d3063017ff4b Florian Müllner committed with rat4 Nov 7, 2011
Showing with 31 additions and 102 deletions.
  1. +2 −6 js/ui/main.js
  2. +29 −29 js/ui/windowManager.js
  3. +0 −63 src/cinnamon-wm.c
  4. +0 −4 src/cinnamon-wm.h
View
8 js/ui/main.js
@@ -144,15 +144,11 @@ function _initUserSession() {
ExtensionSystem.init();
ExtensionSystem.loadExtensions();
- let cinnamonwm = global.window_manager;
-
- cinnamonwm.takeover_keybinding('panel-run-dialog');
- cinnamonwm.connect('keybinding::panel-run-dialog', function () {
+ Meta.keybindings_set_custom_handler('panel-run-dialog', function() {
getRunDialog().open();
});
- cinnamonwm.takeover_keybinding('panel-main-menu');
- cinnamonwm.connect('keybinding::panel-main-menu', function () {
+ Meta.keybindings_set_custom_handler('panel-main-menu', function () {
expo.toggle();
});
View
58 js/ui/windowManager.js
@@ -89,7 +89,6 @@ WindowManager.prototype = {
_init : function() {
this._cinnamonwm = global.window_manager;
- this._keyBindingHandlers = [];
this._minimizing = [];
this._maximizing = [];
this._unmaximizing = [];
@@ -117,15 +116,24 @@ WindowManager.prototype = {
this._cinnamonwm.connect('map', Lang.bind(this, this._mapWindow));
this._cinnamonwm.connect('destroy', Lang.bind(this, this._destroyWindow));
- this.setKeybindingHandler('switch-to-workspace-left', Lang.bind(this, this._showWorkspaceSwitcher));
- this.setKeybindingHandler('switch-to-workspace-right', Lang.bind(this, this._showWorkspaceSwitcher));
- this.setKeybindingHandler('switch-to-workspace-up', Lang.bind(this, this._showWorkspaceSwitcher));
- this.setKeybindingHandler('switch-to-workspace-down', Lang.bind(this, this._showWorkspaceSwitcher));
- this.setKeybindingHandler('switch-windows', Lang.bind(this, this._startAppSwitcher));
- this.setKeybindingHandler('switch-group', Lang.bind(this, this._startAppSwitcher));
- this.setKeybindingHandler('switch-windows-backward', Lang.bind(this, this._startAppSwitcher));
- this.setKeybindingHandler('switch-group-backward', Lang.bind(this, this._startAppSwitcher));
- this.setKeybindingHandler('switch-panels', Lang.bind(this, this._startA11ySwitcher));
+ Meta.keybindings_set_custom_handler('switch-to-workspace-left',
+ Lang.bind(this, this._showWorkspaceSwitcher));
+ Meta.keybindings_set_custom_handler('switch-to-workspace-right',
+ Lang.bind(this, this._showWorkspaceSwitcher));
+ Meta.keybindings_set_custom_handler('switch-to-workspace-up',
+ Lang.bind(this, this._showWorkspaceSwitcher));
+ Meta.keybindings_set_custom_handler('switch-to-workspace-down',
+ Lang.bind(this, this._showWorkspaceSwitcher));
+ Meta.keybindings_set_custom_handler('switch-windows',
+ Lang.bind(this, this._startAppSwitcher));
+ Meta.keybindings_set_custom_handler('switch-group',
+ Lang.bind(this, this._startAppSwitcher));
+ Meta.keybindings_set_custom_handler('switch-windows-backward',
+ Lang.bind(this, this._startAppSwitcher));
+ Meta.keybindings_set_custom_handler('switch-group-backward',
+ Lang.bind(this, this._startAppSwitcher));
+ Meta.keybindings_set_custom_handler('switch-panels',
+ Lang.bind(this, this._startA11ySwitcher));
Main.overview.connect('showing', Lang.bind(this, function() {
for (let i = 0; i < this._dimmedWindows.length; i++)
@@ -137,16 +145,6 @@ WindowManager.prototype = {
}));
},
- setKeybindingHandler: function(keybinding, handler){
- if (this._keyBindingHandlers[keybinding])
- this._cinnamonwm.disconnect(this._keyBindingHandlers[keybinding]);
- else
- this._cinnamonwm.takeover_keybinding(keybinding);
-
- this._keyBindingHandlers[keybinding] =
- this._cinnamonwm.connect('keybinding::' + keybinding, handler);
- },
-
blockAnimations: function() {
this._animationBlockCount++;
},
@@ -738,34 +736,36 @@ WindowManager.prototype = {
cinnamonwm.completed_switch_workspace();
},
- _startAppSwitcher : function(cinnamonwm, binding, mask, window, backwards) {
+ _startAppSwitcher : function(display, screen, window, binding) {
let tabPopup = new AltTab.AltTabPopup();
- if (!tabPopup.show(backwards, binding, mask))
+ let modifiers = binding.get_modifiers();
+ let backwards = modifiers & Meta.VirtualModifier.SHIFT_MASK;
+ if (!tabPopup.show(backwards, binding.get_name(), binding.get_mask()))
tabPopup.destroy();
},
- _startA11ySwitcher : function(cinnamonwm, binding, mask, window, backwards) {
+ _startA11ySwitcher : function(display, screen, window, binding) {
},
- _showWorkspaceSwitcher : function(cinnamonwm, binding, mask, window, backwards) {
- if (binding == 'switch-to-workspace-up') {
+ _showWorkspaceSwitcher : function(display, screen, window, binding) {
+ if (binding.get_name() == 'switch-to-workspace-up') {
Main.expo.toggle();
return;
}
- if (binding == 'switch-to-workspace-down') {
+ if (binding.get_name() == 'switch-to-workspace-down') {
Main.overview.toggle();
return;
}
- if (global.screen.n_workspaces == 1)
+ if (screen.n_workspaces == 1)
return;
- if (binding == 'switch-to-workspace-left')
+ if (binding.get_name() == 'switch-to-workspace-left')
this.actionMoveWorkspaceLeft();
- else if (binding == 'switch-to-workspace-right')
+ else if (binding.get_name() == 'switch-to-workspace-right')
this.actionMoveWorkspaceRight();
},
View
63 src/cinnamon-wm.c
@@ -28,8 +28,6 @@ enum
KILL_SWITCH_WORKSPACE,
KILL_WINDOW_EFFECTS,
- KEYBINDING,
-
LAST_SIGNAL
};
@@ -126,34 +124,6 @@ cinnamon_wm_class_init (CinnamonWMClass *klass)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
META_TYPE_WINDOW_ACTOR);
-
- /**
- * CinnamonWM::keybinding:
- * @cinnamonwm: the #CinnamonWM
- * @binding: the keybinding name
- * @mask: the modifier mask used
- * @window: for window keybindings, the #MetaWindow
- * @backwards: for "reversible" keybindings, whether or not
- * the backwards (Shifted) variant was invoked
- *
- * Emitted when a keybinding captured via
- * cinnamon_wm_takeover_keybinding() is invoked. The keybinding name
- * (which has underscores, not hyphens) is also included as the
- * detail of the signal name, so you can connect just specific
- * keybindings.
- */
- cinnamon_wm_signals[KEYBINDING] =
- g_signal_new ("keybinding",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL,
- _cinnamon_marshal_VOID__STRING_UINT_OBJECT_BOOLEAN,
- G_TYPE_NONE, 4,
- G_TYPE_STRING,
- G_TYPE_UINT,
- META_TYPE_WINDOW,
- G_TYPE_BOOLEAN);
}
void
@@ -325,36 +295,3 @@ cinnamon_wm_new (MetaPlugin *plugin)
return wm;
}
-static void
-cinnamon_wm_key_handler (MetaDisplay *display,
- MetaScreen *screen,
- MetaWindow *window,
- XEvent *event,
- MetaKeyBinding *binding,
- gpointer data)
-{
- CinnamonWM *wm = data;
- gboolean backwards = (event->xkey.state & ShiftMask);
-
- g_signal_emit (wm, cinnamon_wm_signals[KEYBINDING],
- g_quark_from_string (binding->name),
- binding->name, binding->mask, window, backwards);
-}
-
-/**
- * cinnamon_wm_takeover_keybinding:
- * @wm: the #CinnamonWM
- * @binding_name: a meta keybinding name
- *
- * Tells muffin to forward keypresses for @binding_name to Cinnamon
- * rather than processing them internally. This will cause a
- * #CinnamonWM::keybinding signal to be emitted when that key is pressed.
- */
-void
-cinnamon_wm_takeover_keybinding (CinnamonWM *wm,
- const char *binding_name)
-{
- meta_keybindings_set_custom_handler (binding_name,
- cinnamon_wm_key_handler,
- wm, NULL);
-}
View
4 src/cinnamon-wm.h
@@ -39,10 +39,6 @@ void cinnamon_wm_completed_destroy (CinnamonWM *wm,
MetaWindowActor *actor);
void cinnamon_wm_completed_switch_workspace (CinnamonWM *wm);
-/* Keybinding stuff */
-void cinnamon_wm_takeover_keybinding (CinnamonWM *wm,
- const char *binding_name);
-
G_END_DECLS
#endif /* __CINNAMON_WM_H__ */

0 comments on commit d591000

Please sign in to comment.
Something went wrong with that request. Please try again.