diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2014-06-27 22:45:58 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2014-06-27 23:32:54 +0200 |
commit | 38509081e762332ee62d7a16c45050698047fda2 (patch) | |
tree | 88ef501321fbf2219a0cc3cc38c2bba86a91275f | |
parent | f659b66a9db44504c67d93947ea249eaec520e90 (diff) | |
download | gnome-shell-wip/gestures.tar.gz |
windowManager: Switch the focused application on 3-finger hold + tapwip/gestures
The gesture action only cycles through the applications in the current
workspace.
-rw-r--r-- | js/ui/windowManager.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js index b02e93d1f..74b1c4997 100644 --- a/js/ui/windowManager.js +++ b/js/ui/windowManager.js @@ -12,6 +12,7 @@ const Shell = imports.gi.Shell; const AltTab = imports.ui.altTab; const WorkspaceSwitchAction = imports.ui.workspaceSwitchAction; +const AppSwitchAction = imports.ui.appSwitchAction; const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup; const Main = imports.ui.main; const ModalDialog = imports.ui.modalDialog; @@ -691,6 +692,46 @@ const WindowManager = new Lang.Class({ this.actionMoveWorkspace(newWs); })); global.stage.add_action(gesture); + + gesture = new AppSwitchAction.AppSwitchAction(); + gesture.connect('activated', Lang.bind(this, this._switchApp)); + global.stage.add_action(gesture); + }, + + _lookupIndex: function (windows, metaWindow) { + for (let i = 0; i < windows.length; i++) { + if (windows[i].metaWindow == metaWindow) { + return i; + } + } + return -1; + }, + + _switchApp : function () { + let windows = global.get_window_actors().filter(Lang.bind(this, function(actor) { + let win = actor.metaWindow; + return (!win.is_override_redirect() && + win.located_on_workspace(global.screen.get_active_workspace())); + })); + + if (windows.length == 0) + return; + + let focusWindow = global.display.focus_window; + let nextWindow; + + if (focusWindow == null) + nextWindow = windows[0].metaWindow; + else { + let index = this._lookupIndex (windows, focusWindow) + 1; + + if (index >= windows.length) + index = 0; + + nextWindow = windows[index].metaWindow; + } + + Main.activateWindow(nextWindow); }, keepWorkspaceAlive: function(workspace, duration) { |