diff --git a/js/ui/panel.js b/js/ui/panel.js index 9f317deb1..26c3a0330 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -186,8 +186,9 @@ AppMenuButton.prototype = { _init: function() { PanelMenu.Button.prototype._init.call(this, St.Align.START); this._metaDisplay = global.screen.get_display(); + this._startingApps = []; - this._focusedApp = null; + this._targetApp = null; let bin = new St.Bin({ name: 'appMenu' }); this.actor.set_child(bin); @@ -234,6 +235,8 @@ AppMenuButton.prototype = { tracker.connect('notify::focus-app', Lang.bind(this, this._sync)); tracker.connect('app-state-changed', Lang.bind(this, this._onAppStateChanged)); + global.window_manager.connect('switch-workspace', Lang.bind(this, this._sync)); + this._sync(); }, @@ -411,11 +414,12 @@ AppMenuButton.prototype = { _onAppStateChanged: function(tracker, app) { let state = app.state; - if (app == this._lastStartedApp - && state != Shell.AppState.STARTING) { - this._lastStartedApp = null; + if (state != Shell.AppState.STARTING) { + this._startingApps = this._startingApps.filter(function(a) { + return a != app; + }); } else if (state == Shell.AppState.STARTING) { - this._lastStartedApp = app; + this._startingApps.push(app); } // For now just resync on all running state changes; this is mainly to handle // cases where the focused window's application changes without the focus @@ -426,15 +430,20 @@ AppMenuButton.prototype = { _sync: function() { let tracker = Shell.WindowTracker.get_default(); + let lastStartedApp = null; + let workspace = global.screen.get_active_workspace(); + for (let i = 0; i < this._startingApps.length; i++) + if (this._startingApps[i].is_on_workspace(workspace)) + lastStartedApp = this._startingApps[i]; let focusedApp = tracker.focus_app; - if (focusedApp == this._focusedApp) { - if (focusedApp && focusedApp.get_state() != Shell.AppState.STARTING) + let targetApp = focusedApp != null ? focusedApp : lastStartedApp; + if (targetApp == this._targetApp) { + if (targetApp && targetApp.get_state() != Shell.AppState.STARTING) this.stopAnimation(); return; - } else { - this._stopAnimation(); } + this._stopAnimation(); if (!focusedApp) { // If the app has just lost focus to the panel, pretend @@ -450,9 +459,7 @@ AppMenuButton.prototype = { this._label.setText(''); this.actor.reactive = false; - this._focusedApp = focusedApp; - - let targetApp = this._focusedApp != null ? this._focusedApp : this._lastStartedApp; + this._targetApp = targetApp; if (targetApp != null) { let icon = targetApp.get_faded_icon(2 * PANEL_ICON_SIZE); diff --git a/src/shell-app.c b/src/shell-app.c index ad32636f5..fae61c4d4 100644 --- a/src/shell-app.c +++ b/src/shell-app.c @@ -43,6 +43,8 @@ struct _ShellApp { GObject parent; + int started_on_workspace; + ShellAppState state; ShellAppInfo *info; @@ -573,6 +575,14 @@ shell_app_is_on_workspace (ShellApp *app, { GSList *iter; + if (shell_app_get_state (app) == SHELL_APP_STATE_STARTING) + { + if (meta_workspace_index (workspace) == app->started_on_workspace) + return TRUE; + else + return FALSE; + } + if (app->running_state == NULL) return FALSE; @@ -815,6 +825,7 @@ _shell_app_handle_startup_sequence (ShellApp *app, shell_app_state_transition (app, SHELL_APP_STATE_STARTING); meta_display_focus_the_no_focus_window (display, screen, sn_startup_sequence_get_timestamp (sequence)); + app->started_on_workspace = sn_startup_sequence_get_workspace (sequence); } if (!starting)