[gnome-shell/wip/gestures: 10/10] windowManager: Switch the focused application on 3-finger hold + tap
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/gestures: 10/10] windowManager: Switch the focused application on 3-finger hold + tap
- Date: Fri, 27 Jun 2014 22:05:40 +0000 (UTC)
commit 38509081e762332ee62d7a16c45050698047fda2
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jun 27 22:45:58 2014 +0200
windowManager: Switch the focused application on 3-finger hold + tap
The gesture action only cycles through the applications in the current
workspace.
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 b02e93d..74b1c49 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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]