ShellApp: Change activation API

Since almost all of the callers of shell_app_activate were using the
default workspace (by passing -1), remove that parameter.

Add a new shell_app_activate_full() API which takes a workspace as
well as a timestamp; previously we might have been ignoring event
timestamps from elsewhere.

https://bugzilla.gnome.org/show_bug.cgi?id=648149
This commit is contained in:
Colin Walters 2011-08-11 05:35:23 -04:00
parent c5de239e25
commit 4886275df4
17 changed files with 59 additions and 42 deletions

View File

@ -334,10 +334,9 @@ AppSearchProvider.prototype = {
},
activateResult: function(id, params) {
params = Params.parse(params, { workspace: null,
timestamp: null });
params = Params.parse(params, { workspace: -1,
timestamp: 0 });
let workspace = params.workspace ? params.workspace.index() : -1;
let event = Clutter.get_current_event();
let modifiers = event ? Shell.get_event_state(event) : 0;
let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK;
@ -346,15 +345,15 @@ AppSearchProvider.prototype = {
if (openNewWindow)
app.open_new_window(workspace);
else
app.activate(workspace);
app.activate_full(params.workspace, params.timestamp);
},
dragActivateResult: function(id, params) {
params = Params.parse(params, { workspace: null,
timestamp: null });
params = Params.parse(params, { workspace: -1,
timestamp: 0 });
let app = this._appSys.lookup_app(id);
app.open_new_window(params.workspace ? params.workspace.index() : -1);
app.open_new_window(workspace);
},
createResultActor: function (resultMeta, terms) {
@ -395,10 +394,10 @@ SettingsSearchProvider.prototype = {
},
activateResult: function(pref, params) {
params = Params.parse(params, { workspace: null,
timestamp: null });
params = Params.parse(params, { workspace: -1,
timestamp: 0 });
pref.activate(params.workspace);
pref.activate_full(params.workspace, params.timestamp);
},
dragActivateResult: function(pref, params) {
@ -596,17 +595,17 @@ AppWellIcon.prototype = {
&& this.app.state == Shell.AppState.RUNNING) {
this.app.open_new_window(-1);
} else {
this.app.activate(-1);
this.app.activate();
}
}
Main.overview.hide();
},
shellWorkspaceLaunch : function(params) {
params = Params.parse(params, { workspace: null,
timestamp: null });
params = Params.parse(params, { workspace: -1,
timestamp: 0 });
this.app.open_new_window(params.workspace ? params.workspace.index() : -1);
this.app.open_new_window(params.workspace);
},
getDragActor: function() {

View File

@ -200,7 +200,7 @@ DateMenuButton.prototype = {
this.menu.close();
Main.overview.hide();
let app = Shell.AppSystem.get_default().lookup_setting('gnome-datetime-panel.desktop');
app.activate(-1);
app.activate();
},
_onOpenCalendarActivate: function() {

View File

@ -30,11 +30,11 @@ DocSearchProvider.prototype = {
},
activateResult: function(id, params) {
params = Params.parse(params, { workspace: null,
timestamp: null });
params = Params.parse(params, { workspace: -1,
timestamp: 0 });
let docInfo = this._docManager.lookupByUri(id);
docInfo.launch(params.workspace ? params.workspace.index() : -1);
docInfo.launch(params.workspace);
},
getInitialResultSet: function(terms) {

View File

@ -173,7 +173,7 @@ ListItem.prototype = {
_onClicked: function() {
this.emit('activate');
this._app.activate(-1);
this._app.activate();
}
};
Signals.addSignalMethods(ListItem.prototype);

View File

@ -60,13 +60,13 @@ PlaceInfo.prototype = {
// Helper function to translate launch parameters into a GAppLaunchContext
function _makeLaunchContext(params)
{
params = Params.parse(params, { workspace: null,
timestamp: null });
params = Params.parse(params, { workspace: -1,
timestamp: 0 });
let launchContext = global.create_app_launch_context();
if (params.workspace != null)
launchContext.set_desktop(params.workspace.index());
if (params.timestamp != null)
if (params.workspace != -1)
launchContext.set_desktop(params.workspace);
if (params.timestamp != 0)
launchContext.set_timestamp(params.timestamp);
return launchContext;

View File

@ -84,7 +84,7 @@ ListItem.prototype = {
_onClicked: function() {
this.emit('activate');
this._app.activate(-1);
this._app.activate();
}
};
Signals.addSignalMethods(ListItem.prototype);
@ -402,4 +402,4 @@ ShellProcessesDialog.prototype = {
_setButtonsForChoices(this, choices);
}
}
Signals.addSignalMethods(ShellProcessesDialog.prototype);
Signals.addSignalMethods(ShellProcessesDialog.prototype);

View File

@ -91,7 +91,7 @@ ATIndicator.prototype = {
this.menu.addAction(_("Universal Access Settings"), function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().lookup_setting('gnome-universal-access-panel.desktop');
app.activate(-1);
app.activate();
});
},

View File

@ -92,7 +92,7 @@ Indicator.prototype = {
this.menu.addAction(_("Bluetooth Settings"), function() {
Main.overview.hide()
let app = Shell.AppSystem.get_default().lookup_setting('bluetooth-properties.desktop');
app.activate(-1);
app.activate();
});
this._applet.connect('pincode-request', Lang.bind(this, this._pinRequest));

View File

@ -75,7 +75,7 @@ XKBIndicator.prototype = {
this.menu.addAction(_("Region and Language Settings"), function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().lookup_setting('gnome-region-panel.desktop');
app.activate(-1);
app.activate();
});
},

View File

@ -1605,7 +1605,7 @@ NMApplet.prototype = {
this.menu.addAction(_("Network Settings"), function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().lookup_setting('gnome-network-panel.desktop');
app.activate(-1);
app.activate();
});
this._activeConnections = [ ];

View File

@ -83,7 +83,7 @@ Indicator.prototype = {
this.menu.addAction(_("Power Settings"),function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().lookup_setting('gnome-power-panel.desktop');
app.activate(-1);
app.activate();
});
this._proxy.connect('Changed', Lang.bind(this, this._devicesChanged));

View File

@ -64,7 +64,7 @@ Indicator.prototype = {
this.menu.addAction(_("Sound Settings"), function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().lookup_setting('gnome-sound-panel.desktop');
app.activate(-1);
app.activate();
});
this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));

View File

@ -275,13 +275,13 @@ StatusMenuButton.prototype = {
_onMyAccountActivate: function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().lookup_setting('gnome-user-accounts-panel.desktop');
app.activate(-1);
app.activate();
},
_onPreferencesActivate: function() {
Main.overview.hide();
let app = Shell.AppSystem.get_default().lookup_app('gnome-control-center.desktop');
app.activate(-1);
app.activate();
},
_onLockScreenActivate: function() {

View File

@ -1440,7 +1440,7 @@ Workspace.prototype = {
time);
return true;
} else if (source.shellWorkspaceLaunch) {
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace,
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace ? this.metaWorkspace.index() : -1,
timestamp: time });
return true;
}

