[Xcb] Whatever happened to the XCloseDisplay() hooks?

Carl Worth cworth at cworth.org
Thu Oct 15 11:57:36 PDT 2009

Excerpts from Barton C Massey's message of Wed Oct 14 14:19:47 -0700 2009:
> Cairo is built with a really simple model: if you opened it,
> you close it.  I don't think I get why having both XCB and
> xcb_render_util be built on this same model is somehow a
> design defect.

Yes, but in cairo we did end up adding lifetime-management callbacks
for one specific case: cairo_set_user_data, (and other _set_user_data

What that looks like is this:

     * cairo_destroy_func_t:                                                        
     * data: The data element being destroyed.                                     
     * cairo_destroy_func_t the type of function which is called when a            
     * data element is destroyed. It is passed the pointer to the data              
     * element and should free any memory and resources allocated for it.           
    typedef void (*cairo_destroy_func_t) (void *data);

     * cairo_user_data_key_t:                                                       
     * unused: not used; ignore.                                                   
     * cairo_user_data_key_t is used for attaching user data to cairo              
     * data structures.  The actual contents of the struct is never used,           
     * and there is no need to initialize the object; only the unique               
     * address of a cairo_data_key_t object is used.  Typically, you               
     * would just use the address of a static cairo_data_key_t object.
    typedef struct _cairo_user_data_key {
        int unused;
    } cairo_user_data_key_t;

    cairo_set_user_data (cairo_t                     *cr,
                         const cairo_user_data_key_t *key,
                         void                        *user_data,
                         cairo_destroy_func_t         destroy);

I fought the inclusion of the destroy callback for a long time on a
"callbacks are evil basis", but I eventually relented.

And pretty much all the authors of bindings for cairo have found this
essential. They end up needing to make little "wrapper objects" around
cairo's native objects and need a tight association between the two
with synchronized lifetime management.

I'm actually surprised you haven't had binding authors require the
same thing for XCB yet. (Or maybe it's different since you instead
generate their bindings in their language rather than wrapping the C

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/xcb/attachments/20091015/ed2eada5/attachment.pgp 

More information about the Xcb mailing list