Index: gdk/x11/gdkdisplay-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkdisplay-x11.c,v
retrieving revision 1.38
diff -u -p -r1.38 gdkdisplay-x11.c
--- gdk/x11/gdkdisplay-x11.c	2 Aug 2003 21:35:40 -0000	1.38
+++ gdk/x11/gdkdisplay-x11.c	9 Nov 2003 00:18:49 -0000
@@ -138,6 +138,7 @@ gdk_display_open (const gchar *display_n
   Display *xdisplay;
   GdkDisplay *display;
   GdkDisplayX11 *display_x11;
+  GdkWindowAttr attr;
   gint argc;
   gchar **argv;
   const char *sm_client_id;
@@ -174,9 +175,19 @@ gdk_display_open (const gchar *display_n
   
   /*set the default screen */
   display_x11->default_screen = display_x11->screens[DefaultScreen (display_x11->xdisplay)];
-  display_x11->leader_window = XCreateSimpleWindow (display_x11->xdisplay,
-						    GDK_SCREEN_X11 (display_x11->default_screen)->xroot_window,
-						    10, 10, 10, 10, 0, 0, 0);
+
+  attr.window_type = GDK_WINDOW_TOPLEVEL;
+  attr.wclass = GDK_INPUT_OUTPUT;
+  attr.x = 10;
+  attr.y = 10;
+  attr.width = 10;
+  attr.height = 10;
+  attr.event_mask = 0;
+
+  display_x11->leader_gdk_window = gdk_window_new (GDK_SCREEN_X11 (display_x11->default_screen)->root_window, 
+						   &attr, GDK_WA_X | GDK_WA_Y);
+  display_x11->leader_window = GDK_WINDOW_XID (display_x11->leader_gdk_window);
+
   display_x11->leader_window_title_set = FALSE;
 
   display_x11->gravity_works = GDK_UNKNOWN;
@@ -555,6 +566,25 @@ gdk_display_flush (GdkDisplay *display)
 
   if (!display->closed)
     XFlush (GDK_DISPLAY_XDISPLAY (display));
+}
+
+/**
+ * gdk_display_get_default_group:
+ * @display: a #GdkDisplay
+ * 
+ * Returns the default group leader window for all toplevel windows
+ * on @display. This window is implicitly created by GDK. 
+ * See gdk_window_set_group().
+ * 
+ * Return value: The default group leader window for @display
+ *
+ * Since: 2.4
+ **/
+GdkWindow *gdk_display_get_default_group (GdkDisplay *display)
+{
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  return GDK_DISPLAY_X11 (display)->leader_gdk_window;
 }
 
 /**
Index: gdk/x11/gdkwindow-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v
retrieving revision 1.195
diff -u -p -r1.195 gdkwindow-x11.c
--- gdk/x11/gdkwindow-x11.c	23 Oct 2003 18:50:40 -0000	1.195
+++ gdk/x11/gdkwindow-x11.c	9 Nov 2003 00:18:50 -0000
@@ -370,7 +370,7 @@ check_leader_window_title (GdkDisplay *d
 {
   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
 
-  if (!display_x11->leader_window_title_set)
+  if (display_x11->leader_window && !display_x11->leader_window_title_set)
     {
       set_wm_name (display,
 		   display_x11->leader_window,
@@ -3870,9 +3870,36 @@ gdk_window_set_keep_below (GdkWindow *wi
 }
 
 /**
+ * gdk_window_get_group:
+ * @window: a toplevel #GdkWindow
+ * 
+ * Returns the group leader window for @window. See gdk_window_set_group().
+ * 
+ * Return value: the group leader window for @window
+ *
+ * Since: 2.4
+ **/
+GdkWindow *
+gdk_window_get_group (GdkWindow *window)
+{
+  GdkToplevelX11 *toplevel;
+  
+  g_return_val_if_fail (window != NULL, NULL);
+  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+  g_return_val_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD, NULL);
+
+  if (GDK_WINDOW_DESTROYED (window))
+    return NULL;
+  
+  toplevel = _gdk_x11_window_get_toplevel (window);
+
+  return toplevel->group_leader;
+}
+
+/**
  * gdk_window_set_group:
  * @window: a toplevel #GdkWindow
- * @leader: group leader window
+ * @leader: group leader window, or %NULL to restore the default group leader window
  *
  * Sets the group leader window for @window. By default,
  * GDK sets the group leader for all toplevel windows
@@ -3889,18 +3916,21 @@ void          
 gdk_window_set_group (GdkWindow *window, 
 		      GdkWindow *leader)
 {
+  GdkDisplay *display;
   GdkToplevelX11 *toplevel;
   
   g_return_if_fail (window != NULL);
   g_return_if_fail (GDK_IS_WINDOW (window));
   g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);
-  g_return_if_fail (leader != NULL);
-  g_return_if_fail (GDK_IS_WINDOW (leader));
+  g_return_if_fail (leader == NULL || GDK_IS_WINDOW (leader));
+
+  if (GDK_WINDOW_DESTROYED (window) || (leader != NULL && GDK_WINDOW_DESTROYED (leader)))
+    return;
 
   toplevel = _gdk_x11_window_get_toplevel (window);
 
-  if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (leader))
-    return;
+  if (leader == NULL) 
+    leader = gdk_display_get_default_group (gdk_drawable_get_display (window));
   
   if (toplevel->group_leader != leader)
     {
