[Xcb-commit] 3 commits - icccm

Julien Danjou jdanjou at kemper.freedesktop.org
Wed Jun 18 00:20:33 PDT 2008


 icccm/icccm.c     |  331 +++++++++++-------------------------------------------
 icccm/xcb_icccm.h |   81 ++++++-------
 2 files changed, 108 insertions(+), 304 deletions(-)

New commits:
commit 695726a6d1ac127f1daaccae80e168b92c4dd007
Author: Arnaud Fontaine <arnau at debian.org>
Date:   Sun Apr 27 11:51:14 2008 +0100

    [icccm]: Remove useless function for accessing 'flags' which were also
    buggy because they were returning a 'uint8_t' whereas 'flags' is a
    'uint32_t'.

diff --git a/icccm/icccm.c b/icccm/icccm.c
index facdbf5..ec4aaa1 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -164,19 +164,6 @@ xcb_watch_wm_client_machine (xcb_property_handlers_t        *prophs,
 
 /* WM_SIZE_HINTS */
 
-typedef enum {
-	USPosition = 1 << 0,
-	USSize = 1 << 1,
-	PPosition = 1 << 2,
-	PSize = 1 << 3,
-	PMinSize = 1 << 4,
-	PMaxSize = 1 << 5,
-	PResizeInc = 1 << 6,
-	PAspect = 1 << 7,
-	PBaseSize = 1 << 8,
-	PWinGravity = 1 << 9
-} xcb_size_hints_flags_t;
-
 struct xcb_size_hints_t {
 	uint32_t flags;
 	int32_t x, y, width, height;
@@ -279,130 +266,17 @@ xcb_size_hints_get_win_gravity (xcb_size_hints_t *hints)
         return hints->win_gravity;
 }
 
-uint8_t
-xcb_size_hints_is_us_position (xcb_size_hints_t *hints)
-{
-        return (hints->flags & USPosition);
-}
-
-uint8_t
-xcb_size_hints_is_us_size (xcb_size_hints_t *hints)
-{
-        return (hints->flags & USSize);
-}
-
-uint8_t
-xcb_size_hints_is_p_position (xcb_size_hints_t *hints)
-{
-        return (hints->flags & PPosition);
-}
-
-uint8_t
-xcb_size_hints_is_p_size (xcb_size_hints_t *hints)
-{
-        return (hints->flags & PSize);
-}
-
-uint8_t
-xcb_size_hints_is_p_min_size (xcb_size_hints_t *hints)
-{
-        return (hints->flags & PMinSize);
-}
-
-uint8_t
-xcb_size_hints_is_p_max_size (xcb_size_hints_t *hints)
-{
-        return (hints->flags & PMaxSize);
-}
-
-uint8_t
-xcb_size_hints_is_p_resize_inc (xcb_size_hints_t *hints)
-{
-        return (hints->flags & PResizeInc);
-}
-
-uint8_t
-xcb_size_hints_is_p_aspect (xcb_size_hints_t *hints)
-{
-        return (hints->flags & PAspect);
-}
-
-uint8_t
-xcb_size_hints_is_p_base_size (xcb_size_hints_t *hints)
-{
-        return (hints->flags & PBaseSize);
-}
-
-uint8_t
-xcb_size_hints_is_p_win_gravity (xcb_size_hints_t *hints)
-{
-        return (hints->flags & PWinGravity);
-}
-
-void
-xcb_size_hints_set_flag_none (xcb_size_hints_t *hints)
-{
-        hints->flags = 0;
-}
-
-void
-xcb_size_hints_set_flag_us_position (xcb_size_hints_t *hints)
-{
-        hints->flags = USPosition;
-}
-
-void
-xcb_size_hints_set_flag_us_size (xcb_size_hints_t *hints)
-{
-        hints->flags = USSize;
-}
-
-void
-xcb_size_hints_set_flag_p_position (xcb_size_hints_t *hints)
-{
-        hints->flags = PPosition;
-}
-
-void
-xcb_size_hints_set_flag_p_size (xcb_size_hints_t *hints)
-{
-        hints->flags = PSize;
-}
-
-void
-xcb_size_hints_set_flag_p_min_size (xcb_size_hints_t *hints)
-{
-        hints->flags = PMinSize;
-}
-
-void
-xcb_size_hints_set_flag_p_max_size (xcb_size_hints_t *hints)
-{
-        hints->flags = PMaxSize;
-}
-
-void
-xcb_size_hints_set_flag_p_resize_inc (xcb_size_hints_t *hints)
-{
-        hints->flags = PResizeInc;
-}
-
-void
-xcb_size_hints_set_flag_p_aspect (xcb_size_hints_t *hints)
-{
-        hints->flags = PAspect;
-}
-
-void
-xcb_size_hints_set_flag_p_base_size (xcb_size_hints_t *hints)
+uint32_t
+xcb_size_hints_get_flags (xcb_size_hints_t *hints)
 {
-        hints->flags = PBaseSize;
+	return hints->flags;
 }
 
 void
-xcb_size_hints_set_flag_p_win_gravity (xcb_size_hints_t *hints)
+xcb_size_hints_set_flags (xcb_size_hints_t *hints,
+                          uint32_t flags)
 {
-        hints->flags = PWinGravity;
+	hints->flags = flags;
 }
 
 void
@@ -411,11 +285,11 @@ xcb_size_hints_set_position (xcb_size_hints_t *hints,
                              int32_t           x,
                              int32_t           y)
 {
-	hints->flags &= ~(USPosition | PPosition);
+	hints->flags &= ~(XCB_SIZE_US_POSITION_HINT | XCB_SIZE_P_POSITION_HINT);
 	if (user_specified)
-		hints->flags |= USPosition;
+		hints->flags |= XCB_SIZE_US_POSITION_HINT;
 	else
-		hints->flags |= PPosition;
+		hints->flags |= XCB_SIZE_P_POSITION_HINT;
 	hints->x = x;
 	hints->y = y;
 }
@@ -426,11 +300,11 @@ xcb_size_hints_set_size (xcb_size_hints_t *hints,
                          int32_t           width,
                          int32_t           height)
 {
-	hints->flags &= ~(USSize | PSize);
+	hints->flags &= ~(XCB_SIZE_US_SIZE_HINT | XCB_SIZE_P_SIZE_HINT);
 	if (user_specified)
-		hints->flags |= USSize;
+		hints->flags |= XCB_SIZE_US_SIZE_HINT;
 	else
-		hints->flags |= PSize;
+		hints->flags |= XCB_SIZE_P_SIZE_HINT;
 	hints->width = width;
 	hints->height = height;
 }
@@ -440,7 +314,7 @@ xcb_size_hints_set_min_size (xcb_size_hints_t *hints,
                              int32_t           min_width,
                              int32_t           min_height)
 {
-	hints->flags |= PMinSize;
+	hints->flags |= XCB_SIZE_P_MIN_SIZE_HINT;
 	hints->min_width = min_width;
 	hints->min_height = min_height;
 }
@@ -450,7 +324,7 @@ xcb_size_hints_set_max_size (xcb_size_hints_t *hints,
                              int32_t           max_width,
                              int32_t           max_height)
 {
-	hints->flags |= PMaxSize;
+	hints->flags |= XCB_SIZE_P_MAX_SIZE_HINT;
 	hints->max_width = max_width;
 	hints->max_height = max_height;
 }
@@ -460,7 +334,7 @@ xcb_size_hints_set_resize_inc (xcb_size_hints_t *hints,
                                int32_t           width_inc,
                                int32_t           height_inc)
 {
-	hints->flags |= PResizeInc;
+	hints->flags |= XCB_SIZE_P_RESIZE_INC_HINT;
 	hints->width_inc = width_inc;
 	hints->height_inc = height_inc;
 }
@@ -472,7 +346,7 @@ xcb_size_hints_set_aspect (xcb_size_hints_t *hints,
                            int32_t           max_aspect_num,
                            int32_t           max_aspect_den)
 {
-	hints->flags |= PAspect;
+	hints->flags |= XCB_SIZE_P_ASPECT_HINT;
 	hints->min_aspect_num = min_aspect_num;
 	hints->min_aspect_den = min_aspect_den;
 	hints->max_aspect_num = max_aspect_num;
@@ -484,7 +358,7 @@ xcb_size_hints_set_base_size (xcb_size_hints_t *hints,
                               int32_t           base_width,
                               int32_t           base_height)
 {
-	hints->flags |= PBaseSize;
+	hints->flags |= XCB_SIZE_BASE_SIZE_HINT;
 	hints->base_width = base_width;
 	hints->base_height = base_height;
 }
@@ -493,7 +367,7 @@ void
 xcb_size_hints_set_win_gravity (xcb_size_hints_t *hints,
                                 uint8_t           win_gravity)
 {
-	hints->flags |= PWinGravity;
+	hints->flags |= XCB_SIZE_P_WIN_GRAVITY_HINT;
 	hints->win_gravity = win_gravity;
 }
 
@@ -550,12 +424,12 @@ xcb_get_wm_size_hints (xcb_connection_t *c,
 		memcpy (hints, (xcb_size_hints_t *) xcb_get_property_value (rep),
 			length * rep->format >> 3);
 
-		*supplied = (USPosition | USSize   |
-			     PPosition  | PSize    |
-			     PMinSize   | PMaxSize |
-			     PResizeInc | PAspect);
+		*supplied = (XCB_SIZE_US_POSITION_HINT | XCB_SIZE_US_SIZE_HINT |
+			     XCB_SIZE_P_POSITION_HINT  | XCB_SIZE_P_SIZE_HINT  |
+			     XCB_SIZE_P_MIN_SIZE_HINT  | XCB_SIZE_P_MAX_SIZE_HINT |
+			     XCB_SIZE_P_RESIZE_INC_HINT | XCB_SIZE_P_ASPECT_HINT);
 		if (length >= 18) /* NumPropSizeElements = 18 (ICCCM version 1) */
-		        *supplied |= (PBaseSize | PWinGravity);
+		        *supplied |= (XCB_SIZE_BASE_SIZE_HINT | XCB_SIZE_P_WIN_GRAVITY_HINT);
 		else
 		{
 		        hints->base_width  = 0;
@@ -612,21 +486,6 @@ struct xcb_wm_hints_t {
 	/* this structure may be extended in the future */
 };
 
-typedef enum {
-        XCB_WM_INPUT_HINT         = (1L << 0),
-	XCB_WM_STATE_HINT         = (1L << 1),
-	XCB_WM_ICON_PIXMAP_HINT   = (1L << 2),
-	XCB_WM_ICON_WINDOW_HINT   = (1L << 3),
-	XCB_WM_ICON_POSITION_HINT = (1L << 4),
-	XCB_WM_ICON_MASK_HINT     = (1L << 5),
-	XCB_WM_WINDOW_GROUP_HINT  = (1L << 6),
-	XCB_WM_X_URGENCY_HINT     = (1L << 8)
-} xcb_wm_t;
-
-#define XCB_WM_ALL_HINTS (XCB_WM_INPUT_HINT       | XCB_WM_STATE_HINT         | XCB_WM_ICON_PIXMAP_HINT | \
-                          XCB_WM_ICON_WINDOW_HINT | XCB_WM_ICON_POSITION_HINT | XCB_WM_ICON_MASK_HINT   | \
-                          XCB_WM_WINDOW_GROUP_HINT)
-
 xcb_wm_hints_t *
 xcb_alloc_wm_hints()
 {
@@ -669,71 +528,23 @@ xcb_wm_hints_get_window_group(xcb_wm_hints_t *hints)
         return hints->window_group;
 }
 
-
-uint8_t
-xcb_wm_hints_is_input_hint(xcb_wm_hints_t *hints)
-{
-        return (hints->flags & XCB_WM_INPUT_HINT);
-}
-
-uint8_t
-xcb_wm_hints_is_state_hint(xcb_wm_hints_t *hints)
-{
-        return (hints->flags & XCB_WM_STATE_HINT);
-}
-
-uint8_t
-xcb_wm_hints_is_icon_pixmap_hint(xcb_wm_hints_t *hints)
-{
-        return (hints->flags & XCB_WM_ICON_PIXMAP_HINT);
-}
-
-uint8_t
-xcb_wm_hints_is_icon_window_hint(xcb_wm_hints_t *hints)
-{
-        return (hints->flags & XCB_WM_ICON_WINDOW_HINT);
-}
-
-uint8_t
-xcb_wm_hints_is_icon_position_hint(xcb_wm_hints_t *hints)
-{
-        return (hints->flags & XCB_WM_ICON_POSITION_HINT);
-}
-
-uint8_t
-xcb_wm_hints_is_icon_mask_hint(xcb_wm_hints_t *hints)
-{
-        return (hints->flags & XCB_WM_ICON_MASK_HINT);
-}
-
-uint8_t
-xcb_wm_hints_is_window_group_hint(xcb_wm_hints_t *hints)
-{
-        return (hints->flags & XCB_WM_WINDOW_GROUP_HINT);
-}
-
-uint8_t
-xcb_wm_hints_is_x_urgency_hint(xcb_wm_hints_t *hints)
-{
-        return (hints->flags & XCB_WM_X_URGENCY_HINT);
-}
-
-uint8_t
-xcb_wm_hints_state_is_withdrawn(xcb_wm_hints_t *hints)
+uint32_t
+xcb_wm_hints_get_flags(xcb_wm_hints_t *hints)
 {
-        return (hints->initial_state == XCB_WM_WITHDRAWN_STATE);
+        return hints->flags;
 }
 
-uint8_t
-xcb_wm_hints_state_is_normal(xcb_wm_hints_t *hints)
+void
+xcb_wm_hints_set_flags(xcb_wm_hints_t *hints,
+                       uint32_t flags)
 {
-        return (hints->initial_state == XCB_WM_NORMAL_STATE);
+        hints->flags = flags;
 }
 
-uint8_t
-xcb_wm_hints_state_is_iconic(xcb_wm_hints_t *hints)
+uint32_t
+xcb_wm_hints_get_initial_state(xcb_wm_hints_t *hints)
 {
-        return (hints->initial_state == XCB_WM_ICONIC_STATE);
+        return hints->initial_state;
 }
 
 void
@@ -771,12 +582,6 @@ xcb_wm_hints_set_none(xcb_wm_hints_t *hints)
 }
 
 void
-xcb_wm_hints_set_urgent(xcb_wm_hints_t *hints)
-{
-        hints->flags |= XCB_WM_X_URGENCY_HINT;
-}
-
-void
 xcb_wm_hints_set_icon_pixmap(xcb_wm_hints_t *hints, xcb_pixmap_t icon_pixmap)
 {
         hints->icon_pixmap = icon_pixmap;
diff --git a/icccm/xcb_icccm.h b/icccm/xcb_icccm.h
index d7b42a9..ca73d40 100644
--- a/icccm/xcb_icccm.h
+++ b/icccm/xcb_icccm.h
@@ -90,6 +90,19 @@ void xcb_watch_wm_client_machine (xcb_property_handlers_t        *prophs,
 
 /* WM_SIZE_HINTS */
 
+typedef enum {
+	XCB_SIZE_US_POSITION_HINT = 1 << 0,
+	XCB_SIZE_US_SIZE_HINT = 1 << 1,
+	XCB_SIZE_P_POSITION_HINT = 1 << 2,
+	XCB_SIZE_P_SIZE_HINT = 1 << 3,
+	XCB_SIZE_P_MIN_SIZE_HINT = 1 << 4,
+	XCB_SIZE_P_MAX_SIZE_HINT = 1 << 5,
+	XCB_SIZE_P_RESIZE_INC_HINT = 1 << 6,
+	XCB_SIZE_P_ASPECT_HINT = 1 << 7,
+	XCB_SIZE_BASE_SIZE_HINT = 1 << 8,
+	XCB_SIZE_P_WIN_GRAVITY_HINT = 1 << 9
+} xcb_size_hints_flags_t;
+
 typedef struct xcb_size_hints_t xcb_size_hints_t;
 
 xcb_size_hints_t *xcb_alloc_size_hints   ();
@@ -122,28 +135,10 @@ void       xcb_size_hints_get_base_size  (xcb_size_hints_t *hints,
                                           int32_t          *base_height);
 uint32_t   xcb_size_hints_get_win_gravity (xcb_size_hints_t *hints);
 
-uint8_t    xcb_size_hints_is_us_position   (xcb_size_hints_t *hints);
-uint8_t    xcb_size_hints_is_us_size       (xcb_size_hints_t *hints);
-uint8_t    xcb_size_hints_is_p_position    (xcb_size_hints_t *hints);
-uint8_t    xcb_size_hints_is_p_size        (xcb_size_hints_t *hints);
-uint8_t    xcb_size_hints_is_p_min_size    (xcb_size_hints_t *hints);
-uint8_t    xcb_size_hints_is_p_max_size    (xcb_size_hints_t *hints);
-uint8_t    xcb_size_hints_is_p_resize_inc  (xcb_size_hints_t *hints);
-uint8_t    xcb_size_hints_is_p_aspect      (xcb_size_hints_t *hints);
-uint8_t    xcb_size_hints_is_p_base_size   (xcb_size_hints_t *hints);
-uint8_t    xcb_size_hints_is_p_win_gravity (xcb_size_hints_t *hints);
-
-void       xcb_size_hints_set_flag_none          (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_us_position   (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_us_size       (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_p_position    (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_p_size        (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_p_min_size    (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_p_max_size    (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_p_resize_inc  (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_p_aspect      (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_p_base_size   (xcb_size_hints_t *hints);
-void       xcb_size_hints_set_flag_p_win_gravity (xcb_size_hints_t *hints);
+uint32_t   xcb_size_hints_get_flags	  (xcb_size_hints_t *hints);
+
+void	   xcb_size_hints_set_flags	  (xcb_size_hints_t *hints,
+					   uint32_t flags);
 
 void       xcb_size_hints_set_position   (xcb_size_hints_t *hints,
                                           int               user_specified,
@@ -220,6 +215,21 @@ typedef enum {
     XCB_WM_ICONIC_STATE    = 3
 } xcb_wm_state_t;
 
+typedef enum {
+        XCB_WM_INPUT_HINT         = (1L << 0),
+	XCB_WM_STATE_HINT         = (1L << 1),
+	XCB_WM_ICON_PIXMAP_HINT   = (1L << 2),
+	XCB_WM_ICON_WINDOW_HINT   = (1L << 3),
+	XCB_WM_ICON_POSITION_HINT = (1L << 4),
+	XCB_WM_ICON_MASK_HINT     = (1L << 5),
+	XCB_WM_WINDOW_GROUP_HINT  = (1L << 6),
+	XCB_WM_X_URGENCY_HINT     = (1L << 8)
+} xcb_wm_t;
+
+#define XCB_WM_ALL_HINTS (XCB_WM_INPUT_HINT       | XCB_WM_STATE_HINT         | XCB_WM_ICON_PIXMAP_HINT | \
+                          XCB_WM_ICON_WINDOW_HINT | XCB_WM_ICON_POSITION_HINT | XCB_WM_ICON_MASK_HINT   | \
+                          XCB_WM_WINDOW_GROUP_HINT)
+
 xcb_wm_hints_t *xcb_alloc_wm_hints();
 void            xcb_free_wm_hints          (xcb_wm_hints_t *hints);
 
@@ -229,25 +239,15 @@ xcb_pixmap_t xcb_wm_hints_get_icon_mask    (xcb_wm_hints_t *hints);
 xcb_window_t xcb_wm_hints_get_icon_window  (xcb_wm_hints_t *hints);
 xcb_window_t xcb_wm_hints_get_window_group (xcb_wm_hints_t *hints);
 
-uint8_t xcb_wm_hints_is_input_hint         (xcb_wm_hints_t *hints);
-uint8_t xcb_wm_hints_is_state_hint         (xcb_wm_hints_t *hints);
-uint8_t xcb_wm_hints_is_icon_pixmap_hint   (xcb_wm_hints_t *hints);
-uint8_t xcb_wm_hints_is_icon_window_hint   (xcb_wm_hints_t *hints);
-uint8_t xcb_wm_hints_is_icon_position_hint (xcb_wm_hints_t *hints);
-uint8_t xcb_wm_hints_is_icon_mask_hint     (xcb_wm_hints_t *hints);
-uint8_t xcb_wm_hints_is_window_group_hint  (xcb_wm_hints_t *hints);
-uint8_t xcb_wm_hints_is_x_urgency_hint     (xcb_wm_hints_t *hints);
-
-uint8_t xcb_wm_hints_state_is_withdrawn (xcb_wm_hints_t *hints);
-uint8_t xcb_wm_hints_state_is_normal    (xcb_wm_hints_t *hints);
-uint8_t xcb_wm_hints_state_is_iconic    (xcb_wm_hints_t *hints);
+uint32_t xcb_wm_hints_get_flags(xcb_wm_hints_t *hints);
+void xcb_wm_hints_set_flags(xcb_wm_hints_t *hints, uint32_t flags);
+uint32_t xcb_wm_hints_get_initial_state(xcb_wm_hints_t *hints);
 
 void xcb_wm_hints_set_input        (xcb_wm_hints_t *hints, uint8_t input);
 void xcb_wm_hints_set_iconic       (xcb_wm_hints_t *hints);
 void xcb_wm_hints_set_normal       (xcb_wm_hints_t *hints);
 void xcb_wm_hints_set_withdrawn    (xcb_wm_hints_t *hints);
 void xcb_wm_hints_set_none         (xcb_wm_hints_t *hints);
-void xcb_wm_hints_set_urgent       (xcb_wm_hints_t *hints);
 void xcb_wm_hints_set_icon_pixmap  (xcb_wm_hints_t *hints, xcb_pixmap_t icon_pixmap);
 void xcb_wm_hints_set_icon_mask    (xcb_wm_hints_t *hints, xcb_pixmap_t icon_mask);
 void xcb_wm_hints_set_icon_window  (xcb_wm_hints_t *hints, xcb_window_t icon_window);
commit 604c645c51c2b8e09a90145ecb31122c7647ff37
Author: Arnaud Fontaine <arnau at debian.org>
Date:   Thu Apr 10 15:43:25 2008 +0100

    [icccm]: correctly copy the reply value according to its format

diff --git a/icccm/icccm.c b/icccm/icccm.c
index aa347a1..facdbf5 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -925,10 +925,11 @@ xcb_get_wm_protocols (xcb_connection_t *c,
 		        free(rep);
 			return 0;
 		}
-		memcpy(*list, xcb_get_property_value(rep), length);
+		memcpy(*list, xcb_get_property_value(rep), length * rep->format >> 3);
 		free(rep);
 		return 1;
 	}
+	free(rep);
 	return 0;
 }
 
commit 5b77d22ceb848856525b1176970392b952bb9173
Author: Arnaud Fontaine <arnau at debian.org>
Date:   Wed Apr 9 14:24:54 2008 +0100

    [icccm]: fix incorrect pointer usage

diff --git a/icccm/icccm.c b/icccm/icccm.c
index cf22a25..aa347a1 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -515,45 +515,46 @@ xcb_set_wm_size_hints (xcb_connection_t *c,
 	xcb_change_property(c, XCB_PROP_MODE_REPLACE, window, property, WM_SIZE_HINTS, 32, sizeof(*hints) / 4, hints);
 }
 
-int
+xcb_size_hints_t *
 xcb_get_wm_size_hints (xcb_connection_t *c,
                        xcb_window_t      window,
                        xcb_atom_t        property,
-                       xcb_size_hints_t *hints,
                        long             *supplied)
 {
         xcb_get_property_cookie_t cookie;
-	xcb_get_property_reply_t *rep;
+	xcb_get_property_reply_t  *rep;
+	xcb_size_hints_t          *hints = NULL;
+	long                      length;
 
 	cookie = xcb_get_property (c, 0, window,
 				 property, WM_SIZE_HINTS,
 				 0L, 18); /* NumPropSizeElements = 18 (ICCCM version 1) */
 	rep = xcb_get_property_reply (c, cookie, 0);
 	if (!rep)
-	        return 0;
+		return NULL;
 
+	length = xcb_get_property_value_length (rep);
 	if ((rep->type == WM_SIZE_HINTS) &&
 	    ((rep->format == 8)  ||
 	     (rep->format == 16) ||
 	     (rep->format == 32)) &&
-	    (rep->value_len >= 15)) /* OldNumPropSizeElements = 15 (pre-ICCCM) */
+	    (length >= 15)) /* OldNumPropSizeElements = 15 (pre-ICCCM) */
 	{
-                char *prop;
-	        long  length;
+		hints = xcb_alloc_size_hints();
+		if (!hints)
+		{
+		    free (rep);
+		    return NULL;
+		}
 
-		length = xcb_get_property_value_length (rep);
-		/* FIXME: in GetProp.c of xcl, one move the memory.
-		 * Should we do that too ? */
-		prop = (char *)malloc(sizeof(char)*length);
-		memcpy(prop, xcb_get_property_value (rep), length);
-		prop[length] = '\0';
-		hints = (xcb_size_hints_t *)strdup (prop);
+		memcpy (hints, (xcb_size_hints_t *) xcb_get_property_value (rep),
+			length * rep->format >> 3);
 
 		*supplied = (USPosition | USSize   |
 			     PPosition  | PSize    |
 			     PMinSize   | PMaxSize |
 			     PResizeInc | PAspect);
-		if (rep->value_len >= 18) /* NumPropSizeElements = 18 (ICCCM version 1) */
+		if (length >= 18) /* NumPropSizeElements = 18 (ICCCM version 1) */
 		        *supplied |= (PBaseSize | PWinGravity);
 		else
 		{
@@ -562,16 +563,11 @@ xcb_get_wm_size_hints (xcb_connection_t *c,
 			hints->win_gravity = 0;
 		}
 		hints->flags &= (*supplied);	/* get rid of unwanted bits */
-
-		free (rep);
-
-		return 1;
 	}
 
-	hints = NULL;
 	free (rep);
 
-	return 0;
+	return hints;
 }
 
 /* WM_NORMAL_HINTS */
@@ -592,13 +588,12 @@ xcb_set_wm_normal_hints (xcb_connection_t *c,
 	xcb_set_wm_size_hints(c, window, WM_NORMAL_HINTS, hints);
 }
 
-int
+xcb_size_hints_t *
 xcb_get_wm_normal_hints (xcb_connection_t *c,
                          xcb_window_t      window,
-                         xcb_size_hints_t *hints,
                          long             *supplied)
 {
-	return (xcb_get_wm_size_hints (c, window, WM_NORMAL_HINTS, hints, supplied));
+	return (xcb_get_wm_size_hints (c, window, WM_NORMAL_HINTS, supplied));
 }
 
 /* WM_HINTS */
@@ -638,6 +633,12 @@ xcb_alloc_wm_hints()
 	return calloc(1, sizeof(xcb_wm_hints_t));
 }
 
+void
+xcb_free_wm_hints(xcb_wm_hints_t *hints)
+{
+	free(hints);
+}
+
 uint8_t
 xcb_wm_hints_get_input(xcb_wm_hints_t *hints)
 {
@@ -826,7 +827,6 @@ xcb_get_wm_hints (xcb_connection_t *c,
 	xcb_get_property_cookie_t cookie;
 	xcb_get_property_reply_t *rep;
 	xcb_wm_hints_t           *hints;
-        char                     *prop;
 	long                      length;
 
 	cookie = xcb_get_property (c, 0, window,
@@ -836,25 +836,24 @@ xcb_get_wm_hints (xcb_connection_t *c,
 	if (!rep)
 		return NULL;
 
+	length = xcb_get_property_value_length (rep);
 	if ((rep->type != WM_HINTS) ||
-	    (rep->value_len < (XCB_NUM_WM_HINTS_ELEMENTS - 1)) ||
+	    (length < (XCB_NUM_WM_HINTS_ELEMENTS - 1)) ||
 	    (rep->format != 32))
 	{
 		free (rep);
 		return NULL;
 	}
-	hints = (xcb_wm_hints_t *)calloc (1, (unsigned)sizeof (xcb_wm_hints_t));
+	hints = xcb_alloc_wm_hints();
 	if (!hints)
 	{
 		free (rep);
 		return NULL;
 	}
 
-	length = xcb_get_property_value_length (rep);
-	prop = (char *) xcb_get_property_value (rep);
-	prop[length] = '\0';
-	hints = (xcb_wm_hints_t *)strdup (prop);
-	if (rep->value_len < XCB_NUM_WM_HINTS_ELEMENTS)
+	memcpy(hints, (xcb_size_hints_t *) xcb_get_property_value (rep),
+	       length * rep->format >> 3);
+	if (length < XCB_NUM_WM_HINTS_ELEMENTS)
 		hints->window_group = XCB_NONE;
 
 	return hints;
diff --git a/icccm/xcb_icccm.h b/icccm/xcb_icccm.h
index eafc71b..d7b42a9 100644
--- a/icccm/xcb_icccm.h
+++ b/icccm/xcb_icccm.h
@@ -190,10 +190,9 @@ void       xcb_set_wm_size_hints         (xcb_connection_t     *c,
                                           xcb_atom_t            property,
                                           xcb_size_hints_t     *hints);
 
-int        xcb_get_wm_size_hints         (xcb_connection_t     *c,
+xcb_size_hints_t  *xcb_get_wm_size_hints (xcb_connection_t     *c,
                                           xcb_window_t          window,
                                           xcb_atom_t            property,
-                                          xcb_size_hints_t     *hints,
                                           long                 *supplied);
 
 /* WM_NORMAL_HINTS */
@@ -206,10 +205,9 @@ void xcb_set_wm_normal_hints (xcb_connection_t *c,
                               xcb_window_t      window,
                               xcb_size_hints_t *hints);
 
-int  xcb_get_wm_normal_hints (xcb_connection_t *c,
-                              xcb_window_t      window,
-                              xcb_size_hints_t *hints,
-                              long             *supplied);
+xcb_size_hints_t *xcb_get_wm_normal_hints (xcb_connection_t *c,
+					   xcb_window_t	     window,
+					   long		    *supplied);
 
 /* WM_HINTS */
 
@@ -223,6 +221,7 @@ typedef enum {
 } xcb_wm_state_t;
 
 xcb_wm_hints_t *xcb_alloc_wm_hints();
+void            xcb_free_wm_hints          (xcb_wm_hints_t *hints);
 
 uint8_t      xcb_wm_hints_get_input        (xcb_wm_hints_t *hints);
 xcb_pixmap_t xcb_wm_hints_get_icon_pixmap  (xcb_wm_hints_t *hints);


More information about the xcb-commit mailing list