[Xcb-commit] 5 commits - aux

Bart Massey bart at kemper.freedesktop.org
Fri Dec 7 00:29:18 PST 2007


 aux/xcb_aux.c |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 aux/xcb_aux.h |   45 +++++++++++++++++++++++
 2 files changed, 158 insertions(+)

New commits:
commit bf3c6fd6e72267a64e981b71727c58f0c330fd1a
Author: Bart Massey <bart at cs.pdx.edu>
Date:   Fri Dec 7 00:27:52 2007 -0800

    added aux_set_line_attributes_checked

diff --git a/aux/xcb_aux.c b/aux/xcb_aux.c
index 011d9d1..f152669 100644
--- a/aux/xcb_aux.c
+++ b/aux/xcb_aux.c
@@ -302,3 +302,24 @@ xcb_aux_parse_color(char *color_name,
     *blue = b << n;
     return 1;
 }
+
+/* Drawing related functions */
+
+/* Adapted from Xlib */
+xcb_void_cookie_t
+xcb_aux_set_line_attributes_checked (xcb_connection_t *dpy,
+				     xcb_gcontext_t gc,
+				     uint16_t linewidth,
+				     int32_t linestyle,
+				     int32_t capstyle,
+				     int32_t joinstyle)
+{
+    uint32_t mask = 0;
+    xcb_params_gc_t gv;
+
+    XCB_AUX_ADD_PARAM(&mask, &gv, line_width, linewidth);
+    XCB_AUX_ADD_PARAM(&mask, &gv, line_style, linestyle);
+    XCB_AUX_ADD_PARAM(&mask, &gv, cap_style, capstyle);
+    XCB_AUX_ADD_PARAM(&mask, &gv, join_style, joinstyle);
+    return xcb_aux_change_gc_checked(dpy, gc, mask, &gv);
+}
diff --git a/aux/xcb_aux.h b/aux/xcb_aux.h
index 6144971..c376b77 100644
--- a/aux/xcb_aux.h
+++ b/aux/xcb_aux.h
@@ -180,6 +180,15 @@ int
 xcb_aux_parse_color(char *color_name,
 		    uint16_t *red,  uint16_t *green,  uint16_t *blue);
 
+xcb_void_cookie_t
+xcb_aux_set_line_attributes_checked (xcb_connection_t *dpy,
+				     xcb_gcontext_t gc,
+				     uint16_t linewidth,
+				     int32_t linestyle,
+				     int32_t capstyle,
+				     int32_t joinstyle);
+
+
 #ifdef __cplusplus
 }
 #endif
commit 15fcf943605aa29cb7b512168fdee99679fa044b
Author: Bart Massey <bart at cs.pdx.edu>
Date:   Fri Dec 7 00:24:57 2007 -0800

    added PARAM macros

diff --git a/aux/xcb_aux.h b/aux/xcb_aux.h
index 6d4d851..6144971 100644
--- a/aux/xcb_aux.h
+++ b/aux/xcb_aux.h
@@ -33,6 +33,13 @@ void           xcb_aux_sync              (xcb_connection_t *c);
 
 /* less error prone to use structs instead of value lists */
 
