From 953bc0bfab28ba2665007189befb45923e32b156 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Wed, 12 Jan 2011 19:19:49 +0100 Subject: [PATCH] AlternateTab: new extension A new extension, originally developed by Thomas Bouffon, allows to use classic AltTab (window based instead of app based) in GNOME Shell. Tested with 2.91.5 --- configure.ac | 7 +- extensions/alternate-tab/Makefile.am | 3 + extensions/alternate-tab/extension.js | 365 ++++++++++++++++++++++++ extensions/alternate-tab/metadata.json | 7 + extensions/alternate-tab/stylesheet.css | 8 + 5 files changed, 387 insertions(+), 3 deletions(-) create mode 100644 extensions/alternate-tab/Makefile.am create mode 100644 extensions/alternate-tab/extension.js create mode 100644 extensions/alternate-tab/metadata.json create mode 100644 extensions/alternate-tab/stylesheet.css diff --git a/configure.ac b/configure.ac index 7e38c091..73f040a2 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,7 @@ PKG_PROG_PKG_CONFIG([0.22]) ADDITIONAL_PACKAGES= dnl keep this in sync with extensions/Makefile.am -ALL_EXTENSIONS=example +ALL_EXTENSIONS="example alternate-tab" AC_ARG_ENABLE([extensions], [AS_HELP_STRING([--enable-extensions],[Space separated list of extensions to enable. Default is that all extensions are built.])], [], @@ -28,8 +28,8 @@ AC_ARG_ENABLE([extensions], ENABLED_EXTENSIONS= for e in $enable_extensions; do case $e in - *example*) - ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS example" + alternate-tab|example) + ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS $e" ;; *) AC_MSG_ERROR([invalid extension $e]) @@ -49,6 +49,7 @@ AC_CONFIG_FILES([ Makefile extensions/Makefile extensions/example/Makefile + extensions/alternate-tab/Makefile po/Makefile.in ]) AC_OUTPUT diff --git a/extensions/alternate-tab/Makefile.am b/extensions/alternate-tab/Makefile.am new file mode 100644 index 00000000..b8fde766 --- /dev/null +++ b/extensions/alternate-tab/Makefile.am @@ -0,0 +1,3 @@ +EXTENSION_ID = alternate-tab + +include ../../extension.mk diff --git a/extensions/alternate-tab/extension.js b/extensions/alternate-tab/extension.js new file mode 100644 index 00000000..9433ac8f --- /dev/null +++ b/extensions/alternate-tab/extension.js @@ -0,0 +1,365 @@ +// Sample extension code, makes clicking on the panel show a message +const St = imports.gi.St; +const Mainloop = imports.mainloop; +const AltTab=imports.ui.altTab; + +const Main = imports.ui.main; +const WindowManager = imports.ui.windowManager; +const Clutter = imports.gi.Clutter; +const Tweener = imports.ui.tweener; +const Shell= imports.gi.Shell; +const Lang = imports.lang; + + + +function AltTabPopup2() { + this._init(); +} + +AltTabPopup2.prototype = { + __proto__ : AltTab.AltTabPopup.prototype, + _init : function() { + this.actor = new Shell.GenericContainer({ name: 'altTabPopup', + reactive: true }); + + this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); + this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight)); + this.actor.connect('allocate', Lang.bind(this, this._allocate)); + + this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); + + + this._haveModal = false; + + this._currentApp = 0; + this._currentWindow = -1; + this._thumbnailTimeoutId = 0; + this._motionTimeoutId = 0; + + // Initially disable hover so we ignore the enter-event if + // the switcher appears underneath the current pointer location + this._disableHover(); + + this.show(); + Main.uiGroup.add_actor(this.actor); +}, + + + show : function(backward) { + let tracker = Shell.WindowTracker.get_default(); + let windows=global.get_window_actors(); +// let windows=global.get_window_actors(); + let liste=''; + let normal_windows=[]; + let appIcons=[]; + let tracker = Shell.WindowTracker.get_default(); + let apps = tracker.get_running_apps (''); + + for (let w=windows.length-1; w>=0;w--) { + let win=windows[w].get_meta_window(); + if (win.window_type==0) { + normal_windows.push(win); + } + } + normal_windows.sort(Lang.bind(this, this._sortWindows)); + + + + let win_on_top=normal_windows.shift(); + normal_windows.push(win_on_top); + windows=normal_windows; + for (let w=0; wt1) return 1; + else return -1; +}, + _appActivated : function(thumbnailList, n) { + //log(/"Activé !"); + let appIcon = this._appIcons[this._currentApp]; + Main.activateWindow(appIcon.cachedWindows[0]); + this.destroy(); + }, + _finish : function() { + let app = this._appIcons[this._currentApp]; +Main.activateWindow(app.cachedWindows[0]); + this.destroy(); + +}, +/*_appEntered : function(thumbnailList, n) { + if (!this._mouseActive) + return; + + this._select(this._currentApp, n); + },*/ + + + + +}; + + + + + +function WindowList(windows) { + this._init(windows); +} +WindowList.prototype = { + __proto__ : AltTab.AppSwitcher.prototype , + _init : function(windows) { + + AltTab.AppSwitcher.prototype._init.call(this,[]); + let activeWorkspace = global.screen.get_active_workspace(); + this._labels = new Array(); + this._thumbnailBins = new Array(); + this._clones = new Array(); + this._windows = windows; + this._arrows= new Array(); + this.icons= new Array(); + for (let w=0; w