[panel] Only show starting applications for current workspace

Add the workspace we started on to ShellApp.  Use it inside panel.js
to filter the list.
https://bugzilla.gnome.org/show_bug.cgi?id=623688
This commit is contained in:
Maxim Ermilov 2010-10-07 01:31:22 +04:00
parent 6925a82204
commit 4456954d30
2 changed files with 30 additions and 12 deletions

View File

@ -186,8 +186,9 @@ AppMenuButton.prototype = {
_init: function() { _init: function() {
PanelMenu.Button.prototype._init.call(this, St.Align.START); PanelMenu.Button.prototype._init.call(this, St.Align.START);
this._metaDisplay = global.screen.get_display(); this._metaDisplay = global.screen.get_display();
this._startingApps = [];
this._focusedApp = null; this._targetApp = null;
let bin = new St.Bin({ name: 'appMenu' }); let bin = new St.Bin({ name: 'appMenu' });
this.actor.set_child(bin); this.actor.set_child(bin);
@ -234,6 +235,8 @@ AppMenuButton.prototype = {
tracker.connect('notify::focus-app', Lang.bind(this, this._sync)); tracker.connect('notify::focus-app', Lang.bind(this, this._sync));
tracker.connect('app-state-changed', Lang.bind(this, this._onAppStateChanged)); tracker.connect('app-state-changed', Lang.bind(this, this._onAppStateChanged));
global.window_manager.connect('switch-workspace', Lang.bind(this, this._sync));
this._sync(); this._sync();
}, },
@ -411,11 +414,12 @@ AppMenuButton.prototype = {
_onAppStateChanged: function(tracker, app) { _onAppStateChanged: function(tracker, app) {
let state = app.state; let state = app.state;
if (app == this._lastStartedApp if (state != Shell.AppState.STARTING) {
&& state != Shell.AppState.STARTING) { this._startingApps = this._startingApps.filter(function(a) {
this._lastStartedApp = null; return a != app;
});
} else if (state == Shell.AppState.STARTING) { } 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 // 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 // cases where the focused window's application changes without the focus
@ -426,15 +430,20 @@ AppMenuButton.prototype = {
_sync: function() { _sync: function() {
let tracker = Shell.WindowTracker.get_default(); 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; let focusedApp = tracker.focus_app;
if (focusedApp == this._focusedApp) { let targetApp = focusedApp != null ? focusedApp : lastStartedApp;
if (focusedApp && focusedApp.get_state() != Shell.AppState.STARTING) if (targetApp == this._targetApp) {
if (targetApp && targetApp.get_state() != Shell.AppState.STARTING)
this.stopAnimation(); this.stopAnimation();
return; return;
} else {
this._stopAnimation();
} }
this._stopAnimation();
if (!focusedApp) { if (!focusedApp) {
// If the app has just lost focus to the panel, pretend // If the app has just lost focus to the panel, pretend
@ -450,9 +459,7 @@ AppMenuButton.prototype = {
this._label.setText(''); this._label.setText('');
this.actor.reactive = false; this.actor.reactive = false;
this._focusedApp = focusedApp; this._targetApp = targetApp;
let targetApp = this._focusedApp != null ? this._focusedApp : this._lastStartedApp;
if (targetApp != null) { if (targetApp != null) {
let icon = targetApp.get_faded_icon(2 * PANEL_ICON_SIZE); let icon = targetApp.get_faded_icon(2 * PANEL_ICON_SIZE);

View File

@ -43,6 +43,8 @@ struct _ShellApp
{ {
GObject parent; GObject parent;
int started_on_workspace;
ShellAppState state; ShellAppState state;
ShellAppInfo *info; ShellAppInfo *info;
@ -573,6 +575,14 @@ shell_app_is_on_workspace (ShellApp *app,
{ {
GSList *iter; 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) if (app->running_state == NULL)
return FALSE; return FALSE;
@ -815,6 +825,7 @@ _shell_app_handle_startup_sequence (ShellApp *app,
shell_app_state_transition (app, SHELL_APP_STATE_STARTING); shell_app_state_transition (app, SHELL_APP_STATE_STARTING);
meta_display_focus_the_no_focus_window (display, screen, meta_display_focus_the_no_focus_window (display, screen,
sn_startup_sequence_get_timestamp (sequence)); sn_startup_sequence_get_timestamp (sequence));
app->started_on_workspace = sn_startup_sequence_get_workspace (sequence);
} }
if (!starting) if (!starting)