Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/ChangeLog,v
retrieving revision 1.86
diff -u -p -r1.86 ChangeLog
--- ChangeLog	2 Nov 2002 19:01:06 -0000	1.86
+++ ChangeLog	8 Nov 2002 01:46:41 -0000
@@ -0,0 +1,21 @@
+2002-11-08  Mark McLoughlin  <mark@skynet.ie>
+
+	Create a XSettingsManager for every available
+	screen and apply settings changes to each.
+
+	* gnome-settings-daemon.c:
+	(manager_event_filter): make this a per-window filter
+	and ask the appropriate xsettings manager to filter
+	the event.
+	(finalize): dispose of every manager.
+	(gnome_settings_daemon_new): create a settings manager
+	for each screen.
+
+	* gnome-settings-xsettings.c:
+	(translate_bool_int), (translate_int_int),
+	(translate_string_string), (process_value),
+	(xsettings_callback), (xft_callback),
+	(gnome_xft_settings_set_xsettings),
+	(gnome_settings_xsettings_load): apply settings to
+	every available settings manager.
+
Index: gnome-settings-daemon.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-daemon.c,v
retrieving revision 1.27
diff -u -p -r1.27 gnome-settings-daemon.c
--- gnome-settings-daemon.c	29 Oct 2002 06:19:51 -0000	1.27
+++ gnome-settings-daemon.c	8 Nov 2002 01:46:42 -0000
@@ -56,7 +56,7 @@ struct _GnomeSettingsDaemonPrivate {
 };
 
 static GSList *directories = NULL;
