[gnome-shell-extensions] alternate-tab: workspace and icons part 3.2 ready
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] alternate-tab: workspace and icons part 3.2 ready
- Date: Fri, 18 Nov 2011 17:34:55 +0000 (UTC)
commit ef934af38d5eeff0db08a5db2c2b42cf4e1146a2
Author: Joachim Bargsten <jw bargsten org>
Date: Tue Oct 4 00:40:59 2011 +0200
alternate-tab: workspace and icons part 3.2 ready
The workspace and icons switcher is now gnome 3.2 ready.
https://bugzilla.gnome.org/show_bug.cgi?id=661281
extensions/alternate-tab/extension.js | 68 ++++++++++++++++++++------------
1 files changed, 42 insertions(+), 26 deletions(-)
---
diff --git a/extensions/alternate-tab/extension.js b/extensions/alternate-tab/extension.js
index c872f5c..09e1d6c 100644
--- a/extensions/alternate-tab/extension.js
+++ b/extensions/alternate-tab/extension.js
@@ -23,21 +23,26 @@ const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;
const N_ = function(e) { return e };
-const POPUP_FADE_TIME = 0.1; // seconds
+const POPUP_DELAY_TIMEOUT = 150; // milliseconds
const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.alternate-tab';
const SETTINGS_BEHAVIOUR_KEY = 'behaviour';
const SETTINGS_FIRST_TIME_KEY = 'first-time';
const MODES = {
- native: function() {
- Main.wm._startAppSwitcher();
+ native: function(shellwm, binding, mask, window, backwards) {
+ shellwm._startAppSwitcher(shellwm, binding, mask, window, backwards);
},
all_thumbnails: function() {
new AltTabPopup2();
},
- workspace_icons: function() {
- new AltTabPopupW().show();
+ workspace_icons: function(shellwm, binding, mask, window, backwards) {
+ if (shellwm._workspaceSwitcherPopup != null)
+ shellwm._workspaceSwitcherPopup.actor.hide();
+
+ let tabPopup = new AltTabPopupW();
+ if (!tabPopup.show(backwards, binding, mask))
+ tabPopup.destroy();
}
};
@@ -68,7 +73,9 @@ function AltTabPopupW() {
AltTabPopupW.prototype = {
__proto__ : AltTab.AltTabPopup.prototype,
- show : function(backward, switch_group) {
+ _windowActivated : function(thumbnailList, n) { },
+
+ show : function(backward, binding, mask) {
let appSys = Shell.AppSystem.get_default();
let apps = appSys.get_running ();
@@ -78,6 +85,7 @@ AltTabPopupW.prototype = {
if (!Main.pushModal(this.actor))
return false;
this._haveModal = true;
+ this._modifierMask = AltTab.primaryModifier(mask);
this.actor.connect('key-press-event', Lang.bind(this, this._keyPressEvent));
this.actor.connect('key-release-event', Lang.bind(this, this._keyReleaseEvent));
@@ -92,16 +100,22 @@ AltTabPopupW.prototype = {
this._appIcons = this._appSwitcher.icons;
+ // Need to force an allocation so we can figure out whether we
+ // need to scroll when selecting
+ this.actor.opacity = 0;
+ this.actor.show();
+ this.actor.get_allocation_box();
+
// Make the initial selection
- if (switch_group) {
- if (backward) {
- this._select(0, this._appIcons[0].cachedWindows.length - 1);
- } else {
- if (this._appIcons[0].cachedWindows.length > 1)
- this._select(0, 1);
- else
- this._select(0, 0);
- }
+ if (binding == 'switch_group') {
+ //see AltTab.AltTabPopup.show function
+ //cached windows are always of length one, so select first app and the window
+ //the direction doesn't matter, so ignore backward
+ this._select(0, 0);
+ } else if (binding == 'switch_group_backward') {
+ this._select(0, 0);
+ } else if (binding == 'switch_windows_backward') {
+ this._select(this._appIcons.length - 1);
} else if (this._appIcons.length == 1) {
this._select(0);
} else if (backward) {
@@ -110,24 +124,25 @@ AltTabPopupW.prototype = {
this._select(1);
}
+
// There's a race condition; if the user released Alt before
// we got the grab, then we won't be notified. (See
// https://bugzilla.gnome.org/show_bug.cgi?id=596695 for
// details.) So we check now. (Have to do this after updating
// selection.)
let [x, y, mods] = global.get_pointer();
- if (!(mods & Gdk.ModifierType.MOD1_MASK)) {
+ if (!(mods & this._modifierMask)) {
this._finish();
return false;
}
- this.actor.opacity = 0;
- this.actor.show();
- Tweener.addTween(this.actor,
- { opacity: 255,
- time: POPUP_FADE_TIME,
- transition: 'easeOutQuad'
- });
+ // We delay showing the popup so that fast Alt+Tab users aren't
+ // disturbed by the popup briefly flashing.
+ this._initialDelayTimeoutId = Mainloop.timeout_add(POPUP_DELAY_TIMEOUT,
+ Lang.bind(this, function () {
+ this.actor.opacity = 255;
+ this._initialDelayTimeoutId = 0;
+ }));
return true;
},
@@ -545,15 +560,16 @@ function init(metadata) {
imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
}
-function doAltTab(shellwm, binding, window, backwards) {
+function doAltTab(shellwm, binding, mask, window, backwards) {
let settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
+
if(settings.get_boolean(SETTINGS_FIRST_TIME_KEY)) {
new AltTabSettingsDialog().open();
} else {
let behaviour = settings.get_string(SETTINGS_BEHAVIOUR_KEY);
if(behaviour in MODES) {
- MODES[behaviour](binding, backwards);
+ MODES[behaviour](shellwm, binding, mask, window, backwards);
}
}
}
@@ -570,4 +586,4 @@ function disable() {
Main.wm.setKeybindingHandler('switch_group', Lang.bind(Main.wm, Main.wm._startAppSwitcher));
Main.wm.setKeybindingHandler('switch_windows_backward', Lang.bind(Main.wm, Main.wm._startAppSwitcher));
Main.wm.setKeybindingHandler('switch_group_backward', Lang.bind(Main.wm, Main.wm._startAppSwitcher));
-}
\ No newline at end of file
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]