[gnome-shell] ShellApp: Change activation API
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] ShellApp: Change activation API
- Date: Thu, 11 Aug 2011 14:11:16 +0000 (UTC)
commit 4886275df43295552d7a1082bedc383def89ae48
Author: Colin Walters <walters verbum org>
Date: Thu Aug 11 05:35:23 2011 -0400
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
js/ui/appDisplay.js | 27 +++++++++++++--------------
js/ui/dateMenu.js | 2 +-
js/ui/docDisplay.js | 6 +++---
js/ui/endSessionDialog.js | 2 +-
js/ui/placeDisplay.js | 10 +++++-----
js/ui/shellMountOperation.js | 4 ++--
js/ui/status/accessibility.js | 2 +-
js/ui/status/bluetooth.js | 2 +-
js/ui/status/keyboard.js | 2 +-
js/ui/status/network.js | 2 +-
js/ui/status/power.js | 2 +-
js/ui/status/volume.js | 2 +-
js/ui/statusMenu.js | 4 ++--
js/ui/workspace.js | 2 +-
js/ui/workspaceThumbnail.js | 2 +-
src/shell-app.c | 23 +++++++++++++++++++----
src/shell-app.h | 7 +++++--
17 files changed, 59 insertions(+), 42 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 975667c..a69b677 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -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() {
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 99ad76d..a8824dc 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -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() {
diff --git a/js/ui/docDisplay.js b/js/ui/docDisplay.js
index 6a289b0..10646fb 100644
--- a/js/ui/docDisplay.js
+++ b/js/ui/docDisplay.js
@@ -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) {
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index cad887d..70f996a 100644
--- a/js/ui/endSessionDialog.js
+++ b/js/ui/endSessionDialog.js
@@ -173,7 +173,7 @@ ListItem.prototype = {
_onClicked: function() {
this.emit('activate');
- this._app.activate(-1);
+ this._app.activate();
}
};
Signals.addSignalMethods(ListItem.prototype);
diff --git a/js/ui/placeDisplay.js b/js/ui/placeDisplay.js
index 9354247..edfef06 100644
--- a/js/ui/placeDisplay.js
+++ b/js/ui/placeDisplay.js
@@ -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;
diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js
index d85e77f..9ccaaea 100644
--- a/js/ui/shellMountOperation.js
+++ b/js/ui/shellMountOperation.js
@@ -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);
\ No newline at end of file
+Signals.addSignalMethods(ShellProcessesDialog.prototype);
diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js
index 542c230..7792ed4 100644
--- a/js/ui/status/accessibility.js
+++ b/js/ui/status/accessibility.js
@@ -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();
});
},
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index a73eb7e..d506996 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -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));
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index 0ae9929..1db0d82 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -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();
});
},
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 38b2e25..4b4aaac 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -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 = [ ];
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index 1f5b5bb..482711b 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -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));
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index adc1207..0c02a9e 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -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));
diff --git a/js/ui/statusMenu.js b/js/ui/statusMenu.js
index f2d825c..21bc2b1 100644
--- a/js/ui/statusMenu.js
+++ b/js/ui/statusMenu.js
@@ -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() {
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index acb8904..e7ff208 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -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;
}
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index 5123042..582842b 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -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;
}
diff --git a/src/shell-app.c b/src/shell-app.c
index c338055..1654401 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -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;
}
}
diff --git a/src/shell-app.h b/src/shell-app.h
index d1aed02..8f4f0e6 100644
--- a/src/shell-app.h
+++ b/src/shell-app.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]