patch for xcb-util

David Coppa <[email protected]> Tue, 16 Mar 2010 10:20:23 +0100
Newsgroups gmane.os.openbsd.x11
Message-ID <20100316092023.GA29856@cl0311500093650>
Hello,

I'd really like to have this in: are there any objections?

I'm resending, just in case it got lost.

Thanks,
david


Index: icccm.c
===================================================================
RCS file: /cvs/xenocara/dist/xcb-util/icccm/icccm.c,v
retrieving revision 1.5
diff -N -u -p icccm.c
--- icccm.c	7 Mar 2010 15:51:34 -0000	1.5
+++ icccm.c	16 Mar 2010 09:01:39 -0000
@@ -58,7 +58,7 @@ xcb_get_text_property_reply(xcb_connection_t *c,
 {
   xcb_get_property_reply_t *reply = xcb_get_property_reply(c, cookie, e);
 
-  if(!reply)
+  if(!reply || reply->type == XCB_NONE)
     return 0;
 
   prop->_reply = reply;
@@ -418,8 +418,7 @@ xcb_get_property_cookie_t
 xcb_get_wm_size_hints(xcb_connection_t *c, xcb_window_t window,
                       xcb_atom_t property)
 {
-  /* NumPropSizeElements = 18 (ICCCM version 1). */
-  return xcb_get_property(c, 0, window, property, WM_SIZE_HINTS, 0L, 18);
+  return xcb_get_property(c, 0, window, property, WM_SIZE_HINTS, 0L, XCB_NUM_WM_SIZE_HINTS_ELEMENTS);
 }
 
 xcb_get_property_cookie_t
@@ -427,7 +426,7 @@ xcb_get_wm_size_hints_unchecked(xcb_connection_t *c, x
                                 xcb_atom_t property)
 {
   return xcb_get_property_unchecked(c, 0, window, property, WM_SIZE_HINTS,
-                                    0L, 18);
+                                    0L, XCB_NUM_WM_SIZE_HINTS_ELEMENTS);
 }
 
 uint8_t
@@ -439,13 +438,11 @@ xcb_get_wm_size_hints_from_reply(xcb_size_hints_t *hin
   if(!reply)
     return 0;
 
-  length = xcb_get_property_value_length(reply) / (reply->format / 8);
-
   if (!(reply->type == WM_SIZE_HINTS &&
-         reply->format == 32 &&
-        /* OldNumPropSizeElements = 15 (pre-ICCCM) */
-        length >= 15))
+         reply->format == 32))
     return 0;
+
+  length = xcb_get_property_value_length(reply) / (reply->format / 8);
 
   if (length > XCB_NUM_WM_SIZE_HINTS_ELEMENTS)
     length = XCB_NUM_WM_SIZE_HINTS_ELEMENTS;