Skip to content

Commit

Permalink
Select first app when there are none running
Browse files Browse the repository at this point in the history
  • Loading branch information
dsboger committed Jan 30, 2017
1 parent a912e61 commit 1710197
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const AppFavorites = imports.ui.appFavorites;

let AppSwitcher_init_orig;
let AppSwitcherPopup_init_orig;
let AppSwitcherPopup_initialSelection_orig;
let AppSwitcherPopup_select_orig;
let AppSwitcherPopup_finish_orig;

Expand Down Expand Up @@ -53,6 +54,16 @@ const AppSwitcherPopup_init_mod = function() {
}
}

const AppSwitcherPopup_initialSelection_mod = function(backward, binding) {
// favorites are always added after running apps, so if first icon has no windows,
// there are no running apps
if (this._items[0].cachedWindows.length == 0) {
this._select(0);
} else {
AppSwitcherPopup_initialSelection_orig.apply(this, [backward, binding]);
}
}

const AppSwitcherPopup_select_mod = function(app, window, forceAppFocus) {
let appIcon = this._items[app];
if (appIcon.cachedWindows.length == 0) {
Expand Down Expand Up @@ -85,6 +96,9 @@ function enable() {
AppSwitcherPopup_init_orig = AltTab.AppSwitcherPopup.prototype._init;
AltTab.AppSwitcherPopup.prototype._init = AppSwitcherPopup_init_mod;

AppSwitcherPopup_initialSelection_orig = AltTab.AppSwitcherPopup.prototype._initialSelection;
AltTab.AppSwitcherPopup.prototype._initialSelection = AppSwitcherPopup_initialSelection_mod;

AppSwitcherPopup_select_orig = AltTab.AppSwitcherPopup.prototype._select;
AltTab.AppSwitcherPopup.prototype._select = AppSwitcherPopup_select_mod;

Expand All @@ -99,6 +113,9 @@ function disable() {
AltTab.AppSwitcherPopup.prototype._init = AppSwitcherPopup_init_orig;
AppSwitcherPopup_init_orig = null;

AltTab.AppSwitcherPopup.prototype._initialSelection = AppSwitcherPopup_initialSelection_orig;
AppSwitcherPopup_initialSelection_orig = null;

AltTab.AppSwitcherPopup.prototype._select = AppSwitcherPopup_select_orig;
AppSwitcherPopup_select_orig = null;

Expand Down

0 comments on commit 1710197

Please sign in to comment.