? gdk/groupleader.diff
Index: gdk/gdkdisplay.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkdisplay.h,v
retrieving revision 1.15
diff -u -p -r1.15 gdkdisplay.h
--- gdk/gdkdisplay.h	5 Jul 2003 01:53:46 -0000	1.15
+++ gdk/gdkdisplay.h	8 Aug 2003 21:32:29 -0000
@@ -157,6 +157,8 @@ void     gdk_display_get_maximal_cursor_
 						guint         *width,
 						guint         *height);
 
+GdkWindow *gdk_display_get_default_group (GdkDisplay *display); 
+
 G_END_DECLS
 
 #endif				/* __GDK_DISPLAY_H__ */
Index: gdk/gdkwindow.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.h,v
retrieving revision 1.45
diff -u -p -r1.45 gdkwindow.h
--- gdk/gdkwindow.h	17 Nov 2002 22:03:47 -0000	1.45
+++ gdk/gdkwindow.h	8 Aug 2003 21:32:29 -0000
@@ -484,6 +484,7 @@ void	      gdk_window_set_icon_name	 (Gd
 					  const gchar	  *name);
 void	      gdk_window_set_group	 (GdkWindow	  *window, 
 					  GdkWindow	  *leader);
+GdkWindow*    gdk_window_get_group	 (GdkWindow	  *window);
 void	      gdk_window_set_decorations (GdkWindow	  *window,
 					  GdkWMDecoration  decorations);
 gboolean      gdk_window_get_decorations (GdkWindow       *window,
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	8 Aug 2003 21:32:30 -0000
@@ -177,6 +177,8 @@ gdk_display_open (const gchar *display_n
   display_x11->leader_window = XCreateSimpleWindow (display_x11->xdisplay,
 						    GDK_SCREEN_X11 (display_x11->default_screen)->xroot_window,
 						    10, 10, 10, 10, 0, 0, 0);
+  display_x11->leader_gdk_window = NULL;
+
   display_x11->leader_window_title_set = FALSE;
 
   display_x11->gravity_works = GDK_UNKNOWN;
@@ -555,6 +557,32 @@ 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)
+{
+  GdkDisplayX11 *display_x11;
+  
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  display_x11 = GDK_DISPLAY_X11 (display);
+
+  if (display_x11->leader_gdk_window == NULL)
+    display_x11->leader_gdk_window = gdk_window_foreign_new_for_display (display, display_x11->leader_window);
+
+  return display_x11->leader_gdk_window;
 }
 
 /**
Index: gdk/x11/gdkdisplay-x11.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkdisplay-x11.h,v
retrieving revision 1.13
diff -u -p -r1.13 gdkdisplay-x11.h
--- gdk/x11/gdkdisplay-x11.h	2 Aug 2003 17:50:09 -0000	1.13
+++ gdk/x11/gdkdisplay-x11.h	8 Aug 2003 21:32:30 -0000
@@ -109,6 +109,7 @@ struct _GdkDisplayX11
 
   /* Session Management leader window see ICCCM */
   Window leader_window;
+  GdkWindow *leader_gdk_window;
   gboolean leader_window_title_set;
   
   /* list of filters for client messages */
Index: gdk/x11/gdkwindow-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v
retrieving revision 1.192
diff -u -p -r1.192 gdkwindow-x11.c
--- gdk/x11/gdkwindow-x11.c	2 Aug 2003 17:50:09 -0000	1.192
+++ gdk/x11/gdkwindow-x11.c	8 Aug 2003 21:32:31 -0000
@@ -3794,9 +3794,36 @@ gdk_window_unfullscreen (GdkWindow *wind
 
 
 /**
+ * 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
@@ -3813,18 +3840,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)
     {
