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:
parent
c5de239e25
commit
4886275df4
@ -334,10 +334,9 @@ AppSearchProvider.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(id, params) {
|
activateResult: function(id, params) {
|
||||||
params = Params.parse(params, { workspace: null,
|
params = Params.parse(params, { workspace: -1,
|
||||||
timestamp: null });
|
timestamp: 0 });
|
||||||
|
|
||||||
let workspace = params.workspace ? params.workspace.index() : -1;
|
|
||||||
let event = Clutter.get_current_event();
|
let event = Clutter.get_current_event();
|
||||||
let modifiers = event ? Shell.get_event_state(event) : 0;
|
let modifiers = event ? Shell.get_event_state(event) : 0;
|
||||||
let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK;
|
let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK;
|
||||||
@ -346,15 +345,15 @@ AppSearchProvider.prototype = {
|
|||||||
if (openNewWindow)
|
if (openNewWindow)
|
||||||
app.open_new_window(workspace);
|
app.open_new_window(workspace);
|
||||||
else
|
else
|
||||||
app.activate(workspace);
|
app.activate_full(params.workspace, params.timestamp);
|
||||||
},
|
},
|
||||||
|
|
||||||
dragActivateResult: function(id, params) {
|
dragActivateResult: function(id, params) {
|
||||||
params = Params.parse(params, { workspace: null,
|
params = Params.parse(params, { workspace: -1,
|
||||||
timestamp: null });
|
timestamp: 0 });
|
||||||
|
|
||||||
let app = this._appSys.lookup_app(id);
|
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) {
|
createResultActor: function (resultMeta, terms) {
|
||||||
@ -395,10 +394,10 @@ SettingsSearchProvider.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(pref, params) {
|
activateResult: function(pref, params) {
|
||||||
params = Params.parse(params, { workspace: null,
|
params = Params.parse(params, { workspace: -1,
|
||||||
timestamp: null });
|
timestamp: 0 });
|
||||||
|
|
||||||
pref.activate(params.workspace);
|
pref.activate_full(params.workspace, params.timestamp);
|
||||||
},
|
},
|
||||||
|
|
||||||
dragActivateResult: function(pref, params) {
|
dragActivateResult: function(pref, params) {
|
||||||
@ -596,17 +595,17 @@ AppWellIcon.prototype = {
|
|||||||
&& this.app.state == Shell.AppState.RUNNING) {
|
&& this.app.state == Shell.AppState.RUNNING) {
|
||||||
this.app.open_new_window(-1);
|
this.app.open_new_window(-1);
|
||||||
} else {
|
} else {
|
||||||
this.app.activate(-1);
|
this.app.activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
shellWorkspaceLaunch : function(params) {
|
shellWorkspaceLaunch : function(params) {
|
||||||
params = Params.parse(params, { workspace: null,
|
params = Params.parse(params, { workspace: -1,
|
||||||
timestamp: null });
|
timestamp: 0 });
|
||||||
|
|
||||||
this.app.open_new_window(params.workspace ? params.workspace.index() : -1);
|
this.app.open_new_window(params.workspace);
|
||||||
},
|
},
|
||||||
|
|
||||||
getDragActor: function() {
|
getDragActor: function() {
|
||||||
|
@ -200,7 +200,7 @@ DateMenuButton.prototype = {
|
|||||||
this.menu.close();
|
this.menu.close();
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
let app = Shell.AppSystem.get_default().lookup_setting('gnome-datetime-panel.desktop');
|
let app = Shell.AppSystem.get_default().lookup_setting('gnome-datetime-panel.desktop');
|
||||||
app.activate(-1);
|
app.activate();
|
||||||
},
|
},
|
||||||
|
|
||||||
_onOpenCalendarActivate: function() {
|
_onOpenCalendarActivate: function() {
|
||||||
|
@ -30,11 +30,11 @@ DocSearchProvider.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(id, params) {
|
activateResult: function(id, params) {
|
||||||
params = Params.parse(params, { workspace: null,
|
params = Params.parse(params, { workspace: -1,
|
||||||
timestamp: null });
|
timestamp: 0 });
|
||||||
|
|
||||||
let docInfo = this._docManager.lookupByUri(id);
|
let docInfo = this._docManager.lookupByUri(id);
|
||||||
docInfo.launch(params.workspace ? params.workspace.index() : -1);
|
docInfo.launch(params.workspace);
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialResultSet: function(terms) {
|
getInitialResultSet: function(terms) {
|
||||||
|
@ -173,7 +173,7 @@ ListItem.prototype = {
|
|||||||
|
|
||||||
_onClicked: function() {
|
_onClicked: function() {
|
||||||
this.emit('activate');
|
this.emit('activate');
|
||||||
this._app.activate(-1);
|
this._app.activate();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(ListItem.prototype);
|
Signals.addSignalMethods(ListItem.prototype);
|
||||||
|
@ -60,13 +60,13 @@ PlaceInfo.prototype = {
|
|||||||
// Helper function to translate launch parameters into a GAppLaunchContext
|
// Helper function to translate launch parameters into a GAppLaunchContext
|
||||||
function _makeLaunchContext(params)
|
function _makeLaunchContext(params)
|
||||||
{
|
{
|
||||||
params = Params.parse(params, { workspace: null,
|
params = Params.parse(params, { workspace: -1,
|
||||||
timestamp: null });
|
timestamp: 0 });
|
||||||
|
|
||||||
let launchContext = global.create_app_launch_context();
|
let launchContext = global.create_app_launch_context();
|
||||||
if (params.workspace != null)
|
if (params.workspace != -1)
|
||||||
launchContext.set_desktop(params.workspace.index());
|
launchContext.set_desktop(params.workspace);
|
||||||
if (params.timestamp != null)
|
if (params.timestamp != 0)
|
||||||
launchContext.set_timestamp(params.timestamp);
|
launchContext.set_timestamp(params.timestamp);
|
||||||
|
|
||||||
return launchContext;
|
return launchContext;
|
||||||
|
@ -84,7 +84,7 @@ ListItem.prototype = {
|
|||||||
|
|
||||||
_onClicked: function() {
|
_onClicked: function() {
|
||||||
this.emit('activate');
|
this.emit('activate');
|
||||||
this._app.activate(-1);
|
this._app.activate();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(ListItem.prototype);
|
Signals.addSignalMethods(ListItem.prototype);
|
||||||
@ -402,4 +402,4 @@ ShellProcessesDialog.prototype = {
|
|||||||
_setButtonsForChoices(this, choices);
|
_setButtonsForChoices(this, choices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Signals.addSignalMethods(ShellProcessesDialog.prototype);
|
Signals.addSignalMethods(ShellProcessesDialog.prototype);
|
||||||
|
@ -91,7 +91,7 @@ ATIndicator.prototype = {
|
|||||||
this.menu.addAction(_("Universal Access Settings"), function() {
|
this.menu.addAction(_("Universal Access Settings"), function() {
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
let app = Shell.AppSystem.get_default().lookup_setting('gnome-universal-access-panel.desktop');
|
let app = Shell.AppSystem.get_default().lookup_setting('gnome-universal-access-panel.desktop');
|
||||||
app.activate(-1);
|
app.activate();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ Indicator.prototype = {
|
|||||||
this.menu.addAction(_("Bluetooth Settings"), function() {
|
this.menu.addAction(_("Bluetooth Settings"), function() {
|
||||||
Main.overview.hide()
|
Main.overview.hide()
|
||||||
let app = Shell.AppSystem.get_default().lookup_setting('bluetooth-properties.desktop');
|
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));
|
this._applet.connect('pincode-request', Lang.bind(this, this._pinRequest));
|
||||||
|
@ -75,7 +75,7 @@ XKBIndicator.prototype = {
|
|||||||
this.menu.addAction(_("Region and Language Settings"), function() {
|
this.menu.addAction(_("Region and Language Settings"), function() {
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
let app = Shell.AppSystem.get_default().lookup_setting('gnome-region-panel.desktop');
|
let app = Shell.AppSystem.get_default().lookup_setting('gnome-region-panel.desktop');
|
||||||
app.activate(-1);
|
app.activate();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1605,7 +1605,7 @@ NMApplet.prototype = {
|
|||||||
this.menu.addAction(_("Network Settings"), function() {
|
this.menu.addAction(_("Network Settings"), function() {
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
let app = Shell.AppSystem.get_default().lookup_setting('gnome-network-panel.desktop');
|
let app = Shell.AppSystem.get_default().lookup_setting('gnome-network-panel.desktop');
|
||||||
app.activate(-1);
|
app.activate();
|
||||||
});
|
});
|
||||||
|
|
||||||
this._activeConnections = [ ];
|
this._activeConnections = [ ];
|
||||||
|
@ -83,7 +83,7 @@ Indicator.prototype = {
|
|||||||
this.menu.addAction(_("Power Settings"),function() {
|
this.menu.addAction(_("Power Settings"),function() {
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
let app = Shell.AppSystem.get_default().lookup_setting('gnome-power-panel.desktop');
|
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));
|
this._proxy.connect('Changed', Lang.bind(this, this._devicesChanged));
|
||||||
|
@ -64,7 +64,7 @@ Indicator.prototype = {
|
|||||||
this.menu.addAction(_("Sound Settings"), function() {
|
this.menu.addAction(_("Sound Settings"), function() {
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
let app = Shell.AppSystem.get_default().lookup_setting('gnome-sound-panel.desktop');
|
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));
|
this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
|
||||||
|
@ -275,13 +275,13 @@ StatusMenuButton.prototype = {
|
|||||||
_onMyAccountActivate: function() {
|
_onMyAccountActivate: function() {
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
let app = Shell.AppSystem.get_default().lookup_setting('gnome-user-accounts-panel.desktop');
|
let app = Shell.AppSystem.get_default().lookup_setting('gnome-user-accounts-panel.desktop');
|
||||||
app.activate(-1);
|
app.activate();
|
||||||
},
|
},
|
||||||
|
|
||||||
_onPreferencesActivate: function() {
|
_onPreferencesActivate: function() {
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
let app = Shell.AppSystem.get_default().lookup_app('gnome-control-center.desktop');
|
let app = Shell.AppSystem.get_default().lookup_app('gnome-control-center.desktop');
|
||||||
app.activate(-1);
|
app.activate();
|
||||||
},
|
},
|
||||||
|
|
||||||
_onLockScreenActivate: function() {
|
_onLockScreenActivate: function() {
|
||||||
|
@ -1440,7 +1440,7 @@ Workspace.prototype = {
|
|||||||
time);
|
time);
|
||||||
return true;
|
return true;
|
||||||
} else if (source.shellWorkspaceLaunch) {
|
} else if (source.shellWorkspaceLaunch) {
|
||||||
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace,
|
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace ? this.metaWorkspace.index() : -1,
|
||||||
timestamp: time });
|
timestamp: time });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ WorkspaceThumbnail.prototype = {
|
|||||||
time);
|
time);
|
||||||
return true;
|
return true;
|
||||||
} else if (source.shellWorkspaceLaunch) {
|
} else if (source.shellWorkspaceLaunch) {
|
||||||
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace,
|
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace ? this.metaWorkspace.index() : -1,
|
||||||
timestamp: time });
|
timestamp: time });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -508,8 +508,22 @@ shell_app_activate_window (ShellApp *app,
|
|||||||
/**
|
/**
|
||||||
* shell_app_activate:
|
* shell_app_activate:
|
||||||
* @app: a #ShellApp
|
* @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
|
* @workspace: launch on this workspace, or -1 for default. Ignored if
|
||||||
* activating an existing window
|
* activating an existing window
|
||||||
|
* @timestamp: Event timestamp
|
||||||
*
|
*
|
||||||
* Perform an appropriate default action for operating on this application,
|
* Perform an appropriate default action for operating on this application,
|
||||||
* dependent on its current state. For example, if the application is not
|
* 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).
|
* recently used transient for that window).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
shell_app_activate (ShellApp *app,
|
shell_app_activate_full (ShellApp *app,
|
||||||
int workspace)
|
int workspace,
|
||||||
|
guint32 timestamp)
|
||||||
{
|
{
|
||||||
switch (app->state)
|
switch (app->state)
|
||||||
{
|
{
|
||||||
@ -527,7 +542,7 @@ shell_app_activate (ShellApp *app,
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
if (!shell_app_launch (app,
|
if (!shell_app_launch (app,
|
||||||
0,
|
timestamp,
|
||||||
NULL,
|
NULL,
|
||||||
workspace,
|
workspace,
|
||||||
NULL,
|
NULL,
|
||||||
@ -546,7 +561,7 @@ shell_app_activate (ShellApp *app,
|
|||||||
case SHELL_APP_STATE_STARTING:
|
case SHELL_APP_STATE_STARTING:
|
||||||
break;
|
break;
|
||||||
case SHELL_APP_STATE_RUNNING:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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_window (ShellApp *app, MetaWindow *window, guint32 timestamp);
|
||||||
|
|
||||||
void shell_app_activate (ShellApp *app,
|
void shell_app_activate (ShellApp *app);
|
||||||
int workspace);
|
|
||||||
|
void shell_app_activate_full (ShellApp *app,
|
||||||
|
int workspace,
|
||||||
|
guint32 timestamp);
|
||||||
|
|
||||||
void shell_app_open_new_window (ShellApp *app,
|
void shell_app_open_new_window (ShellApp *app,
|
||||||
int workspace);
|
int workspace);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user