Home | History | Annotate | Line # | Download | only in files
      1 /*
      2  * This file generated automatically from dbe.xml by c_client.py.
      3  * Edit at your peril.
      4  */
      5 
      6 #ifdef HAVE_CONFIG_H
      7 #include "config.h"
      8 #endif
      9 #include <stdlib.h>
     10 #include <string.h>
     11 #include <assert.h>
     12 #include <stddef.h>  /* for offsetof() */
     13 #include "xcbext.h"
     14 #include "dbe.h"
     15 
     16 #define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)
     17 #include "xproto.h"
     18 
     19 xcb_extension_t xcb_dbe_id = { "DOUBLE-BUFFER", 0 };
     20 
     21 void
     22 xcb_dbe_back_buffer_next (xcb_dbe_back_buffer_iterator_t *i)
     23 {
     24     --i->rem;
     25     ++i->data;
     26     i->index += sizeof(xcb_dbe_back_buffer_t);
     27 }
     28 
     29 xcb_generic_iterator_t
     30 xcb_dbe_back_buffer_end (xcb_dbe_back_buffer_iterator_t i)
     31 {
     32     xcb_generic_iterator_t ret;
     33     ret.data = i.data + i.rem;
     34     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     35     ret.rem = 0;
     36     return ret;
     37 }
     38 
     39 void
     40 xcb_dbe_swap_info_next (xcb_dbe_swap_info_iterator_t *i)
     41 {
     42     --i->rem;
     43     ++i->data;
     44     i->index += sizeof(xcb_dbe_swap_info_t);
     45 }
     46 
     47 xcb_generic_iterator_t
     48 xcb_dbe_swap_info_end (xcb_dbe_swap_info_iterator_t i)
     49 {
     50     xcb_generic_iterator_t ret;
     51     ret.data = i.data + i.rem;
     52     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     53     ret.rem = 0;
     54     return ret;
     55 }
     56 
     57 void
     58 xcb_dbe_buffer_attributes_next (xcb_dbe_buffer_attributes_iterator_t *i)
     59 {
     60     --i->rem;
     61     ++i->data;
     62     i->index += sizeof(xcb_dbe_buffer_attributes_t);
     63 }
     64 
     65 xcb_generic_iterator_t
     66 xcb_dbe_buffer_attributes_end (xcb_dbe_buffer_attributes_iterator_t i)
     67 {
     68     xcb_generic_iterator_t ret;
     69     ret.data = i.data + i.rem;
     70     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     71     ret.rem = 0;
     72     return ret;
     73 }
     74 
     75 void
     76 xcb_dbe_visual_info_next (xcb_dbe_visual_info_iterator_t *i)
     77 {
     78     --i->rem;
     79     ++i->data;
     80     i->index += sizeof(xcb_dbe_visual_info_t);
     81 }
     82 
     83 xcb_generic_iterator_t
     84 xcb_dbe_visual_info_end (xcb_dbe_visual_info_iterator_t i)
     85 {
     86     xcb_generic_iterator_t ret;
     87     ret.data = i.data + i.rem;
     88     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     89     ret.rem = 0;
     90     return ret;
     91 }
     92 
     93 int
     94 xcb_dbe_visual_infos_sizeof (const void  *_buffer)
     95 {
     96     char *xcb_tmp = (char *)_buffer;
     97     const xcb_dbe_visual_infos_t *_aux = (xcb_dbe_visual_infos_t *)_buffer;
     98     unsigned int xcb_buffer_len = 0;
     99     unsigned int xcb_block_len = 0;
    100     unsigned int xcb_pad = 0;
    101     unsigned int xcb_align_to = 0;
    102 
    103 
    104     xcb_block_len += sizeof(xcb_dbe_visual_infos_t);
    105     xcb_tmp += xcb_block_len;
    106     xcb_buffer_len += xcb_block_len;
    107     xcb_block_len = 0;
    108     /* infos */
    109     xcb_block_len += _aux->n_infos * sizeof(xcb_dbe_visual_info_t);
    110     xcb_tmp += xcb_block_len;
    111     xcb_align_to = ALIGNOF(xcb_dbe_visual_info_t);
    112     /* insert padding */
    113     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    114     xcb_buffer_len += xcb_block_len + xcb_pad;
    115     if (0 != xcb_pad) {
    116         xcb_tmp += xcb_pad;
    117         xcb_pad = 0;
    118     }
    119     xcb_block_len = 0;
    120 
    121     return xcb_buffer_len;
    122 }
    123 
    124 xcb_dbe_visual_info_t *
    125 xcb_dbe_visual_infos_infos (const xcb_dbe_visual_infos_t *R)
    126 {
    127     return (xcb_dbe_visual_info_t *) (R + 1);
    128 }
    129 
    130 int
    131 xcb_dbe_visual_infos_infos_length (const xcb_dbe_visual_infos_t *R)
    132 {
    133     return R->n_infos;
    134 }
    135 
    136 xcb_dbe_visual_info_iterator_t
    137 xcb_dbe_visual_infos_infos_iterator (const xcb_dbe_visual_infos_t *R)
    138 {
    139     xcb_dbe_visual_info_iterator_t i;
    140     i.data = (xcb_dbe_visual_info_t *) (R + 1);
    141     i.rem = R->n_infos;
    142     i.index = (char *) i.data - (char *) R;
    143     return i;
    144 }
    145 
    146 void
    147 xcb_dbe_visual_infos_next (xcb_dbe_visual_infos_iterator_t *i)
    148 {
    149     xcb_dbe_visual_infos_t *R = i->data;
    150     xcb_generic_iterator_t child;
    151     child.data = (xcb_dbe_visual_infos_t *)(((char *)R) + xcb_dbe_visual_infos_sizeof(R));
    152     i->index = (char *) child.data - (char *) i->data;
    153     --i->rem;
    154     i->data = (xcb_dbe_visual_infos_t *) child.data;
    155 }
    156 
    157 xcb_generic_iterator_t
    158 xcb_dbe_visual_infos_end (xcb_dbe_visual_infos_iterator_t i)
    159 {
    160     xcb_generic_iterator_t ret;
    161     while(i.rem > 0)
    162         xcb_dbe_visual_infos_next(&i);
    163     ret.data = i.data;
    164     ret.rem = i.rem;
    165     ret.index = i.index;
    166     return ret;
    167 }
    168 
    169 xcb_dbe_query_version_cookie_t
    170 xcb_dbe_query_version (xcb_connection_t *c,
    171                        uint8_t           major_version,
    172                        uint8_t           minor_version)
    173 {
    174     static const xcb_protocol_request_t xcb_req = {
    175         .count = 2,
    176         .ext = &xcb_dbe_id,
    177         .opcode = XCB_DBE_QUERY_VERSION,
    178         .isvoid = 0
    179     };
    180 
    181     struct iovec xcb_parts[4];
    182     xcb_dbe_query_version_cookie_t xcb_ret;
    183     xcb_dbe_query_version_request_t xcb_out;
    184 
    185     xcb_out.major_version = major_version;
    186     xcb_out.minor_version = minor_version;
    187     memset(xcb_out.pad0, 0, 2);
    188 
    189     xcb_parts[2].iov_base = (char *) &xcb_out;
    190     xcb_parts[2].iov_len = sizeof(xcb_out);
    191     xcb_parts[3].iov_base = 0;
    192     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    193 
    194     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    195     return xcb_ret;
    196 }
    197 
    198 xcb_dbe_query_version_cookie_t
    199 xcb_dbe_query_version_unchecked (xcb_connection_t *c,
    200                                  uint8_t           major_version,
    201                                  uint8_t           minor_version)
    202 {
    203     static const xcb_protocol_request_t xcb_req = {
    204         .count = 2,
    205         .ext = &xcb_dbe_id,
    206         .opcode = XCB_DBE_QUERY_VERSION,
    207         .isvoid = 0
    208     };
    209 
    210     struct iovec xcb_parts[4];
    211     xcb_dbe_query_version_cookie_t xcb_ret;
    212     xcb_dbe_query_version_request_t xcb_out;
    213 
    214     xcb_out.major_version = major_version;
    215     xcb_out.minor_version = minor_version;
    216     memset(xcb_out.pad0, 0, 2);
    217 
    218     xcb_parts[2].iov_base = (char *) &xcb_out;
    219     xcb_parts[2].iov_len = sizeof(xcb_out);
    220     xcb_parts[3].iov_base = 0;
    221     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    222 
    223     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    224     return xcb_ret;
    225 }
    226 
    227 xcb_dbe_query_version_reply_t *
    228 xcb_dbe_query_version_reply (xcb_connection_t                *c,
    229                              xcb_dbe_query_version_cookie_t   cookie  /**< */,
    230                              xcb_generic_error_t            **e)
    231 {
    232     return (xcb_dbe_query_version_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    233 }
    234 
    235 xcb_void_cookie_t
    236 xcb_dbe_allocate_back_buffer_checked (xcb_connection_t      *c,
    237                                       xcb_window_t           window,
    238                                       xcb_dbe_back_buffer_t  buffer,
    239                                       uint8_t                swap_action)
    240 {
    241     static const xcb_protocol_request_t xcb_req = {
    242         .count = 2,
    243         .ext = &xcb_dbe_id,
    244         .opcode = XCB_DBE_ALLOCATE_BACK_BUFFER,
    245         .isvoid = 1
    246     };
    247 
    248     struct iovec xcb_parts[4];
    249     xcb_void_cookie_t xcb_ret;
    250     xcb_dbe_allocate_back_buffer_request_t xcb_out;
    251 
    252     xcb_out.window = window;
    253     xcb_out.buffer = buffer;
    254     xcb_out.swap_action = swap_action;
    255     memset(xcb_out.pad0, 0, 3);
    256 
    257     xcb_parts[2].iov_base = (char *) &xcb_out;
    258     xcb_parts[2].iov_len = sizeof(xcb_out);
    259     xcb_parts[3].iov_base = 0;
    260     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    261 
    262     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    263     return xcb_ret;
    264 }
    265 
    266 xcb_void_cookie_t
    267 xcb_dbe_allocate_back_buffer (xcb_connection_t      *c,
    268                               xcb_window_t           window,
    269                               xcb_dbe_back_buffer_t  buffer,
    270                               uint8_t                swap_action)
    271 {
    272     static const xcb_protocol_request_t xcb_req = {
    273         .count = 2,
    274         .ext = &xcb_dbe_id,
    275         .opcode = XCB_DBE_ALLOCATE_BACK_BUFFER,
    276         .isvoid = 1
    277     };
    278 
    279     struct iovec xcb_parts[4];
    280     xcb_void_cookie_t xcb_ret;
    281     xcb_dbe_allocate_back_buffer_request_t xcb_out;
    282 
    283     xcb_out.window = window;
    284     xcb_out.buffer = buffer;
    285     xcb_out.swap_action = swap_action;
    286     memset(xcb_out.pad0, 0, 3);
    287 
    288     xcb_parts[2].iov_base = (char *) &xcb_out;
    289     xcb_parts[2].iov_len = sizeof(xcb_out);
    290     xcb_parts[3].iov_base = 0;
    291     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    292 
    293     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    294     return xcb_ret;
    295 }
    296 
    297 xcb_void_cookie_t
    298 xcb_dbe_deallocate_back_buffer_checked (xcb_connection_t      *c,
    299                                         xcb_dbe_back_buffer_t  buffer)
    300 {
    301     static const xcb_protocol_request_t xcb_req = {
    302         .count = 2,
    303         .ext = &xcb_dbe_id,
    304         .opcode = XCB_DBE_DEALLOCATE_BACK_BUFFER,
    305         .isvoid = 1
    306     };
    307 
    308     struct iovec xcb_parts[4];
    309     xcb_void_cookie_t xcb_ret;
    310     xcb_dbe_deallocate_back_buffer_request_t xcb_out;
    311 
    312     xcb_out.buffer = buffer;
    313 
    314     xcb_parts[2].iov_base = (char *) &xcb_out;
    315     xcb_parts[2].iov_len = sizeof(xcb_out);
    316     xcb_parts[3].iov_base = 0;
    317     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    318 
    319     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    320     return xcb_ret;
    321 }
    322 
    323 xcb_void_cookie_t
    324 xcb_dbe_deallocate_back_buffer (xcb_connection_t      *c,
    325                                 xcb_dbe_back_buffer_t  buffer)
    326 {
    327     static const xcb_protocol_request_t xcb_req = {
    328         .count = 2,
    329         .ext = &xcb_dbe_id,
    330         .opcode = XCB_DBE_DEALLOCATE_BACK_BUFFER,
    331         .isvoid = 1
    332     };
    333 
    334     struct iovec xcb_parts[4];
    335     xcb_void_cookie_t xcb_ret;
    336     xcb_dbe_deallocate_back_buffer_request_t xcb_out;
    337 
    338     xcb_out.buffer = buffer;
    339 
    340     xcb_parts[2].iov_base = (char *) &xcb_out;
    341     xcb_parts[2].iov_len = sizeof(xcb_out);
    342     xcb_parts[3].iov_base = 0;
    343     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    344 
    345     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    346     return xcb_ret;
    347 }
    348 
    349 int
    350 xcb_dbe_swap_buffers_sizeof (const void  *_buffer)
    351 {
    352     char *xcb_tmp = (char *)_buffer;
    353     const xcb_dbe_swap_buffers_request_t *_aux = (xcb_dbe_swap_buffers_request_t *)_buffer;
    354     unsigned int xcb_buffer_len = 0;
    355     unsigned int xcb_block_len = 0;
    356     unsigned int xcb_pad = 0;
    357     unsigned int xcb_align_to = 0;
    358 
    359 
    360     xcb_block_len += sizeof(xcb_dbe_swap_buffers_request_t);
    361     xcb_tmp += xcb_block_len;
    362     xcb_buffer_len += xcb_block_len;
    363     xcb_block_len = 0;
    364     /* actions */
    365     xcb_block_len += _aux->n_actions * sizeof(xcb_dbe_swap_info_t);
    366     xcb_tmp += xcb_block_len;
    367     xcb_align_to = ALIGNOF(xcb_dbe_swap_info_t);
    368     /* insert padding */
    369     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    370     xcb_buffer_len += xcb_block_len + xcb_pad;
    371     if (0 != xcb_pad) {
    372         xcb_tmp += xcb_pad;
    373         xcb_pad = 0;
    374     }
    375     xcb_block_len = 0;
    376 
    377     return xcb_buffer_len;
    378 }
    379 
    380 xcb_void_cookie_t
    381 xcb_dbe_swap_buffers_checked (xcb_connection_t          *c,
    382                               uint32_t                   n_actions,
    383                               const xcb_dbe_swap_info_t *actions)
    384 {
    385     static const xcb_protocol_request_t xcb_req = {
    386         .count = 4,
    387         .ext = &xcb_dbe_id,
    388         .opcode = XCB_DBE_SWAP_BUFFERS,
    389         .isvoid = 1
    390     };
    391 
    392     struct iovec xcb_parts[6];
    393     xcb_void_cookie_t xcb_ret;
    394     xcb_dbe_swap_buffers_request_t xcb_out;
    395 
    396     xcb_out.n_actions = n_actions;
    397 
    398     xcb_parts[2].iov_base = (char *) &xcb_out;
    399     xcb_parts[2].iov_len = sizeof(xcb_out);
    400     xcb_parts[3].iov_base = 0;
    401     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    402     /* xcb_dbe_swap_info_t actions */
    403     xcb_parts[4].iov_base = (char *) actions;
    404     xcb_parts[4].iov_len = n_actions * sizeof(xcb_dbe_swap_info_t);
    405     xcb_parts[5].iov_base = 0;
    406     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
    407 
    408     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    409     return xcb_ret;
    410 }
    411 
    412 xcb_void_cookie_t
    413 xcb_dbe_swap_buffers (xcb_connection_t          *c,
    414                       uint32_t                   n_actions,
    415                       const xcb_dbe_swap_info_t *actions)
    416 {
    417     static const xcb_protocol_request_t xcb_req = {
    418         .count = 4,
    419         .ext = &xcb_dbe_id,
    420         .opcode = XCB_DBE_SWAP_BUFFERS,
    421         .isvoid = 1
    422     };
    423 
    424     struct iovec xcb_parts[6];
    425     xcb_void_cookie_t xcb_ret;
    426     xcb_dbe_swap_buffers_request_t xcb_out;
    427 
    428     xcb_out.n_actions = n_actions;
    429 
    430     xcb_parts[2].iov_base = (char *) &xcb_out;
    431     xcb_parts[2].iov_len = sizeof(xcb_out);
    432     xcb_parts[3].iov_base = 0;
    433     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    434     /* xcb_dbe_swap_info_t actions */
    435     xcb_parts[4].iov_base = (char *) actions;
    436     xcb_parts[4].iov_len = n_actions * sizeof(xcb_dbe_swap_info_t);
    437     xcb_parts[5].iov_base = 0;
    438     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
    439 
    440     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    441     return xcb_ret;
    442 }
    443 
    444 xcb_dbe_swap_info_t *
    445 xcb_dbe_swap_buffers_actions (const xcb_dbe_swap_buffers_request_t *R)
    446 {
    447     return (xcb_dbe_swap_info_t *) (R + 1);
    448 }
    449 
    450 int
    451 xcb_dbe_swap_buffers_actions_length (const xcb_dbe_swap_buffers_request_t *R)
    452 {
    453     return R->n_actions;
    454 }
    455 
    456 xcb_dbe_swap_info_iterator_t
    457 xcb_dbe_swap_buffers_actions_iterator (const xcb_dbe_swap_buffers_request_t *R)
    458 {
    459     xcb_dbe_swap_info_iterator_t i;
    460     i.data = (xcb_dbe_swap_info_t *) (R + 1);
    461     i.rem = R->n_actions;
    462     i.index = (char *) i.data - (char *) R;
    463     return i;
    464 }
    465 
    466 xcb_void_cookie_t
    467 xcb_dbe_begin_idiom_checked (xcb_connection_t *c)
    468 {
    469     static const xcb_protocol_request_t xcb_req = {
    470         .count = 2,
    471         .ext = &xcb_dbe_id,
    472         .opcode = XCB_DBE_BEGIN_IDIOM,
    473         .isvoid = 1
    474     };
    475 
    476     struct iovec xcb_parts[4];
    477     xcb_void_cookie_t xcb_ret;
    478     xcb_dbe_begin_idiom_request_t xcb_out;
    479 
    480 
    481     xcb_parts[2].iov_base = (char *) &xcb_out;
    482     xcb_parts[2].iov_len = sizeof(xcb_out);
    483     xcb_parts[3].iov_base = 0;
    484     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    485 
    486     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    487     return xcb_ret;
    488 }
    489 
    490 xcb_void_cookie_t
    491 xcb_dbe_begin_idiom (xcb_connection_t *c)
    492 {
    493     static const xcb_protocol_request_t xcb_req = {
    494         .count = 2,
    495         .ext = &xcb_dbe_id,
    496         .opcode = XCB_DBE_BEGIN_IDIOM,
    497         .isvoid = 1
    498     };
    499 
    500     struct iovec xcb_parts[4];
    501     xcb_void_cookie_t xcb_ret;
    502     xcb_dbe_begin_idiom_request_t xcb_out;
    503 
    504 
    505     xcb_parts[2].iov_base = (char *) &xcb_out;
    506     xcb_parts[2].iov_len = sizeof(xcb_out);
    507     xcb_parts[3].iov_base = 0;
    508     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    509 
    510     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    511     return xcb_ret;
    512 }
    513 
    514 xcb_void_cookie_t
    515 xcb_dbe_end_idiom_checked (xcb_connection_t *c)
    516 {
    517     static const xcb_protocol_request_t xcb_req = {
    518         .count = 2,
    519         .ext = &xcb_dbe_id,
    520         .opcode = XCB_DBE_END_IDIOM,
    521         .isvoid = 1
    522     };
    523 
    524     struct iovec xcb_parts[4];
    525     xcb_void_cookie_t xcb_ret;
    526     xcb_dbe_end_idiom_request_t xcb_out;
    527 
    528 
    529     xcb_parts[2].iov_base = (char *) &xcb_out;
    530     xcb_parts[2].iov_len = sizeof(xcb_out);
    531     xcb_parts[3].iov_base = 0;
    532     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    533 
    534     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    535     return xcb_ret;
    536 }
    537 
    538 xcb_void_cookie_t
    539 xcb_dbe_end_idiom (xcb_connection_t *c)
    540 {
    541     static const xcb_protocol_request_t xcb_req = {
    542         .count = 2,
    543         .ext = &xcb_dbe_id,
    544         .opcode = XCB_DBE_END_IDIOM,
    545         .isvoid = 1
    546     };
    547 
    548     struct iovec xcb_parts[4];
    549     xcb_void_cookie_t xcb_ret;
    550     xcb_dbe_end_idiom_request_t xcb_out;
    551 
    552 
    553     xcb_parts[2].iov_base = (char *) &xcb_out;
    554     xcb_parts[2].iov_len = sizeof(xcb_out);
    555     xcb_parts[3].iov_base = 0;
    556     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    557 
    558     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    559     return xcb_ret;
    560 }
    561 
    562 int
    563 xcb_dbe_get_visual_info_sizeof (const void  *_buffer)
    564 {
    565     char *xcb_tmp = (char *)_buffer;
    566     const xcb_dbe_get_visual_info_request_t *_aux = (xcb_dbe_get_visual_info_request_t *)_buffer;
    567     unsigned int xcb_buffer_len = 0;
    568     unsigned int xcb_block_len = 0;
    569     unsigned int xcb_pad = 0;
    570     unsigned int xcb_align_to = 0;
    571 
    572 
    573     xcb_block_len += sizeof(xcb_dbe_get_visual_info_request_t);
    574     xcb_tmp += xcb_block_len;
    575     xcb_buffer_len += xcb_block_len;
    576     xcb_block_len = 0;
    577     /* drawables */
    578     xcb_block_len += _aux->n_drawables * sizeof(xcb_drawable_t);
    579     xcb_tmp += xcb_block_len;
    580     xcb_align_to = ALIGNOF(xcb_drawable_t);
    581     /* insert padding */
    582     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    583     xcb_buffer_len += xcb_block_len + xcb_pad;
    584     if (0 != xcb_pad) {
    585         xcb_tmp += xcb_pad;
    586         xcb_pad = 0;
    587     }
    588     xcb_block_len = 0;
    589 
    590     return xcb_buffer_len;
    591 }
    592 
    593 xcb_dbe_get_visual_info_cookie_t
    594 xcb_dbe_get_visual_info (xcb_connection_t     *c,
    595                          uint32_t              n_drawables,
    596                          const xcb_drawable_t *drawables)
    597 {
    598     static const xcb_protocol_request_t xcb_req = {
    599         .count = 4,
    600         .ext = &xcb_dbe_id,
    601         .opcode = XCB_DBE_GET_VISUAL_INFO,
    602         .isvoid = 0
    603     };
    604 
    605     struct iovec xcb_parts[6];
    606     xcb_dbe_get_visual_info_cookie_t xcb_ret;
    607     xcb_dbe_get_visual_info_request_t xcb_out;
    608 
    609     xcb_out.n_drawables = n_drawables;
    610 
    611     xcb_parts[2].iov_base = (char *) &xcb_out;
    612     xcb_parts[2].iov_len = sizeof(xcb_out);
    613     xcb_parts[3].iov_base = 0;
    614     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    615     /* xcb_drawable_t drawables */
    616     xcb_parts[4].iov_base = (char *) drawables;
    617     xcb_parts[4].iov_len = n_drawables * sizeof(xcb_visualid_t);
    618     xcb_parts[5].iov_base = 0;
    619     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
    620 
    621     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    622     return xcb_ret;
    623 }
    624 
    625 xcb_dbe_get_visual_info_cookie_t
    626 xcb_dbe_get_visual_info_unchecked (xcb_connection_t     *c,
    627                                    uint32_t              n_drawables,
    628                                    const xcb_drawable_t *drawables)
    629 {
    630     static const xcb_protocol_request_t xcb_req = {
    631         .count = 4,
    632         .ext = &xcb_dbe_id,
    633         .opcode = XCB_DBE_GET_VISUAL_INFO,
    634         .isvoid = 0
    635     };
    636 
    637     struct iovec xcb_parts[6];
    638     xcb_dbe_get_visual_info_cookie_t xcb_ret;
    639     xcb_dbe_get_visual_info_request_t xcb_out;
    640 
    641     xcb_out.n_drawables = n_drawables;
    642 
    643     xcb_parts[2].iov_base = (char *) &xcb_out;
    644     xcb_parts[2].iov_len = sizeof(xcb_out);
    645     xcb_parts[3].iov_base = 0;
    646     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    647     /* xcb_drawable_t drawables */
    648     xcb_parts[4].iov_base = (char *) drawables;
    649     xcb_parts[4].iov_len = n_drawables * sizeof(xcb_visualid_t);
    650     xcb_parts[5].iov_base = 0;
    651     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
    652 
    653     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    654     return xcb_ret;
    655 }
    656 
    657 int
    658 xcb_dbe_get_visual_info_supported_visuals_length (const xcb_dbe_get_visual_info_reply_t *R)
    659 {
    660     return R->n_supported_visuals;
    661 }
    662 
    663 xcb_dbe_visual_infos_iterator_t
    664 xcb_dbe_get_visual_info_supported_visuals_iterator (const xcb_dbe_get_visual_info_reply_t *R)
    665 {
    666     xcb_dbe_visual_infos_iterator_t i;
    667     i.data = (xcb_dbe_visual_infos_t *) (R + 1);
    668     i.rem = R->n_supported_visuals;
    669     i.index = (char *) i.data - (char *) R;
    670     return i;
    671 }
    672 
    673 xcb_dbe_get_visual_info_reply_t *
    674 xcb_dbe_get_visual_info_reply (xcb_connection_t                  *c,
    675                                xcb_dbe_get_visual_info_cookie_t   cookie  /**< */,
    676                                xcb_generic_error_t              **e)
    677 {
    678     return (xcb_dbe_get_visual_info_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    679 }
    680 
    681 xcb_dbe_get_back_buffer_attributes_cookie_t
    682 xcb_dbe_get_back_buffer_attributes (xcb_connection_t      *c,
    683                                     xcb_dbe_back_buffer_t  buffer)
    684 {
    685     static const xcb_protocol_request_t xcb_req = {
    686         .count = 2,
    687         .ext = &xcb_dbe_id,
    688         .opcode = XCB_DBE_GET_BACK_BUFFER_ATTRIBUTES,
    689         .isvoid = 0
    690     };
    691 
    692     struct iovec xcb_parts[4];
    693     xcb_dbe_get_back_buffer_attributes_cookie_t xcb_ret;
    694     xcb_dbe_get_back_buffer_attributes_request_t xcb_out;
    695 
    696     xcb_out.buffer = buffer;
    697 
    698     xcb_parts[2].iov_base = (char *) &xcb_out;
    699     xcb_parts[2].iov_len = sizeof(xcb_out);
    700     xcb_parts[3].iov_base = 0;
    701     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    702 
    703     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    704     return xcb_ret;
    705 }
    706 
    707 xcb_dbe_get_back_buffer_attributes_cookie_t
    708 xcb_dbe_get_back_buffer_attributes_unchecked (xcb_connection_t      *c,
    709                                               xcb_dbe_back_buffer_t  buffer)
    710 {
    711     static const xcb_protocol_request_t xcb_req = {
    712         .count = 2,
    713         .ext = &xcb_dbe_id,
    714         .opcode = XCB_DBE_GET_BACK_BUFFER_ATTRIBUTES,
    715         .isvoid = 0
    716     };
    717 
    718     struct iovec xcb_parts[4];
    719     xcb_dbe_get_back_buffer_attributes_cookie_t xcb_ret;
    720     xcb_dbe_get_back_buffer_attributes_request_t xcb_out;
    721 
    722     xcb_out.buffer = buffer;
    723 
    724     xcb_parts[2].iov_base = (char *) &xcb_out;
    725     xcb_parts[2].iov_len = sizeof(xcb_out);
    726     xcb_parts[3].iov_base = 0;
    727     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    728 
    729     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    730     return xcb_ret;
    731 }
    732 
    733 xcb_dbe_get_back_buffer_attributes_reply_t *
    734 xcb_dbe_get_back_buffer_attributes_reply (xcb_connection_t                             *c,
    735                                           xcb_dbe_get_back_buffer_attributes_cookie_t   cookie  /**< */,
    736                                           xcb_generic_error_t                         **e)
    737 {
    738     return (xcb_dbe_get_back_buffer_attributes_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    739 }
    740 
    741