--- gdm-2.14.9/daemon/gdmconfig.h.xserver-args-in-session	2006-08-06 20:15:07.000000000 +0100
+++ gdm-2.14.9/daemon/gdmconfig.h	2006-08-06 20:16:07.000000000 +0100
@@ -82,4 +82,5 @@ void		gdm_set_user_session_lang (gboolea
 					 const char *save_language);
 char*          gdm_get_session_exec     (const char *session_name,
                                          gboolean check_try_exec);
+char*          gdm_get_session_xserver_args     (const char *session_name);
 
--- gdm-2.14.9/daemon/gdm.c.xserver-args-in-session	2006-08-06 20:42:37.000000000 +0100
+++ gdm-2.14.9/daemon/gdm.c	2006-08-06 20:47:32.000000000 +0100
@@ -135,6 +135,8 @@ gboolean gdm_emergency_server = FALSE;
 
 gboolean gdm_first_login = TRUE;
 
+gchar *gdm_xserver_args = NULL;
+
 int gdm_in_signal = 0;
 gboolean gdm_in_final_cleanup = FALSE;
 
--- gdm-2.14.9/daemon/slave.c.xserver-args-in-session	2006-08-06 20:26:58.000000000 +0100
+++ gdm-2.14.9/daemon/slave.c	2006-08-06 20:52:12.000000000 +0100
@@ -141,6 +141,7 @@ static int slave_waitpid_w = -1;
 static GSList *slave_waitpids = NULL;
 
 extern gboolean gdm_first_login;
+extern gchar *gdm_xserver_args;
 extern gboolean gdm_emergency_server;
 extern pid_t extra_process;
 extern int extra_status;
@@ -4135,6 +4136,16 @@ gdm_slave_session_start (void)
     if (gdm_get_value_bool (GDM_KEY_KILL_INIT_CLIENTS))
 	    gdm_server_whack_clients (d->dsp);
 
+    gdm_xserver_args = gdm_get_session_xserver_args(session);
+    if ( gdm_xserver_args ) {
+	    gdm_server_stop(d);
+	    gdm_slave_send_num (GDM_SOP_XPID, 0);
+	    gdm_server_start (d, TRUE, FALSE, 20, 5);
+	    gdm_slave_send_num (GDM_SOP_XPID, d->servpid);
+	    g_free(gdm_xserver_args);
+	    gdm_xserver_args = NULL;
+    }
+
     /* Now that we will set up the user authorization we will
        need to run session_stop to whack it */
     session_started = TRUE;
--- gdm-2.14.9/daemon/server.c.xserver-args-in-session	2006-08-06 20:38:44.000000000 +0100
+++ gdm-2.14.9/daemon/server.c	2006-08-06 20:49:33.000000000 +0100
@@ -59,6 +59,7 @@ static char * get_font_path (const char 
 extern pid_t extra_process;
 extern int extra_status;
 extern int gdm_in_signal;
+extern gchar *gdm_xserver_args;
 
 /* Global vars */
 static GdmDisplay *d = NULL;
@@ -945,6 +946,26 @@ rotate_logs (const char *dname)
 	g_free (fname);
 }
 
+static void
+gdm_server_add_xserver_args (char **argv)
+{
+	int count;
+	char **args;
+	int len;
+	int i;
+
+	len = ve_vector_len(argv);
+	g_shell_parse_argv (gdm_xserver_args, &count, &args, NULL);
+	argv = g_renew (char *, argv, len + count + 1);
+
+	for (i=0; i < count;i++) {
+		argv[len++] = g_strdup(args[i]);
+	}
+
+	argv[len] = NULL;
+	g_strfreev (args);
+}
+
 GdmXserver *
 gdm_server_resolve (GdmDisplay *disp)
 {
@@ -1114,6 +1135,9 @@ gdm_server_spawn (GdmDisplay *d, const c
 					    TRUE /* resolve flags */,
 					    vtarg);
 
+    if (gdm_xserver_args)
+	    gdm_server_add_xserver_args (argv);
+
     command = g_strjoinv (" ", argv);
 
     /* Fork into two processes. Parent remains the gdm process. Child
--- gdm-2.14.9/daemon/gdmconfig.c.xserver-args-in-session	2006-08-06 20:02:33.000000000 +0100
+++ gdm-2.14.9/daemon/gdmconfig.c	2006-08-06 20:14:38.000000000 +0100
@@ -2625,6 +2625,68 @@ gdm_get_session_exec (const char *sessio
 }
 
 /**
+ * gdm_get_session_xserver_args
+ *
+ * This function accesses the GDM session desktop file, via vicious
+ * extensions and returns any additional X server arguments that are
+ * specified there.
+ */
+char *
+gdm_get_session_xserver_args (const char *session_name)
+{
+   char *file;
+   char *full = NULL;
+   VeConfig *cfg;
+   static char *xserver_args;
+   static char *cached = NULL;
+
+   /* clear cache */
+   if (session_name == NULL) {
+      g_free (xserver_args);
+      xserver_args = NULL;
+      g_free (cached);
+      cached = NULL;
+      return NULL;
+   }
+
+   if (cached != NULL && strcmp (ve_sure_string (session_name), ve_sure_string (cached)) == 0)
+      return g_strdup (xserver_args);
+
+   g_free (xserver_args);
+   xserver_args = NULL;
+   g_free (cached);
+   cached = g_strdup (session_name);
+
+   /* Some ugly special casing for legacy "Default.desktop", oh well,
+    * we changed to "default.desktop" */
+   if (g_ascii_strcasecmp (session_name, "default") == 0 ||
+       g_ascii_strcasecmp (session_name, "default.desktop") == 0) {
+      full = ve_find_prog_in_path ("default.desktop",
+         gdm_get_value_string (GDM_KEY_SESSION_DESKTOP_DIR));
+   }
+
+   if (full == NULL) {
+      file = gdm_ensure_extension (session_name, ".desktop");
+      full = ve_find_prog_in_path (file,
+         gdm_get_value_string (GDM_KEY_SESSION_DESKTOP_DIR));
+      g_free (file);
+   }
+
+   if (ve_string_empty (full) || g_access (full, R_OK) != 0) {
+      g_free (full);
+      return NULL;
+   }
+
+   cfg = ve_config_get (full);
+   g_free (full);
+   if (ve_config_get_bool (cfg, "Desktop Entry/Hidden=false"))
+      return NULL;
+
+   xserver_args = ve_config_get_string (cfg, "Desktop Entry/X-Gdm-XserverArgs");
+   return g_strdup (xserver_args);
+}
+
+/**
  * gdm_set_user_session_lang
  * gdm_get_user_session_lang
  *
--- gdm-2.14.9/docs/C/gdm.xml.xserver-args-in-session	2006-06-12 19:52:59.000000000 +0100
+++ gdm-2.14.9/docs/C/gdm.xml	2006-08-08 07:32:30.000000000 +0100
@@ -1177,6 +1177,14 @@ PostSession/
       <filename>Hidden=true</filename> in that file.
     </para>
 
+    <para>
+      GDM uses the optional key <filename>X-Gdm-XserverArgs</filename> in
+      session files to specify additional arguments to be passed to the
+      X server.  For example, the entry
+      <filename>X-Gdm-XserverArgs=-depth 16</filename> will start the
+      X server with a color depth of 16 bits.
+    </para>
+
     <sect2 id="scriptdirs">
       <title>The Script Directories</title>
       