+#define _XCB_AUX_OFFSETOF(paramsp, param) \
+    ((void*)(&((paramsp)->param))-(void*)(paramsp))
+    
+#define XCB_AUX_ADD_PARAM(maskp, paramsp, param, value) \
+    ((*(maskp)|=1<<(_XCB_AUX_OFFSETOF((paramsp),param)/sizeof(uint32_t))), \
+     ((paramsp)->param=(value)))
+
 typedef struct {
     uint32_t back_pixmap;
     uint32_t back_pixel;
commit f3186db090406eb23792d516275b59d2d11209df
Author: Bart Massey <bart at cs.pdx.edu>
Date:   Fri Dec 7 00:22:51 2007 -0800

    xcb_aux_parse_color()

diff --git a/aux/xcb_aux.c b/aux/xcb_aux.c
index 457b96d..011d9d1 100644
--- a/aux/xcb_aux.c
+++ b/aux/xcb_aux.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <xcb/xcb.h>
 #include "xcb_aux.h"
@@ -255,3 +256,49 @@ xcb_aux_change_keyboard_control (xcb_connection_t            *c,
 	pack_list(mask, (const uint32_t *)params, value_list);
 	return xcb_change_keyboard_control( c, mask, value_list );
 }
+
+/* Color related functions */
+
+/* Return true if the given color name can be translated locally,
+   in which case load the components.  Otherwise, a lookup_color request
+   will be needed, so return false. */
+int
+xcb_aux_parse_color(char *color_name,
+		    uint16_t *red,  uint16_t *green,  uint16_t *blue)
+{
+    int n, r, g, b, i;
+    if (!color_name || *color_name != '#')
+	return 0;
+    /*
+     * Excitingly weird RGB parsing code from Xlib.
+     */
+    n = strlen (color_name);
+    color_name++;
+    n--;
+    if (n != 3 && n != 6 && n != 9 && n != 12)
+	return 0;
+    n /= 3;
+    g = b = 0;
+    do {
+	r = g;
+	g = b;
+	b = 0;
+	for (i = n; --i >= 0; ) {
+	    char c = *color_name++;
+	    b <<= 4;
+	    if (c >= '0' && c <= '9')
+		b |= c - '0';
+	    else if (c >= 'A' && c <= 'F')
+		b |= c - ('A' - 10);
+	    else if (c >= 'a' && c <= 'f')
+		b |= c - ('a' - 10);
+	    else return 0;
+	}
+    } while (*color_name != '\0');
+    n <<= 2;
+    n = 16 - n;
+    *red = r << n;
+    *green = g << n;
+    *blue = b << n;
+    return 1;
+}
diff --git a/aux/xcb_aux.h b/aux/xcb_aux.h
index 70d1ff8..6d4d851 100644
--- a/aux/xcb_aux.h
+++ b/aux/xcb_aux.h
@@ -169,6 +169,9 @@ xcb_aux_change_keyboard_control (xcb_connection_t            *c,
                                  uint32_t                     mask,
                                  const xcb_params_keyboard_t *params);
 
+int
+xcb_aux_parse_color(char *color_name,
+		    uint16_t *red,  uint16_t *green,  uint16_t *blue);
 
 #ifdef __cplusplus
 }
commit 35094b2410ce2dfa3a9cc7c454333d626fcad788
Author: Bart Massey <bart at cs.pdx.edu>
Date:   Fri Dec 7 00:20:11 2007 -0800

    added checked version of aux_change_gc function

diff --git a/aux/xcb_aux.c b/aux/xcb_aux.c
index 0be8acf..457b96d 100644
--- a/aux/xcb_aux.c
+++ b/aux/xcb_aux.c
@@ -236,6 +236,17 @@ xcb_aux_change_gc (xcb_connection_t     *c,
 }
 
 xcb_void_cookie_t
+xcb_aux_change_gc_checked (xcb_connection_t     *c,
+			   xcb_gcontext_t        gc,
+			   uint32_t              mask,
+			   const xcb_params_gc_t *params)
+{
+	uint32_t value_list[32];
+	pack_list(mask, (const uint32_t *)params, value_list);
+	return xcb_change_gc_checked( c, gc, mask, value_list );
+}
+
+xcb_void_cookie_t
 xcb_aux_change_keyboard_control (xcb_connection_t            *c,
                                  uint32_t                     mask,
                                  const xcb_params_keyboard_t *params)
diff --git a/aux/xcb_aux.h b/aux/xcb_aux.h
index dcc534e..70d1ff8 100644
--- a/aux/xcb_aux.h
+++ b/aux/xcb_aux.h
@@ -148,6 +148,11 @@ xcb_aux_change_gc (xcb_connection_t      *c,
                    uint32_t               mask,
                    const xcb_params_gc_t *params);
 