View File

@ -452,7 +452,7 @@ WorkspaceThumbnail.prototype = {
time);
return true;
} else if (source.shellWorkspaceLaunch) {
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace,
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace ? this.metaWorkspace.index() : -1,
timestamp: time });
return true;
}

View File

@ -508,8 +508,22 @@ shell_app_activate_window (ShellApp *app,
/**
* shell_app_activate:
* @app: a #ShellApp
*
* Like shell_app_activate_full(), but using the default workspace and
* event timestamp.
*/
void
shell_app_activate (ShellApp *app)
{
return shell_app_activate_full (app, -1, 0);
}
/**
* shell_app_activate_full:
* @app: a #ShellApp
* @workspace: launch on this workspace, or -1 for default. Ignored if
* activating an existing window
* @timestamp: Event timestamp
*
* Perform an appropriate default action for operating on this application,
* dependent on its current state. For example, if the application is not
@ -518,8 +532,9 @@ shell_app_activate_window (ShellApp *app,
* recently used transient for that window).
*/
void
shell_app_activate (ShellApp *app,
int workspace)
shell_app_activate_full (ShellApp *app,
int workspace,
guint32 timestamp)
{
switch (app->state)
{
@ -527,7 +542,7 @@ shell_app_activate (ShellApp *app,
{
GError *error = NULL;
if (!shell_app_launch (app,
0,
timestamp,
NULL,
workspace,
NULL,
@ -546,7 +561,7 @@ shell_app_activate (ShellApp *app,
case SHELL_APP_STATE_STARTING:
break;
case SHELL_APP_STATE_RUNNING:
shell_app_activate_window (app, NULL, shell_global_get_current_time (shell_global_get ()));
shell_app_activate_window (app, NULL, timestamp);
break;
}
}

View File

@ -47,8 +47,11 @@ gboolean shell_app_is_window_backed (ShellApp *app);
void shell_app_activate_window (ShellApp *app, MetaWindow *window, guint32 timestamp);
void shell_app_activate (ShellApp *app,
int workspace);
void shell_app_activate (ShellApp *app);
void shell_app_activate_full (ShellApp *app,
int workspace,
guint32 timestamp);
void shell_app_open_new_window (ShellApp *app,
int workspace);