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 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 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 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 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 * 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 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 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 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_present_notify_t * 258 xcb_present_pixmap_notifies (const xcb_present_pixmap_request_t *R) 259 { 260 return (xcb_present_notify_t *) (R + 1); 261 } 262 263 int 264 xcb_present_pixmap_notifies_length (const xcb_present_pixmap_request_t *R) 265 { 266 return (((R->length * 4) - sizeof(xcb_present_pixmap_request_t))/sizeof(xcb_present_notify_t)); 267 } 268 269 xcb_present_notify_iterator_t 270 xcb_present_pixmap_notifies_iterator (const xcb_present_pixmap_request_t *R) 271 { 272 xcb_present_notify_iterator_t i; 273 i.data = (xcb_present_notify_t *) (R + 1); 274 i.rem = (((R->length * 4) - sizeof(xcb_present_pixmap_request_t))/sizeof(xcb_present_notify_t)); 275 i.index = (char *) i.data - (char *) R; 276 return i; 277 } 278 279 xcb_void_cookie_t 280 xcb_present_notify_msc_checked (xcb_connection_t *c, 281 xcb_window_t window, 282 uint32_t serial, 283 uint64_t target_msc, 284 uint64_t divisor, 285 uint64_t remainder) 286 { 287 static const xcb_protocol_request_t xcb_req = { 288 .count = 2, 289 .ext = &xcb_present_id, 290 .opcode = XCB_PRESENT_NOTIFY_MSC, 291 .isvoid = 1 292 }; 293 294 struct iovec xcb_parts[4]; 295 xcb_void_cookie_t xcb_ret; 296 xcb_present_notify_msc_request_t xcb_out; 297 298 xcb_out.window = window; 299 xcb_out.serial = serial; 300 memset(xcb_out.pad0, 0, 4); 301 xcb_out.target_msc = target_msc; 302 xcb_out.divisor = divisor; 303 xcb_out.remainder = remainder; 304 305 xcb_parts[2].iov_base = (char *) &xcb_out; 306 xcb_parts[2].iov_len = sizeof(xcb_out); 307 xcb_parts[3].iov_base = 0; 308 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3; 309 310 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req); 311 return xcb_ret; 312 } 313 314 xcb_void_cookie_t 315 xcb_present_notify_msc (xcb_connection_t *c, 316 xcb_window_t window, 317 uint32_t serial, 318 uint64_t target_msc, 319 uint64_t divisor, 320 uint64_t remainder) 321 { 322 static const xcb_protocol_request_t xcb_req = { 323 .count = 2, 324 .ext = &xcb_present_id, 325 .opcode = XCB_PRESENT_NOTIFY_MSC, 326 .isvoid = 1 327 }; 328 329 struct iovec xcb_parts[4]; 330 xcb_void_cookie_t xcb_ret; 331 xcb_present_notify_msc_request_t xcb_out; 332 333 xcb_out.window = window; 334 xcb_out.serial = serial; 335 memset(xcb_out.pad0, 0, 4); 336 xcb_out.target_msc = target_msc; 337 xcb_out.divisor = divisor; 338 xcb_out.remainder = remainder; 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 void 350 xcb_present_event_next (xcb_present_event_iterator_t *i) 351 { 352 --i->rem; 353 ++i->data; 354 i->index += sizeof(xcb_present_event_t); 355 } 356 357 xcb_generic_iterator_t 358 xcb_present_event_end (xcb_present_event_iterator_t i) 359 { 360 xcb_generic_iterator_t ret; 361 ret.data = i.data + i.rem; 362 ret.index = i.index + ((char *) ret.data - (char *) i.data); 363 ret.rem = 0; 364 return ret; 365 } 366 367 xcb_void_cookie_t 368 xcb_present_select_input_checked (xcb_connection_t *c, 369 xcb_present_event_t eid, 370 xcb_window_t window, 371 uint32_t event_mask) 372 { 373 static const xcb_protocol_request_t xcb_req = { 374 .count = 2, 375 .ext = &xcb_present_id, 376 .opcode = XCB_PRESENT_SELECT_INPUT, 377 .isvoid = 1 378 }; 379 380 struct iovec xcb_parts[4]; 381 xcb_void_cookie_t xcb_ret; 382 xcb_present_select_input_request_t xcb_out; 383 384 xcb_out.eid = eid; 385 xcb_out.window = window; 386 xcb_out.event_mask = event_mask; 387 388 xcb_parts[2].iov_base = (char *) &xcb_out; 389 xcb_parts[2].iov_len = sizeof(xcb_out); 390 xcb_parts[3].iov_base = 0; 391 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3; 392 393 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req); 394 return xcb_ret; 395 } 396 397 xcb_void_cookie_t 398 xcb_present_select_input (xcb_connection_t *c, 399 xcb_present_event_t eid, 400 xcb_window_t window, 401 uint32_t event_mask) 402 { 403 static const xcb_protocol_request_t xcb_req = { 404 .count = 2, 405 .ext = &xcb_present_id, 406 .opcode = XCB_PRESENT_SELECT_INPUT, 407 .isvoid = 1 408 }; 409 410 struct iovec xcb_parts[4]; 411 xcb_void_cookie_t xcb_ret; 412 xcb_present_select_input_request_t xcb_out; 413 414 xcb_out.eid = eid; 415 xcb_out.window = window; 416 xcb_out.event_mask = event_mask; 417 418 xcb_parts[2].iov_base = (char *) &xcb_out; 419 xcb_parts[2].iov_len = sizeof(xcb_out); 420 xcb_parts[3].iov_base = 0; 421 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3; 422 423 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req); 424 return xcb_ret; 425 } 426 427 xcb_present_query_capabilities_cookie_t 428 xcb_present_query_capabilities (xcb_connection_t *c, 429 uint32_t target) 430 { 431 static const xcb_protocol_request_t xcb_req = { 432 .count = 2, 433 .ext = &xcb_present_id, 434 .opcode = XCB_PRESENT_QUERY_CAPABILITIES, 435 .isvoid = 0 436 }; 437 438 struct iovec xcb_parts[4]; 439 xcb_present_query_capabilities_cookie_t xcb_ret; 440 xcb_present_query_capabilities_request_t xcb_out; 441 442 xcb_out.target = target; 443 444 xcb_parts[2].iov_base = (char *) &xcb_out; 445 xcb_parts[2].iov_len = sizeof(xcb_out); 446 xcb_parts[3].iov_base = 0; 447 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3; 448 449 xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req); 450 return xcb_ret; 451 } 452 453 xcb_present_query_capabilities_cookie_t 454 xcb_present_query_capabilities_unchecked (xcb_connection_t *c, 455 uint32_t target) 456 { 457 static const xcb_protocol_request_t xcb_req = { 458 .count = 2, 459 .ext = &xcb_present_id, 460 .opcode = XCB_PRESENT_QUERY_CAPABILITIES, 461 .isvoid = 0 462 }; 463 464 struct iovec xcb_parts[4]; 465 xcb_present_query_capabilities_cookie_t xcb_ret; 466 xcb_present_query_capabilities_request_t xcb_out; 467 468 xcb_out.target = target; 469 470 xcb_parts[2].iov_base = (char *) &xcb_out; 471 xcb_parts[2].iov_len = sizeof(xcb_out); 472 xcb_parts[3].iov_base = 0; 473 xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3; 474 475 xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req); 476 return xcb_ret; 477 } 478 479 xcb_present_query_capabilities_reply_t * 480 xcb_present_query_capabilities_reply (xcb_connection_t *c, 481 xcb_present_query_capabilities_cookie_t cookie /**< */, 482 xcb_generic_error_t **e) 483 { 484 return (xcb_present_query_capabilities_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e); 485 } 486 487 int 488 xcb_present_redirect_notify_sizeof (const void *_buffer, 489 uint32_t notifies_len) 490 { 491 char *xcb_tmp = (char *)_buffer; 492 unsigned int xcb_buffer_len = 0; 493 unsigned int xcb_block_len = 0; 494 unsigned int xcb_pad = 0; 495 unsigned int xcb_align_to = 0; 496 497 498 xcb_block_len += sizeof(xcb_present_redirect_notify_event_t); 499 xcb_tmp += xcb_block_len; 500 xcb_buffer_len += xcb_block_len; 501 xcb_block_len = 0; 502 /* notifies */ 503 xcb_block_len += notifies_len * sizeof(xcb_present_notify_t); 504 xcb_tmp += xcb_block_len; 505 xcb_align_to = ALIGNOF(xcb_present_notify_t); 506 /* insert padding */ 507 xcb_pad = -xcb_block_len & (xcb_align_to - 1); 508 xcb_buffer_len += xcb_block_len + xcb_pad; 509 if (0 != xcb_pad) { 510 xcb_tmp += xcb_pad; 511 xcb_pad = 0; 512 } 513 xcb_block_len = 0; 514 515 return xcb_buffer_len; 516 } 517 518 xcb_present_notify_t * 519 xcb_present_redirect_notify_notifies (const xcb_present_redirect_notify_event_t *R) 520 { 521 return (xcb_present_notify_t *) (R + 1); 522 } 523 524 int 525 xcb_present_redirect_notify_notifies_length (const xcb_present_redirect_notify_event_t *R) 526 { 527 return (((R->length * 4) - sizeof(xcb_present_redirect_notify_event_t))/sizeof(xcb_present_notify_t)); 528 } 529 530 xcb_present_notify_iterator_t 531 xcb_present_redirect_notify_notifies_iterator (const xcb_present_redirect_notify_event_t *R) 532 { 533 xcb_present_notify_iterator_t i; 534 i.data = (xcb_present_notify_t *) (R + 1); 535 i.rem = (((R->length * 4) - sizeof(xcb_present_redirect_notify_event_t))/sizeof(xcb_present_notify_t)); 536 i.index = (char *) i.data - (char *) R; 537 return i; 538 } 539 540