Index: gdk/gdkscreen.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkscreen.h,v
retrieving revision 1.17
diff -u -p -r1.17 gdkscreen.h
--- gdk/gdkscreen.h	26 Aug 2005 18:49:50 -0000	1.17
+++ gdk/gdkscreen.h	7 Nov 2005 14:43:10 -0000
@@ -110,6 +110,9 @@ void    gdk_screen_set_resolution (GdkSc
 				   gdouble    dpi);
 gdouble gdk_screen_get_resolution (GdkScreen *screen);
 
+GdkWindow *gdk_screen_get_active_window (GdkScreen *screen);
+GList     *gdk_screen_get_window_stack  (GdkScreen *screen);
+
 G_END_DECLS
 
 #endif				/* __GDK_SCREEN_H__ */
Index: gdk/x11/gdkscreen-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkscreen-x11.c,v
retrieving revision 1.43
diff -u -p -r1.43 gdkscreen-x11.c
--- gdk/x11/gdkscreen-x11.c	1 Sep 2005 05:11:46 -0000	1.43
+++ gdk/x11/gdkscreen-x11.c	7 Nov 2005 14:43:11 -0000
@@ -34,6 +34,8 @@
 #include "gdkx.h"
 #include "gdkalias.h"
 
+#include <X11/Xatom.h>
+
 #ifdef HAVE_SOLARIS_XINERAMA
 #include <X11/extensions/xinerama.h>
 #endif
@@ -777,6 +789,131 @@ gdk_screen_make_display_name (GdkScreen 
 
   return _gdk_windowing_substitute_screen_number (old_display, 
 						  gdk_screen_get_number (screen));
+}
+
+/**
+ * gdk_screen_get_active_window
+ * @screen: a #GdkScreen
+ *
+ * Returns a pointer to the screen's currently active window. On X11,
+ * this is done by inspecting the _NET_ACTIVE_WINDOW property on the root
+ * window. If there is no currently currently active window, or the window
+ * manager does not support the _NET_ACTIVE_WINDOW hint, this function
+ * returns NULL.
+ *
+ * Return value: a #GdkWindow wrapper for the currently active window,
+ * or %NULL.
+ *
+ * Since: 2.10
+ **/
+GdkWindow *
+gdk_screen_get_active_window (GdkScreen *screen)
+{
+  GdkScreenX11 *screen_x11;
+  GdkWindow *ret = NULL;
+  Atom type_return;
+  gint format_return;
+  gulong nitems_return;
+  gulong bytes_after_return;
+  guchar *data;
+
+  g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+
+  if (!gdk_x11_screen_supports_net_wm_hint (screen,
+                                            gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))
+    return NULL;
+
+  screen_x11 = GDK_SCREEN_X11 (screen);
+
+  if (XGetWindowProperty (screen_x11->xdisplay, screen_x11->xroot_window,
+	                  gdk_x11_get_xatom_by_name_for_display (screen_x11->display,
+			                                         "_NET_ACTIVE_WINDOW"),
+		          0, 1, False, XA_WINDOW, &type_return,
+		          &format_return, &nitems_return,
+                          &bytes_after_return, &data)
+      == Success)
+    {
+      if ((type_return == XA_WINDOW) && (format_return == 32) && (data))
+        {
+          GdkNativeWindow window = *(GdkNativeWindow *) data;
+
+          if (window != None)
+            {
+              ret = gdk_window_foreign_new_for_display (screen_x11->display,
+                                                        *(GdkNativeWindow *) data);
+            }
+        }
+    }
+
+  if (type_return != None)
+    XFree (data);
+
+  return ret;
+}
+
+/**
+ * gdk_screen_get_window_stack
+ * @screen: a #GdkScreen
+ *
+ * Returns a list of #GdkWindow wrappers representing the current window stack.
+ * On X11, this is done by inspecting the _NET_CLIENT_LIST_STACKING property on
+ * the root window. If the window manager does not support the
+ * _NET_CLIENT_LIST_STACKING hint, this function returns NULL.
+ *
+ * Return value: a list of #GdkWindow wrappers for the current window stack,
+ *               or %NULL.
+ *
+ * Since: 2.10
+ **/
+GList *
+gdk_screen_get_window_stack (GdkScreen *screen)
+{
+  GdkScreenX11 *screen_x11;
+  GList *ret = NULL;
+  Atom type_return;
+  gint format_return;
+  gulong nitems_return;
+  gulong bytes_after_return;
+  guchar *data;
+
+  g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+
+  if (!gdk_x11_screen_supports_net_wm_hint (screen,
+                                            gdk_atom_intern ("_NET_CLIENT_LIST_STACKING", FALSE)))
+    return NULL;
+
+  screen_x11 = GDK_SCREEN_X11 (screen);
+
+  if (XGetWindowProperty (screen_x11->xdisplay, screen_x11->xroot_window,
+	                  gdk_x11_get_xatom_by_name_for_display (screen_x11->display,
+			                                         "_NET_CLIENT_LIST_STACKING"),
+		          0, G_MAXLONG, False, XA_WINDOW, &type_return,
+		          &format_return, &nitems_return,
+                          &bytes_after_return, &data)
+      == Success)
+    {
+      if ((type_return == XA_WINDOW) && (format_return == 32) &&
+          (data) && (nitems_return > 0))
+        {
+          GdkNativeWindow *stack = (GdkNativeWindow *) data;
+          GdkWindow *win;
+          int i;
+
+          for (i = 0; i < nitems_return; i++)
+            {
+              win = gdk_window_foreign_new_for_display (screen_x11->display,
+                                                        stack[i]);
+
+              if (win != NULL)
+                ret = g_list_append (ret, win);
+            }
+        }
+    }
+
+  if (type_return != None)
+    XFree (data);
+
+  return ret;
 }
 
 #define __GDK_SCREEN_X11_C__
