altTab: Ignore workspaces in popups
Currently both the app switcher and the thumbnail list divide items first into two groups (based on whether the item is located on the current workspace or not), and then sort each group individually by MRU. The resulting behavior is often confusing, e.g. when using alt-tab a second time does not switch back to the original window when the first invocation involved a workspace switch and the workspace contains windows of more than one application. Instead, make the behavior more predictable by sorting both lists strictly by MRU. https://bugzilla.gnome.org/show_bug.cgi?id=661156
This commit is contained in:
parent
e74a82b9d6
commit
b50702dd52
@ -98,43 +98,13 @@ const AppSwitcherPopup = new Lang.Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_getAppLists: function() {
|
|
||||||
let tracker = Shell.WindowTracker.get_default();
|
|
||||||
let appSys = Shell.AppSystem.get_default();
|
|
||||||
let allApps = appSys.get_running ();
|
|
||||||
|
|
||||||
let screen = global.screen;
|
|
||||||
let display = screen.get_display();
|
|
||||||
let windows = display.get_tab_list(Meta.TabList.NORMAL_ALL, screen,
|
|
||||||
screen.get_active_workspace());
|
|
||||||
|
|
||||||
// windows is only the windows on the current workspace. For
|
|
||||||
// each one, if it corresponds to an app we know, move that
|
|
||||||
// app from allApps to apps.
|
|
||||||
let apps = [];
|
|
||||||
for (let i = 0; i < windows.length && allApps.length != 0; i++) {
|
|
||||||
let app = tracker.get_window_app(windows[i]);
|
|
||||||
let index = allApps.indexOf(app);
|
|
||||||
if (index != -1) {
|
|
||||||
apps.push(app);
|
|
||||||
allApps.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now @apps is a list of apps on the current workspace, in
|
|
||||||
// standard Alt+Tab order (MRU except for minimized windows),
|
|
||||||
// and allApps is a list of apps that only appear on other
|
|
||||||
// workspaces, sorted by user_time, which is good enough.
|
|
||||||
return [apps, allApps];
|
|
||||||
},
|
|
||||||
|
|
||||||
_createSwitcher: function() {
|
_createSwitcher: function() {
|
||||||
let [localApps, otherApps] = this._getAppLists();
|
let apps = Shell.AppSystem.get_default().get_running ();
|
||||||
|
|
||||||
if (localApps.length == 0 && otherApps.length == 0)
|
if (apps.length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this._switcherList = new AppSwitcher(localApps, otherApps, this);
|
this._switcherList = new AppSwitcher(apps, this);
|
||||||
this._items = this._switcherList.icons;
|
this._items = this._switcherList.icons;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -265,12 +235,8 @@ const AppSwitcherPopup = new Lang.Class({
|
|||||||
this.parent();
|
this.parent();
|
||||||
|
|
||||||
let appIcon = this._items[this._selectedIndex];
|
let appIcon = this._items[this._selectedIndex];
|
||||||
let window;
|
let window = this._currentWindow > 0 ? this._currentWindow : 0;
|
||||||
if (this._currentWindow >= 0)
|
appIcon.app.activate_window(appIcon.cachedWindows[window], timestamp);
|
||||||
window = appIcon.cachedWindows[this._currentWindow];
|
|
||||||
else
|
|
||||||
window = null;
|
|
||||||
appIcon.app.activate_window(window, timestamp);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_onDestroy : function() {
|
_onDestroy : function() {
|
||||||
@ -461,34 +427,26 @@ const AppSwitcher = new Lang.Class({
|
|||||||
Name: 'AppSwitcher',
|
Name: 'AppSwitcher',
|
||||||
Extends: SwitcherPopup.SwitcherList,
|
Extends: SwitcherPopup.SwitcherList,
|
||||||
|
|
||||||
_init : function(localApps, otherApps, altTabPopup) {
|
_init : function(apps, altTabPopup) {
|
||||||
this.parent(true);
|
this.parent(true);
|
||||||
|
|
||||||
// Construct the AppIcons, add to the popup
|
|
||||||
let activeWorkspace = global.screen.get_active_workspace();
|
|
||||||
let workspaceIcons = [];
|
|
||||||
let otherIcons = [];
|
|
||||||
for (let i = 0; i < localApps.length; i++) {
|
|
||||||
let appIcon = new AppIcon(localApps[i]);
|
|
||||||
// Cache the window list now; we don't handle dynamic changes here,
|
|
||||||
// and we don't want to be continually retrieving it
|
|
||||||
appIcon.cachedWindows = appIcon.app.get_windows();
|
|
||||||
workspaceIcons.push(appIcon);
|
|
||||||
}
|
|
||||||
for (let i = 0; i < otherApps.length; i++) {
|
|
||||||
let appIcon = new AppIcon(otherApps[i]);
|
|
||||||
appIcon.cachedWindows = appIcon.app.get_windows();
|
|
||||||
otherIcons.push(appIcon);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.icons = [];
|
this.icons = [];
|
||||||
this._arrows = [];
|
this._arrows = [];
|
||||||
for (let i = 0; i < workspaceIcons.length; i++)
|
|
||||||
this._addIcon(workspaceIcons[i]);
|
let windowTracker = Shell.WindowTracker.get_default();
|
||||||
if (workspaceIcons.length > 0 && otherIcons.length > 0)
|
let allWindows = global.display.get_tab_list(Meta.TabList.NORMAL,
|
||||||
this.addSeparator();
|
global.screen, null);
|
||||||
for (let i = 0; i < otherIcons.length; i++)
|
|
||||||
this._addIcon(otherIcons[i]);
|
// Construct the AppIcons, add to the popup
|
||||||
|
for (let i = 0; i < apps.length; i++) {
|
||||||
|
let appIcon = new AppIcon(apps[i]);
|
||||||
|
// Cache the window list now; we don't handle dynamic changes here,
|
||||||
|
// and we don't want to be continually retrieving it
|
||||||
|
appIcon.cachedWindows = allWindows.filter(function(w) {
|
||||||
|
return windowTracker.get_window_app (w) == appIcon.app;
|
||||||
|
});
|
||||||
|
this._addIcon(appIcon);
|
||||||
|
}
|
||||||
|
|
||||||
this._curApp = -1;
|
this._curApp = -1;
|
||||||
this._iconSize = 0;
|
this._iconSize = 0;
|
||||||
@ -514,8 +472,6 @@ const AppSwitcher = new Lang.Class({
|
|||||||
let [iconMinHeight, iconNaturalHeight] = this.icons[j].label.get_preferred_height(-1);
|
let [iconMinHeight, iconNaturalHeight] = this.icons[j].label.get_preferred_height(-1);
|
||||||
let iconSpacing = iconNaturalHeight + iconPadding + iconBorder;
|
let iconSpacing = iconNaturalHeight + iconPadding + iconBorder;
|
||||||
let totalSpacing = this._list.spacing * (this._items.length - 1);
|
let totalSpacing = this._list.spacing * (this._items.length - 1);
|
||||||
if (this._separator)
|
|
||||||
totalSpacing += this._separator.width + this._list.spacing;
|
|
||||||
|
|
||||||
// We just assume the whole screen here due to weirdness happing with the passed width
|
// We just assume the whole screen here due to weirdness happing with the passed width
|
||||||
let primary = Main.layoutManager.primaryMonitor;
|
let primary = Main.layoutManager.primaryMonitor;
|
||||||
@ -638,24 +594,12 @@ const ThumbnailList = new Lang.Class({
|
|||||||
_init : function(windows) {
|
_init : function(windows) {
|
||||||
this.parent(false);
|
this.parent(false);
|
||||||
|
|
||||||
let activeWorkspace = global.screen.get_active_workspace();
|
|
||||||
|
|
||||||
// We fake the value of 'separatorAdded' when the app has no window
|
|
||||||
// on the current workspace, to avoid displaying a useless separator in
|
|
||||||
// that case.
|
|
||||||
let separatorAdded = windows.length == 0 || windows[0].get_workspace() != activeWorkspace;
|
|
||||||
|
|
||||||
this._labels = new Array();
|
this._labels = new Array();
|
||||||
this._thumbnailBins = new Array();
|
this._thumbnailBins = new Array();
|
||||||
this._clones = new Array();
|
this._clones = new Array();
|
||||||
this._windows = windows;
|
this._windows = windows;
|
||||||
|
|
||||||
for (let i = 0; i < windows.length; i++) {
|
for (let i = 0; i < windows.length; i++) {
|
||||||
if (!separatorAdded && windows[i].get_workspace() != activeWorkspace) {
|
|
||||||
this.addSeparator();
|
|
||||||
separatorAdded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let box = new St.BoxLayout({ style_class: 'thumbnail-box',
|
let box = new St.BoxLayout({ style_class: 'thumbnail-box',
|
||||||
vertical: true });
|
vertical: true });
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user