Set the workspace when launching apps

main.js: Add create_app_launch_context() with code from appDisplay;
  additionally set the workspace on the launch context to the current
  workspace so that the application launches on the right workspace
  even if the user switches before the app starts.

appDisplay.js docDisplay.js: Use Main.create_app_launch_context()

http://bugzilla.gnome.org/show_bug.cgi?id=580658 (Reported by Igor Vatavuk)
This commit is contained in:
Owen W. Taylor 2009-05-01 14:13:51 -04:00
parent 4a5873dd22
commit bb69afc830
3 changed files with 25 additions and 11 deletions

View File

@ -5,13 +5,13 @@ const Clutter = imports.gi.Clutter;
const Pango = imports.gi.Pango;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Shell = imports.gi.Shell;
const Lang = imports.lang;
const Signals = imports.signals;
const GenericDisplay = imports.ui.genericDisplay;
const GtkUtil = imports.ui.gtkutil;
const Main = imports.ui.main;
const ENTERED_MENU_COLOR = new Clutter.Color();
ENTERED_MENU_COLOR.from_pixel(0x00ff0022);
@ -85,15 +85,7 @@ AppDisplayItem.prototype = {
// Opens an application represented by this display item.
launch : function() {
let global = Shell.Global.get();
let screen = global.screen;
let display = screen.get_display();
let timestamp = display.get_current_time();
let context = new Gdk.AppLaunchContext();
let icon = this._appInfo.get_icon();
context.set_icon(icon);
context.set_timestamp(timestamp);
this._appInfo.launch([], context);
this._appInfo.launch([], Main.create_app_launch_context());
},
//// Protected method overrides ////

View File

@ -8,6 +8,7 @@ const Shell = imports.gi.Shell;
const Signals = imports.signals;
const GenericDisplay = imports.ui.genericDisplay;
const Main = imports.ui.main;
const ITEM_DISPLAY_ICON_MARGIN = 2;
@ -78,7 +79,12 @@ DocDisplayItem.prototype = {
appExec = appExec.replace(/%/g, "%%");
let appInfo = Gio.app_info_create_from_commandline(appExec, null, 0, null);
appInfo.launch([], null, null);
// The app launch context doesn't work as well as we might like because
// it doesn't get the right StartupNotify key from the application's
// desktop file. So, we don't get startup notification, the application
// doesn't stick to the current workspace, and so forth.
appInfo.launch([], Main.create_app_launch_context());
} else {
log("Failed to get application info for " + this._docInfo.get_uri());
}

View File

@ -1,6 +1,7 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
@ -166,6 +167,21 @@ function hide_overlay() {
endModal();
}
function create_app_launch_context() {
let global = Shell.Global.get();
let screen = global.screen;
let display = screen.get_display();
let context = new Gdk.AppLaunchContext();
context.set_timestamp(display.get_current_time());
// Make sure that the app is opened on the current workspace even if
// the user switches before it seetarts
context.set_desktop(screen.get_active_workspace_index());
return context;
}
let _shellActors = [];
// For adding an actor that is part of the shell in the normal desktop view