-XSettingsManager *manager;
+XSettingsManager **managers = NULL;
 
 typedef struct DirElement
 {
@@ -128,6 +128,9 @@ static void
 terminate_cb (void *data)
 {
   gboolean *terminated = data;
+
+  if (*terminated)
+    return;
   
   *terminated = TRUE;
   gtk_main_quit ();
@@ -138,7 +141,11 @@ manager_event_filter (GdkXEvent *xevent,
 		      GdkEvent  *event,
 		      gpointer   data)
 {
-  if (xsettings_manager_process_event (manager, (XEvent *)xevent))
+  int screen_num = GPOINTER_TO_INT (data);
+
+  g_return_val_if_fail (managers != NULL, GDK_FILTER_CONTINUE);
+
+  if (xsettings_manager_process_event (managers [screen_num], (XEvent *)xevent))
     return GDK_FILTER_REMOVE;
   else
     return GDK_FILTER_CONTINUE;
@@ -160,13 +167,15 @@ static void
 finalize (GObject *object)
 {
 	GnomeSettingsDaemon *daemon;
+	int                  i;
 
 	daemon = GNOME_SETTINGS_DAEMON (object);
 	if (daemon->private == NULL) {
 	  return;
 	}
 
-	xsettings_manager_destroy (manager);
+	for (i = 0; managers && managers [i]; i++)
+		xsettings_manager_destroy (managers [i]);
 
 	g_free (daemon->private);
 	daemon->private = NULL;
@@ -204,10 +213,18 @@ gnome_settings_daemon_new (void)
   GConfClient *client;
   GSList *list;
   GnomeSettingsDaemon *daemon;
+  GdkDisplay *display;
+  int i;
+  int n_screens;
+
+  display = gdk_display_get_default ();
+  n_screens = gdk_display_get_n_screens (display);
 
   daemon = g_object_new (gnome_settings_daemon_get_type (), NULL);
 
-  if (xsettings_manager_check_running (gdk_display, DefaultScreen (gdk_display)))
+  if (xsettings_manager_check_running (
+		gdk_x11_display_get_xdisplay (display),
+		gdk_screen_get_number (gdk_screen_get_default ())))
     {
       fprintf (stderr, "You can only run one xsettings manager at a time; exiting\n");
       exit (1);
@@ -215,13 +232,27 @@ gnome_settings_daemon_new (void)
       
   if (!terminated)
     {
-      manager = xsettings_manager_new (gdk_display, DefaultScreen (gdk_display),
-				       terminate_cb, &terminated);
-      if (!manager)
-	{
-	  fprintf (stderr, "Could not create xsettings manager!\n");
-	  exit (1);
-	}
+      managers = g_new (XSettingsManager *, n_screens + 1);
+
+      for (i = 0; i < n_screens; i++)
+        {
+          GdkScreen *screen;
+
+          screen = gdk_display_get_screen (display, i);
+
+          managers [i] = xsettings_manager_new (
+				gdk_x11_display_get_xdisplay (display),
+				gdk_screen_get_number (screen),
+				terminate_cb, &terminated);
+          if (!managers [i])
+	    {
+	      fprintf (stderr, "Could not create xsettings manager for screen %d!\n", i);
+	      exit (1);
+	    }
+        }
+
+      g_assert (i == n_screens);
+      managers [i] = NULL;
     }
 
   /* We use GConfClient not GConfClient because a cache isn't useful
@@ -266,8 +297,16 @@ gnome_settings_daemon_new (void)
           g_error_free (error);
         }
     }
-  
-  gdk_window_add_filter (NULL, manager_event_filter, NULL);
+ 
+  for (i = 0; i < n_screens; i++) 
+    {
+      GdkScreen *screen;
+
+      screen = gdk_display_get_screen (display, i);
+      gdk_window_add_filter (
+		gdk_screen_get_root_window (screen),
+		manager_event_filter, GINT_TO_POINTER (i));
+    }
 
 /*  gnome_settings_disk_load (client);*/
   gnome_settings_font_load (client);
Index: gnome-settings-xsettings.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-xsettings.c,v
retrieving revision 1.18
diff -u -p -r1.18 gnome-settings-xsettings.c
--- gnome-settings-xsettings.c	27 Oct 2002 14:07:38 -0000	1.18
+++ gnome-settings-xsettings.c	8 Nov 2002 01:46:44 -0000
@@ -13,7 +13,7 @@
 #include "gnome-settings-xsettings.h"
 #include "xsettings-manager.h"
 
-extern XSettingsManager *manager;
+extern XSettingsManager **managers;
 
 #ifdef HAVE_XFT2
 #define FONT_RENDER_DIR "/desktop/gnome/font_rendering"
@@ -44,31 +44,40 @@ static void
 translate_bool_int (TranslationEntry *trans,
 		    GConfValue       *value)
 {
+  int i;
+
   g_assert (value->type == trans->gconf_type);
   
-  xsettings_manager_set_int (manager, trans->xsetting_name,
-                             gconf_value_get_bool (value));
+  for (i = 0; managers [i]; i++)  
+    xsettings_manager_set_int (managers [i], trans->xsetting_name,
+                               gconf_value_get_bool (value));
 }
 
 static void
 translate_int_int (TranslationEntry *trans,
                    GConfValue       *value)
 {
+  int i;
+
   g_assert (value->type == trans->gconf_type);
-  
-  xsettings_manager_set_int (manager, trans->xsetting_name,
-                             gconf_value_get_int (value));
+
+  for (i = 0; managers [i]; i++)  
+    xsettings_manager_set_int (managers [i], trans->xsetting_name,
+                               gconf_value_get_int (value));
 }
 
 static void
 translate_string_string (TranslationEntry *trans,
                          GConfValue       *value)
 {
+  int i;
+
   g_assert (value->type == trans->gconf_type);
 
-  xsettings_manager_set_string (manager,
-                                trans->xsetting_name,
-                                gconf_value_get_string (value));
+  for (i = 0; managers [i]; i++)  
+    xsettings_manager_set_string (managers [i],
+                                  trans->xsetting_name,
+                                  gconf_value_get_string (value));
 }
 
 static TranslationEntry translations [] = {
@@ -159,7 +168,10 @@ process_value (TranslationEntry *trans,
 {  
   if (val == NULL)
     {
-      xsettings_manager_delete_setting (manager, trans->xsetting_name);
+      int i;
+
+      for (i = 0; managers [i]; i++)  
+        xsettings_manager_delete_setting (managers [i], trans->xsetting_name);
     }
   else
     {
@@ -181,14 +193,16 @@ static void
 xsettings_callback (GConfEntry *entry)
 {
   TranslationEntry *trans;
-  trans = find_translation_entry (entry->key);
+  int i;
 
+  trans = find_translation_entry (entry->key);
   if (trans == NULL)
     return;
 
   process_value (trans, entry->value);
   
-  xsettings_manager_notify (manager);
+  for (i = 0; managers [i]; i++)  
+    xsettings_manager_notify (managers [i]);
 }
 
 void
@@ -208,11 +222,14 @@ static void
 xft_callback (GConfEntry *entry)
 {
   GConfClient *client;
+  int i;
 
   client = gconf_client_get_default ();
 
   gnome_settings_update_xft (client);
-  xsettings_manager_notify (manager);
+
+  for (i = 0; managers [i]; i++)  
+    xsettings_manager_notify (managers [i]);
 }
 
 typedef struct
@@ -320,11 +337,15 @@ gnome_xft_settings_get (GConfClient     
 static void
 gnome_xft_settings_set_xsettings (GnomeXftSettings *settings)
 {
-  xsettings_manager_set_int (manager, "Xft/Antialias", settings->antialias);
-  xsettings_manager_set_int (manager, "Xft/Hinting", settings->hinting);
-  xsettings_manager_set_string (manager, "Xft/HintStyle", settings->hintstyle);
-  xsettings_manager_set_int (manager, "Xft/DPI", settings->dpi);
-  xsettings_manager_set_string (manager, "Xft/RGBA", settings->rgba);
+  int i;
+  for (i = 0; managers [i]; i++)  
+    {
+      xsettings_manager_set_int (managers [i], "Xft/Antialias", settings->antialias);
+      xsettings_manager_set_int (managers [i], "Xft/Hinting", settings->hinting);
+      xsettings_manager_set_string (managers [i], "Xft/HintStyle", settings->hintstyle);
+      xsettings_manager_set_int (managers [i], "Xft/DPI", settings->dpi);
+      xsettings_manager_set_string (managers [i], "Xft/RGBA", settings->rgba);
+    }
 }
 
 /*
@@ -509,5 +530,6 @@ gnome_settings_xsettings_load (GConfClie
   gnome_settings_update_xft (client);
 #endif /* HAVE_XFT */
 
-  xsettings_manager_notify (manager);
+  for (i = 0; managers [i]; i++)  
+    xsettings_manager_notify (managers [i]);
 }
