gnome-session/gnome-session-wm-switch.patch

116 lines
3.0 KiB
Diff
Raw Normal View History

Index: gnome-session/main.c
===================================================================
--- gnome-session/main.c.orig
+++ gnome-session/main.c
@@ -37,12 +37,16 @@
#include <libgnomeui/gnome-window-icon.h>
+#include <gdk/gdkx.h>
+
#include "manager.h"
#include "ice.h"
#include "save.h"
#include "command.h"
#include "splash-widget.h"
#include "util.h"
+#include "prop.h"
+#include "session.h"
#include "gsm-dbus.h"
#include "gsm-sound.h"
#include "gsm-gsd.h"
@@ -192,6 +196,84 @@ gsm_shutdown_gconfd (void)
g_free (command);
}
+static void
+fix_wm (Session *session)
+{
+ GSList *cl, *p;
+ Client *client = NULL;
+ SmProp *prop = NULL;
+
+ for (cl = session->client_list; cl; cl = cl->next)
+ {
+ client = cl->data;
+ if (client->match_rule != MATCH_ID)
+ continue;
+
+ prop = find_property_by_name (client, SmRestartCommand);
+ if (!prop)
+ continue;
+
+ if (!strcmp (prop->vals[0].value, "gnome-wm"))
+ return;
+ else if (!strcmp (prop->vals[0].value, "metacity") ||
+ !strcmp (prop->vals[0].value, "compiz"))
+ break;
+ }
+
+ if (!cl)
+ return;
+
+ if (VendorRelease (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())) != 70000001)
+ {
+ /* Xorg */
+ if (!strcmp (prop->vals[0].value, "metacity"))
+ return;
+ }
+ else
+ {
+ /* Xgl */
+ if (!strcmp (prop->vals[0].value, "compiz"))
+ return;
+ }
+
+ /* At this point, either client is compiz and we're using Xorg, or
+ * client is metacity and we're using Xgl. Either way, replace it
+ * with gnome-wm.
+ */
+
+ for (p = client->properties; p; p = p->next)
+ SmFreeProperty (p->data);
+ g_slist_free (client->properties);
+
+ client->properties = NULL;
+
+ prop = malloc (sizeof (SmProp));
+ prop->name = strdup (SmRestartCommand);
+ prop->type = strdup (SmLISTofARRAY8);
+ prop->num_vals = 5;
+ prop->vals = malloc (5 * sizeof (SmPropValue));
+ prop->vals[0].value = strdup ("gnome-wm");
+ prop->vals[0].length = strlen (prop->vals[0].value);
+ prop->vals[1].value = strdup ("--default-wm");
+ prop->vals[1].length = strlen (prop->vals[1].value);
+ prop->vals[2].value = strdup ("gnome-wm");
+ prop->vals[2].length = strlen (prop->vals[2].value);
+ prop->vals[3].value = strdup ("--sm-client-id");
+ prop->vals[3].length = strlen (prop->vals[3].value);
+ prop->vals[4].value = strdup (client->id);
+ prop->vals[4].length = strlen (prop->vals[4].value);
+ client->properties = g_slist_prepend (client->properties, prop);
+
+ prop = malloc (sizeof (SmProp));
+ prop->name = strdup (GsmPriority);
+ prop->type = strdup (SmCARD8);
+ prop->num_vals = 1;
+ prop->vals = malloc (sizeof (SmPropValue));
+ prop->vals[0].value = calloc (2, 1);
+ prop->vals[0].length = 1;
+ client->properties = g_slist_prepend (client->properties, prop);
+}
+
int
main (int argc, char *argv[])
{
@@ -363,6 +445,8 @@ main (int argc, char *argv[])
putenv (session_name_env);
the_session = read_session (session_name);
+ fix_wm (the_session);
+
gsm_sound_login ();
gsm_remote_desktop_start ();