[gnome-shell] Use Meta.Display.lookup_keyboard_action to enable workspace switches
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Use Meta.Display.lookup_keyboard_action to enable workspace switches
- Date: Thu, 18 Mar 2010 18:15:09 +0000 (UTC)
commit d98db2bd5971af54d45b79e2e20c8d41eccb8c88
Author: Colin Walters <walters verbum org>
Date: Tue Mar 16 22:08:52 2010 -0400
Use Meta.Display.lookup_keyboard_action to enable workspace switches
Also refactor Alt-F2 to use this as well.
https://bugzilla.gnome.org/show_bug.cgi?id=613101
js/ui/main.js | 24 ++++++++++++++++++++++--
js/ui/windowManager.js | 38 ++++++++++++++++++++++++--------------
2 files changed, 46 insertions(+), 16 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 5fe4783..bb837a3 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -279,6 +279,9 @@ function _globalKeyPressHandler(actor, event) {
}
} else if (type == Clutter.EventType.KEY_RELEASE) {
let symbol = event.get_key_symbol();
+ let keyCode = event.get_key_code();
+ let modifierState = Shell.get_event_state(event);
+ // Check the overview key first, this isn't a Meta.KeyBindingAction yet
if (symbol == Clutter.Super_L || symbol == Clutter.Super_R) {
// The super key is the default for triggering the overview, and should
// get us out of the overview when we are already in it.
@@ -286,8 +289,25 @@ function _globalKeyPressHandler(actor, event) {
overview.hide();
return true;
- } else if (symbol == Clutter.F2 && (Shell.get_event_state(event) & Clutter.ModifierType.MOD1_MASK)) {
- getRunDialog().open();
+ }
+
+ // Whitelist some of the Metacity actions
+ let display = global.screen.get_display();
+ let activeWorkspaceIndex = global.screen.get_active_workspace_index();
+
+ // This relies on the fact that Clutter.ModifierType is the same as Gdk.ModifierType
+ let action = display.get_keybinding_action(symbol, keyCode, modifierState);
+ switch (action) {
+ case Meta.KeyBindingAction.WORKSPACE_LEFT:
+ wm.actionMoveWorkspaceLeft();
+ return true;
+ case Meta.KeyBindingAction.WORKSPACE_RIGHT:
+ wm.actionMoveWorkspaceRight();
+ return true;
+ case Meta.KeyBindingAction.PANEL_RUN_DIALOG:
+ case Meta.KeyBindingAction.COMMAND_2:
+ getRunDialog().open();
+ return true;
}
}
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index b3c2199..eb3db1b 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -315,27 +315,37 @@ WindowManager.prototype = {
if (global.screen.n_workspaces == 1)
return;
- if (this._workspaceSwitcherPopup == null)
+ if (this._workspaceSwitcherPopup == null && Main.overview.visible)
this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
- let activeWorkspaceIndex = global.screen.get_active_workspace_index();
-
if (binding == "switch_to_workspace_left") {
- if (activeWorkspaceIndex > 0) {
- global.screen.get_workspace_by_index(activeWorkspaceIndex - 1).activate(global.get_current_time());
- this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex - 1);
- }
- else
- this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex);
+ this.actionMoveWorkspaceLeft();
}
if (binding == "switch_to_workspace_right") {
- if (activeWorkspaceIndex < global.screen.n_workspaces - 1) {
- global.screen.get_workspace_by_index(activeWorkspaceIndex + 1).activate(global.get_current_time());
+ this.actionMoveWorkspaceRight();
+ }
+ },
+
+ actionMoveWorkspaceLeft: function() {
+ let activeWorkspaceIndex = global.screen.get_active_workspace_index();
+ if (activeWorkspaceIndex > 0) {
+ global.screen.get_workspace_by_index(activeWorkspaceIndex - 1).activate(global.get_current_time());
+ if (this._workspaceSwitcherPopup != null)
+ this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex - 1);
+ } else if (this._workspaceSwitcherPopup != null){
+ this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex);
+ }
+ },
+
+ actionMoveWorkspaceRight: function() {
+ let activeWorkspaceIndex = global.screen.get_active_workspace_index();
+ if (activeWorkspaceIndex < global.screen.n_workspaces - 1) {
+ global.screen.get_workspace_by_index(activeWorkspaceIndex + 1).activate(global.get_current_time());
+ if (this._workspaceSwitcherPopup != null)
this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, activeWorkspaceIndex + 1);
- }
- else
- this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, activeWorkspaceIndex);
+ } else if (this._workspaceSwitcherPopup != null) {
+ this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, activeWorkspaceIndex);
}
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]