+xcb_void_cookie_t
+xcb_aux_change_gc_checked (xcb_connection_t     *c,
+			   xcb_gcontext_t        gc,
+			   uint32_t              mask,
+			   const xcb_params_gc_t *params);
 typedef struct {
     uint32_t key_click_percent;
     uint32_t bell_percent;
commit 01b43fc3c7c2815a2e70675c5fd65246b67ddcf6
Author: Bart Massey <bart at cs.pdx.edu>
Date:   Fri Dec 7 00:18:10 2007 -0800

    added checked versions of aux_create_window and aux_create_gc functions

diff --git a/aux/xcb_aux.c b/aux/xcb_aux.c
index d9a6295..0be8acf 100644
--- a/aux/xcb_aux.c
+++ b/aux/xcb_aux.c
@@ -157,6 +157,28 @@ xcb_aux_create_window (xcb_connection_t       *c,
 }
 
 xcb_void_cookie_t
+xcb_aux_create_window_checked (xcb_connection_t       *c,
+			       uint8_t                depth,
+			       xcb_window_t           wid,
+			       xcb_window_t           parent,
+			       int16_t                x,
+			       int16_t                y,
+			       uint16_t               width,
+			       uint16_t               height,
+			       uint16_t               border_width,
+			       uint16_t               _class,
+			       xcb_visualid_t         visual,
+			       uint32_t               mask,
+			       const xcb_params_cw_t *params)
+{
+	uint32_t value_list[16];
+	pack_list(mask, (const uint32_t *)params, value_list);
+	return xcb_create_window_checked(c, depth, wid, parent,
+					 x, y, width, height, border_width,
+					 _class, visual, mask, value_list);
+}
+
+xcb_void_cookie_t
 xcb_aux_change_window_attributes (xcb_connection_t      *c,
                                   xcb_window_t           window,
                                   uint32_t               mask,
@@ -191,6 +213,18 @@ xcb_aux_create_gc (xcb_connection_t      *c,
 }
 
 xcb_void_cookie_t
+xcb_aux_create_gc_checked (xcb_connection_t      *c,
+			   xcb_gcontext_t         gid,
+			   xcb_drawable_t         drawable,
+			   uint32_t               mask,
+			   const xcb_params_gc_t *params)
+{
+	uint32_t value_list[32];
+	pack_list(mask, (const uint32_t *)params, value_list);
+	return xcb_create_gc_checked( c, gid, drawable, mask, value_list);
+}
+
+xcb_void_cookie_t
 xcb_aux_change_gc (xcb_connection_t     *c,
                    xcb_gcontext_t        gc,
                    uint32_t              mask,
diff --git a/aux/xcb_aux.h b/aux/xcb_aux.h
index e07a90f..dcc534e 100644
--- a/aux/xcb_aux.h
+++ b/aux/xcb_aux.h
@@ -67,6 +67,21 @@ xcb_aux_create_window (xcb_connection_t      *c,
                        const xcb_params_cw_t *params);
 
 xcb_void_cookie_t
+xcb_aux_create_window_checked (xcb_connection_t       *c,
+			       uint8_t                depth,
+			       xcb_window_t           wid,
+			       xcb_window_t           parent,
+			       int16_t                x,
+			       int16_t                y,
+			       uint16_t               width,
+			       uint16_t               height,
+			       uint16_t               border_width,
+			       uint16_t               _class,
+			       xcb_visualid_t         visual,
+			       uint32_t               mask,
+			       const xcb_params_cw_t *params);
+
+xcb_void_cookie_t
 xcb_aux_change_window_attributes (xcb_connection_t      *c,
                                   xcb_window_t           window,
                                   uint32_t               mask,
@@ -122,6 +137,12 @@ xcb_aux_create_gc (xcb_connection_t      *c,
                    const xcb_params_gc_t *params);
 
 xcb_void_cookie_t
+xcb_aux_create_gc_checked (xcb_connection_t      *c,
+			   xcb_gcontext_t         gid,
+			   xcb_drawable_t         drawable,
+			   uint32_t               mask,
+			   const xcb_params_gc_t *params);
+xcb_void_cookie_t
 xcb_aux_change_gc (xcb_connection_t      *c,
                    xcb_gcontext_t         gc,
                    uint32_t               mask,


More information about the xcb-commit mailing list