xref: /minix3/external/mit/xorg/lib/libxcb/files/present.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1 /*
2  * This file generated automatically from present.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 "present.h"
15 
16 #define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)
17 #include "xproto.h"
18 #include "randr.h"
19 #include "xfixes.h"
20 #include "sync.h"
21 
22 xcb_extension_t xcb_present_id = { "Present", 0 };
23 
24 void
xcb_present_notify_next(xcb_present_notify_iterator_t * i)25 xcb_present_notify_next (xcb_present_notify_iterator_t *i  /**< */)
26 {
27     --i->rem;
28     ++i->data;
29     i->index += sizeof(xcb_present_notify_t);
30 }
31 
32 xcb_generic_iterator_t
xcb_present_notify_end(xcb_present_notify_iterator_t i)33 xcb_present_notify_end (xcb_present_notify_iterator_t i  /**< */)
34 {
35     xcb_generic_iterator_t ret;
36     ret.data = i.data + i.rem;
37     ret.index = i.index + ((char *) ret.data - (char *) i.data);
38     ret.rem = 0;
39     return ret;
40 }
41 
42 xcb_present_query_version_cookie_t
xcb_present_query_version(xcb_connection_t * c,uint32_t major_version,uint32_t minor_version)43 xcb_present_query_version (xcb_connection_t *c  /**< */,
44                            uint32_t          major_version  /**< */,
45                            uint32_t          minor_version  /**< */)
46 {
47     static const xcb_protocol_request_t xcb_req = {
48         /* count */ 2,
49         /* ext */ &xcb_present_id,
50         /* opcode */ XCB_PRESENT_QUERY_VERSION,
51         /* isvoid */ 0
52     };
53 
54     struct iovec xcb_parts[4];
55     xcb_present_query_version_cookie_t xcb_ret;
56     xcb_present_query_version_request_t xcb_out;
57 
58     xcb_out.major_version = major_version;
59     xcb_out.minor_version = minor_version;
60 
61     xcb_parts[2].iov_base = (char *) &xcb_out;
62     xcb_parts[2].iov_len = sizeof(xcb_out);
63     xcb_parts[3].iov_base = 0;
64     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
65 
66     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
67     return xcb_ret;
68 }
69 
70 xcb_present_query_version_cookie_t
xcb_present_query_version_unchecked(xcb_connection_t * c,uint32_t major_version,uint32_t minor_version)71 xcb_present_query_version_unchecked (xcb_connection_t *c  /**< */,
72                                      uint32_t          major_version  /**< */,
73                                      uint32_t          minor_version  /**< */)
74 {
75     static const xcb_protocol_request_t xcb_req = {
76         /* count */ 2,
77         /* ext */ &xcb_present_id,
78         /* opcode */ XCB_PRESENT_QUERY_VERSION,
79         /* isvoid */ 0
80     };
81 
82     struct iovec xcb_parts[4];
83     xcb_present_query_version_cookie_t xcb_ret;
84     xcb_present_query_version_request_t xcb_out;
85 
86     xcb_out.major_version = major_version;
87     xcb_out.minor_version = minor_version;
88 
89     xcb_parts[2].iov_base = (char *) &xcb_out;
90     xcb_parts[2].iov_len = sizeof(xcb_out);
91     xcb_parts[3].iov_base = 0;
92     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
93 
94     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
95     return xcb_ret;
96 }
97 
98 xcb_present_query_version_reply_t *
xcb_present_query_version_reply(xcb_connection_t * c,xcb_present_query_version_cookie_t cookie,xcb_generic_error_t ** e)99 xcb_present_query_version_reply (xcb_connection_t                    *c  /**< */,
100                                  xcb_present_query_version_cookie_t   cookie  /**< */,
101                                  xcb_generic_error_t                **e  /**< */)
102 {
103     return (xcb_present_query_version_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
104 }
105 
106 int
xcb_present_pixmap_sizeof(const void * _buffer,uint32_t notifies_len)107 xcb_present_pixmap_sizeof (const void  *_buffer  /**< */,
108                            uint32_t     notifies_len  /**< */)
109 {
110     char *xcb_tmp = (char *)_buffer;
111     unsigned int xcb_buffer_len = 0;
112     unsigned int xcb_block_len = 0;
113     unsigned int xcb_pad = 0;
114     unsigned int xcb_align_to = 0;
115 
116 
117     xcb_block_len += sizeof(xcb_present_pixmap_request_t);
118     xcb_tmp += xcb_block_len;
119     xcb_buffer_len += xcb_block_len;
120     xcb_block_len = 0;
121     /* notifies */
122     xcb_block_len += notifies_len * sizeof(xcb_present_notify_t);
123     xcb_tmp += xcb_block_len;
124     xcb_align_to = ALIGNOF(xcb_present_notify_t);
125     /* insert padding */
126     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
127     xcb_buffer_len += xcb_block_len + xcb_pad;
128     if (0 != xcb_pad) {
129         xcb_tmp += xcb_pad;
130         xcb_pad = 0;
131     }
132     xcb_block_len = 0;
133 
134     return xcb_buffer_len;
135 }
136 
137 xcb_void_cookie_t
xcb_present_pixmap_checked(xcb_connection_t * c,xcb_window_t window,xcb_pixmap_t pixmap,uint32_t serial,xcb_xfixes_region_t valid,xcb_xfixes_region_t update,int16_t x_off,int16_t y_off,xcb_randr_crtc_t target_crtc,xcb_sync_fence_t wait_fence,xcb_sync_fence_t idle_fence,uint32_t options,uint64_t target_msc,uint64_t divisor,uint64_t remainder,uint32_t notifies_len,const xcb_present_notify_t * notifies)138 xcb_present_pixmap_checked (xcb_connection_t           *c  /**< */,
139                             xcb_window_t                window  /**< */,
140                             xcb_pixmap_t                pixmap  /**< */,
141                             uint32_t                    serial  /**< */,
142                             xcb_xfixes_region_t         valid  /**< */,
143                             xcb_xfixes_region_t         update  /**< */,
144                             int16_t                     x_off  /**< */,
145                             int16_t                     y_off  /**< */,
146                             xcb_randr_crtc_t            target_crtc  /**< */,
147                             xcb_sync_fence_t            wait_fence  /**< */,
148                             xcb_sync_fence_t            idle_fence  /**< */,
149                             uint32_t                    options  /**< */,
150                             uint64_t                    target_msc  /**< */,
151                             uint64_t                    divisor  /**< */,
152                             uint64_t                    remainder  /**< */,
153                             uint32_t                    notifies_len  /**< */,
154                             const xcb_present_notify_t *notifies  /**< */)
155 {
156     static const xcb_protocol_request_t xcb_req = {
157         /* count */ 4,
158         /* ext */ &xcb_present_id,
159         /* opcode */ XCB_PRESENT_PIXMAP,
160         /* isvoid */ 1
161     };
162 
163     struct iovec xcb_parts[6];
164     xcb_void_cookie_t xcb_ret;
165     xcb_present_pixmap_request_t xcb_out;
166 
167     xcb_out.window = window;
168     xcb_out.pixmap = pixmap;
169     xcb_out.serial = serial;
170     xcb_out.valid = valid;
171     xcb_out.update = update;
172     xcb_out.x_off = x_off;
173     xcb_out.y_off = y_off;
174     xcb_out.target_crtc = target_crtc;
175     xcb_out.wait_fence = wait_fence;
176     xcb_out.idle_fence = idle_fence;
177     xcb_out.options = options;
178     memset(xcb_out.pad0, 0, 4);
179     xcb_out.target_msc = target_msc;
180     xcb_out.divisor = divisor;
181     xcb_out.remainder = remainder;
182 
183     xcb_parts[2].iov_base = (char *) &xcb_out;
184     xcb_parts[2].iov_len = sizeof(xcb_out);
185     xcb_parts[3].iov_base = 0;
186     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
187     /* xcb_present_notify_t notifies */
188     xcb_parts[4].iov_base = (char *) notifies;
189     xcb_parts[4].iov_len = notifies_len * sizeof(xcb_present_notify_t);
190     xcb_parts[5].iov_base = 0;
191     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
192 
193     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
194     return xcb_ret;
195 }
196 
197 xcb_void_cookie_t
xcb_present_pixmap(xcb_connection_t * c,xcb_window_t window,xcb_pixmap_t pixmap,uint32_t serial,xcb_xfixes_region_t valid,xcb_xfixes_region_t update,int16_t x_off,int16_t y_off,xcb_randr_crtc_t target_crtc,xcb_sync_fence_t wait_fence,xcb_sync_fence_t idle_fence,uint32_t options,uint64_t target_msc,uint64_t divisor,uint64_t remainder,uint32_t notifies_len,const xcb_present_notify_t * notifies)198 xcb_present_pixmap (xcb_connection_t           *c  /**< */,
199                     xcb_window_t                window  /**< */,
200                     xcb_pixmap_t                pixmap  /**< */,
201                     uint32_t                    serial  /**< */,
202                     xcb_xfixes_region_t         valid  /**< */,
203                     xcb_xfixes_region_t         update  /**< */,
204                     int16_t                     x_off  /**< */,
205                     int16_t                     y_off  /**< */,
206                     xcb_randr_crtc_t            target_crtc  /**< */,
207                     xcb_sync_fence_t            wait_fence  /**< */,
208                     xcb_sync_fence_t            idle_fence  /**< */,
209                     uint32_t                    options  /**< */,
210                     uint64_t                    target_msc  /**< */,
211                     uint64_t                    divisor  /**< */,
212                     uint64_t                    remainder  /**< */,
213                     uint32_t                    notifies_len  /**< */,
214                     const xcb_present_notify_t *notifies  /**< */)
215 {
216     static const xcb_protocol_request_t xcb_req = {
217         /* count */ 4,
218         /* ext */ &xcb_present_id,
219         /* opcode */ XCB_PRESENT_PIXMAP,
220         /* isvoid */ 1
221     };
222 
223     struct iovec xcb_parts[6];
224     xcb_void_cookie_t xcb_ret;
225     xcb_present_pixmap_request_t xcb_out;
226 
227     xcb_out.window = window;
228     xcb_out.pixmap = pixmap;
229     xcb_out.serial = serial;
230     xcb_out.valid = valid;
231     xcb_out.update = update;
232     xcb_out.x_off = x_off;
233     xcb_out.y_off = y_off;
234     xcb_out.target_crtc = target_crtc;
235     xcb_out.wait_fence = wait_fence;
236     xcb_out.idle_fence = idle_fence;
237     xcb_out.options = options;
238     memset(xcb_out.pad0, 0, 4);
239     xcb_out.target_msc = target_msc;
240     xcb_out.divisor = divisor;
241     xcb_out.remainder = remainder;
242 
243     xcb_parts[2].iov_base = (char *) &xcb_out;
244     xcb_parts[2].iov_len = sizeof(xcb_out);
245     xcb_parts[3].iov_base = 0;
246     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
247     /* xcb_present_notify_t notifies */
248     xcb_parts[4].iov_base = (char *) notifies;
249     xcb_parts[4].iov_len = notifies_len * sizeof(xcb_present_notify_t);
250     xcb_parts[5].iov_base = 0;
251     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
252 
253     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
254     return xcb_ret;
255 }
256 
257 xcb_void_cookie_t
xcb_present_notify_msc_checked(xcb_connection_t * c,xcb_window_t window,uint32_t serial,uint64_t target_msc,uint64_t divisor,uint64_t remainder)258 xcb_present_notify_msc_checked (xcb_connection_t *c  /**< */,
259                                 xcb_window_t      window  /**< */,
260                                 uint32_t          serial  /**< */,
261                                 uint64_t          target_msc  /**< */,
262                                 uint64_t          divisor  /**< */,
263                                 uint64_t          remainder  /**< */)
264 {
265     static const xcb_protocol_request_t xcb_req = {
266         /* count */ 2,
267         /* ext */ &xcb_present_id,
268         /* opcode */ XCB_PRESENT_NOTIFY_MSC,
269         /* isvoid */ 1
270     };
271 
272     struct iovec xcb_parts[4];
273     xcb_void_cookie_t xcb_ret;
274     xcb_present_notify_msc_request_t xcb_out;
275 
276     xcb_out.window = window;
277     xcb_out.serial = serial;
278     memset(xcb_out.pad0, 0, 4);
279     xcb_out.target_msc = target_msc;
280     xcb_out.divisor = divisor;
281     xcb_out.remainder = remainder;
282 
283     xcb_parts[2].iov_base = (char *) &xcb_out;
284     xcb_parts[2].iov_len = sizeof(xcb_out);
285     xcb_parts[3].iov_base = 0;
286     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
287 
288     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
289     return xcb_ret;
290 }
291 
292 xcb_void_cookie_t
xcb_present_notify_msc(xcb_connection_t * c,xcb_window_t window,uint32_t serial,uint64_t target_msc,uint64_t divisor,uint64_t remainder)293 xcb_present_notify_msc (xcb_connection_t *c  /**< */,
294                         xcb_window_t      window  /**< */,
295                         uint32_t          serial  /**< */,
296                         uint64_t          target_msc  /**< */,
297                         uint64_t          divisor  /**< */,
298                         uint64_t          remainder  /**< */)
299 {
300     static const xcb_protocol_request_t xcb_req = {
301         /* count */ 2,
302         /* ext */ &xcb_present_id,
303         /* opcode */ XCB_PRESENT_NOTIFY_MSC,
304         /* isvoid */ 1
305     };
306 
307     struct iovec xcb_parts[4];
308     xcb_void_cookie_t xcb_ret;
309     xcb_present_notify_msc_request_t xcb_out;
310 
311     xcb_out.window = window;
312     xcb_out.serial = serial;
313     memset(xcb_out.pad0, 0, 4);
314     xcb_out.target_msc = target_msc;
315     xcb_out.divisor = divisor;
316     xcb_out.remainder = remainder;
317 
318     xcb_parts[2].iov_base = (char *) &xcb_out;
319     xcb_parts[2].iov_len = sizeof(xcb_out);
320     xcb_parts[3].iov_base = 0;
321     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
322 
323     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
324     return xcb_ret;
325 }
326 
327 void
xcb_present_event_next(xcb_present_event_iterator_t * i)328 xcb_present_event_next (xcb_present_event_iterator_t *i  /**< */)
329 {
330     --i->rem;
331     ++i->data;
332     i->index += sizeof(xcb_present_event_t);
333 }
334 
335 xcb_generic_iterator_t
xcb_present_event_end(xcb_present_event_iterator_t i)336 xcb_present_event_end (xcb_present_event_iterator_t i  /**< */)
337 {
338     xcb_generic_iterator_t ret;
339     ret.data = i.data + i.rem;
340     ret.index = i.index + ((char *) ret.data - (char *) i.data);
341     ret.rem = 0;
342     return ret;
343 }
344 
345 xcb_void_cookie_t
xcb_present_select_input_checked(xcb_connection_t * c,xcb_present_event_t eid,xcb_window_t window,uint32_t event_mask)346 xcb_present_select_input_checked (xcb_connection_t    *c  /**< */,
347                                   xcb_present_event_t  eid  /**< */,
348                                   xcb_window_t         window  /**< */,
349                                   uint32_t             event_mask  /**< */)
350 {
351     static const xcb_protocol_request_t xcb_req = {
352         /* count */ 2,
353         /* ext */ &xcb_present_id,
354         /* opcode */ XCB_PRESENT_SELECT_INPUT,
355         /* isvoid */ 1
356     };
357 
358     struct iovec xcb_parts[4];
359     xcb_void_cookie_t xcb_ret;
360     xcb_present_select_input_request_t xcb_out;
361 
362     xcb_out.eid = eid;
363     xcb_out.window = window;
364     xcb_out.event_mask = event_mask;
365 
366     xcb_parts[2].iov_base = (char *) &xcb_out;
367     xcb_parts[2].iov_len = sizeof(xcb_out);
368     xcb_parts[3].iov_base = 0;
369     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
370 
371     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
372     return xcb_ret;
373 }
374 
375 xcb_void_cookie_t
xcb_present_select_input(xcb_connection_t * c,xcb_present_event_t eid,xcb_window_t window,uint32_t event_mask)376 xcb_present_select_input (xcb_connection_t    *c  /**< */,
377                           xcb_present_event_t  eid  /**< */,
378                           xcb_window_t         window  /**< */,
379                           uint32_t             event_mask  /**< */)
380 {
381     static const xcb_protocol_request_t xcb_req = {
382         /* count */ 2,
383         /* ext */ &xcb_present_id,
384         /* opcode */ XCB_PRESENT_SELECT_INPUT,
385         /* isvoid */ 1
386     };
387 
388     struct iovec xcb_parts[4];
389     xcb_void_cookie_t xcb_ret;
390     xcb_present_select_input_request_t xcb_out;
391 
392     xcb_out.eid = eid;
393     xcb_out.window = window;
394     xcb_out.event_mask = event_mask;
395 
396     xcb_parts[2].iov_base = (char *) &xcb_out;
397     xcb_parts[2].iov_len = sizeof(xcb_out);
398     xcb_parts[3].iov_base = 0;
399     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
400 
401     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
402     return xcb_ret;
403 }
404 
405 xcb_present_query_capabilities_cookie_t
xcb_present_query_capabilities(xcb_connection_t * c,uint32_t target)406 xcb_present_query_capabilities (xcb_connection_t *c  /**< */,
407                                 uint32_t          target  /**< */)
408 {
409     static const xcb_protocol_request_t xcb_req = {
410         /* count */ 2,
411         /* ext */ &xcb_present_id,
412         /* opcode */ XCB_PRESENT_QUERY_CAPABILITIES,
413         /* isvoid */ 0
414     };
415 
416     struct iovec xcb_parts[4];
417     xcb_present_query_capabilities_cookie_t xcb_ret;
418     xcb_present_query_capabilities_request_t xcb_out;
419 
420     xcb_out.target = target;
421 
422     xcb_parts[2].iov_base = (char *) &xcb_out;
423     xcb_parts[2].iov_len = sizeof(xcb_out);
424     xcb_parts[3].iov_base = 0;
425     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
426 
427     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
428     return xcb_ret;
429 }
430 
431 xcb_present_query_capabilities_cookie_t
xcb_present_query_capabilities_unchecked(xcb_connection_t * c,uint32_t target)432 xcb_present_query_capabilities_unchecked (xcb_connection_t *c  /**< */,
433                                           uint32_t          target  /**< */)
434 {
435     static const xcb_protocol_request_t xcb_req = {
436         /* count */ 2,
437         /* ext */ &xcb_present_id,
438         /* opcode */ XCB_PRESENT_QUERY_CAPABILITIES,
439         /* isvoid */ 0
440     };
441 
442     struct iovec xcb_parts[4];
443     xcb_present_query_capabilities_cookie_t xcb_ret;
444     xcb_present_query_capabilities_request_t xcb_out;
445 
446     xcb_out.target = target;
447 
448     xcb_parts[2].iov_base = (char *) &xcb_out;
449     xcb_parts[2].iov_len = sizeof(xcb_out);
450     xcb_parts[3].iov_base = 0;
451     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
452 
453     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
454     return xcb_ret;
455 }
456 
457 xcb_present_query_capabilities_reply_t *
xcb_present_query_capabilities_reply(xcb_connection_t * c,xcb_present_query_capabilities_cookie_t cookie,xcb_generic_error_t ** e)458 xcb_present_query_capabilities_reply (xcb_connection_t                         *c  /**< */,
459                                       xcb_present_query_capabilities_cookie_t   cookie  /**< */,
460                                       xcb_generic_error_t                     **e  /**< */)
461 {
462     return (xcb_present_query_capabilities_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
463 }
464 
465 int
xcb_present_redirect_notify_sizeof(const void * _buffer,uint32_t notifies_len)466 xcb_present_redirect_notify_sizeof (const void  *_buffer  /**< */,
467                                     uint32_t     notifies_len  /**< */)
468 {
469     char *xcb_tmp = (char *)_buffer;
470     unsigned int xcb_buffer_len = 0;
471     unsigned int xcb_block_len = 0;
472     unsigned int xcb_pad = 0;
473     unsigned int xcb_align_to = 0;
474 
475 
476     xcb_block_len += sizeof(xcb_present_redirect_notify_event_t);
477     xcb_tmp += xcb_block_len;
478     xcb_buffer_len += xcb_block_len;
479     xcb_block_len = 0;
480     /* notifies */
481     xcb_block_len += notifies_len * sizeof(xcb_present_notify_t);
482     xcb_tmp += xcb_block_len;
483     xcb_align_to = ALIGNOF(xcb_present_notify_t);
484     /* insert padding */
485     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
486     xcb_buffer_len += xcb_block_len + xcb_pad;
487     if (0 != xcb_pad) {
488         xcb_tmp += xcb_pad;
489         xcb_pad = 0;
490     }
491     xcb_block_len = 0;
492 
493     return xcb_buffer_len;
494 }
495 
496