Make session saving work a bit better

Previously, the restart command hardcoded "mutter" as the binary name.
This commit changes it to use g_get_prgname() which has a better chance
of being correct (and it does fix session saving for gnome-shell).

Now that mutter is a library, it might be more correct (but also
much higher overhead) to add api for setting these things from
the outside.

https://bugzilla.gnome.org/show_bug.cgi?id=648828
This commit is contained in:
Matthias Clasen 2011-04-29 07:23:30 -04:00 committed by Owen W. Taylor
parent 31e6cdf345
commit bbfcde1caa

View File

@ -308,13 +308,16 @@ meta_session_init (const char *previous_client_id,
*/ */
char hint = SmRestartIfRunning; char hint = SmRestartIfRunning;
char priority = 20; /* low to run before other apps */ char priority = 20; /* low to run before other apps */
const char *prgname;
prgname = g_get_prgname ();
prop1.name = SmProgram; prop1.name = SmProgram;
prop1.type = SmARRAY8; prop1.type = SmARRAY8;
prop1.num_vals = 1; prop1.num_vals = 1;
prop1.vals = &prop1val; prop1.vals = &prop1val;
prop1val.value = "mutter"; prop1val.value = (char *)prgname;
prop1val.length = strlen ("mutter"); prop1val.length = strlen (prgname);
/* twm sets getuid() for this, but the SM spec plainly /* twm sets getuid() for this, but the SM spec plainly
* says pw_name, twm is on crack * says pw_name, twm is on crack
@ -573,6 +576,9 @@ set_clone_restart_commands (void)
char *discardv[10]; char *discardv[10];
int i; int i;
SmProp prop1, prop2, prop3, *props[3]; SmProp prop1, prop2, prop3, *props[3];
const char *prgname;
prgname = g_get_prgname ();
/* Restart (use same client ID) */ /* Restart (use same client ID) */
@ -582,7 +588,7 @@ set_clone_restart_commands (void)
g_return_if_fail (client_id); g_return_if_fail (client_id);
i = 0; i = 0;
restartv[i] = "mutter"; restartv[i] = (char *)prgname;
++i; ++i;
restartv[i] = "--sm-client-id"; restartv[i] = "--sm-client-id";
++i; ++i;
@ -603,7 +609,7 @@ set_clone_restart_commands (void)
/* Clone (no client ID) */ /* Clone (no client ID) */
i = 0; i = 0;
clonev[i] = "mutter"; clonev[i] = (char *)prgname;
++i; ++i;
clonev[i] = NULL; clonev[i] = NULL;