diff -up libwnck-2.20.1/libwnck/util.c.no-resource-extension libwnck-2.20.1/libwnck/util.c
--- libwnck-2.20.1/libwnck/util.c.no-resource-extension 2007-10-15 18:37:33.000000000 -0400
+++ libwnck-2.20.1/libwnck/util.c 2007-10-22 13:26:23.000000000 -0400
@@ -114,32 +114,13 @@ _wnck_print_resource_usage (WnckResource
}
#endif
-/**
- * wnck_xid_read_resource_usage:
- * @gdk_display: a <classname>GdkDisplay</classname>.
- * @xid: an X window ID.
- * @usage: return location for the X resource usage of the application owning
- * the X window ID @xid.
- *
- * Looks for the X resource usage of the application owning the X window ID
- * @xid on display @gdisplay. If no resource usage can be found, then all
- * fields of @usage are set to 0.
- *
- * To properly work, this function requires the XRes extension on the X server.
- *
- * Since: 2.6
- */
-void
-wnck_xid_read_resource_usage (GdkDisplay *gdisplay,
- gulong xid,
- WnckResourceUsage *usage)
+static WnckExtStatus
+wnck_init_resource_usage (GdkDisplay *gdisplay)
{
int event, error;
Display *xdisplay;
WnckExtStatus status;
- g_return_if_fail (usage != NULL);
-
xdisplay = GDK_DISPLAY_XDISPLAY (gdisplay);
status = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (gdisplay),
@@ -163,13 +144,39 @@ wnck_xid_read_resource_usage (GdkDisplay
g_assert (status != WNCK_EXT_UNKNOWN);
+ return status;
+}
+
+/**
+ * wnck_xid_read_resource_usage:
+ * @gdk_display: a <classname>GdkDisplay</classname>.
+ * @xid: an X window ID.
+ * @usage: return location for the X resource usage of the application owning
+ * the X window ID @xid.
+ *
+ * Looks for the X resource usage of the application owning the X window ID
+ * @xid on display @gdisplay. If no resource usage can be found, then all
+ * fields of @usage are set to 0.
+ *
+ * To properly work, this function requires the XRes extension on the X server.
+ *
+ * Since: 2.6
+ */
+void
+wnck_xid_read_resource_usage (GdkDisplay *gdisplay,
+ gulong xid,
+ WnckResourceUsage *usage)
+{
+ g_return_if_fail (usage != NULL);
+
memset (usage, '\0', sizeof (*usage));
-
- if (status == WNCK_EXT_MISSING)
+
+ if (wnck_init_resource_usage (gdisplay) == WNCK_EXT_MISSING)
return;
#ifdef HAVE_XRES
{
+ Display *xdisplay;
XResType *types;
int n_types;
unsigned long pixmap_bytes;
@@ -190,6 +197,8 @@ wnck_xid_read_resource_usage (GdkDisplay
_wnck_error_trap_push ();
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdisplay);
+
XResQueryClientResources (xdisplay,
xid, &n_types,
&types);
@@ -608,12 +617,12 @@ wnck_pid_read_resource_usage (GdkDisplay
{
g_return_if_fail (usage != NULL);
-#ifndef HAVE_XRES
- memset (usage, '\0', sizeof (*usage));
- return;
-#else
memset (usage, '\0', sizeof (*usage));
+ if (wnck_init_resource_usage (gdisplay) == WNCK_EXT_MISSING)
+ return;
+
+#ifdef HAVE_XRES
if (!wnck_pid_read_resource_usage_from_cache (gdisplay, pid, usage))
/* the cache might not be built, might be outdated or might not contain
* data for a new X client, so try to fallback to something else */