You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

671 lines
19KB

  1. /*
  2. * XCB input grabber
  3. * Copyright (C) 2014 Luca Barbato <lu_zero@gentoo.org>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "config.h"
  22. #include <stdlib.h>
  23. #include <xcb/xcb.h>
  24. #if CONFIG_LIBXCB_XFIXES
  25. #include <xcb/xfixes.h>
  26. #endif
  27. #if CONFIG_LIBXCB_SHM
  28. #include <sys/shm.h>
  29. #include <xcb/shm.h>
  30. #endif
  31. #include "libavformat/avformat.h"
  32. #include "libavformat/internal.h"
  33. #include "libavutil/mathematics.h"
  34. #include "libavutil/opt.h"
  35. #include "libavutil/parseutils.h"
  36. #include "libavutil/time.h"
  37. typedef struct XCBGrabContext {
  38. const AVClass *class;
  39. xcb_connection_t *conn;
  40. xcb_screen_t *screen;
  41. xcb_window_t window;
  42. #if CONFIG_LIBXCB_SHM
  43. xcb_shm_seg_t segment;
  44. #endif
  45. int64_t time_frame;
  46. AVRational time_base;
  47. int x, y;
  48. int width, height;
  49. int frame_size;
  50. int bpp;
  51. int draw_mouse;
  52. int follow_mouse;
  53. int show_region;
  54. int region_border;
  55. int centered;
  56. const char *video_size;
  57. const char *framerate;
  58. int has_shm;
  59. } XCBGrabContext;
  60. #define FOLLOW_CENTER -1
  61. #define OFFSET(x) offsetof(XCBGrabContext, x)
  62. #define D AV_OPT_FLAG_DECODING_PARAM
  63. static const AVOption options[] = {
  64. { "x", "Initial x coordinate.", OFFSET(x), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D },
  65. { "y", "Initial y coordinate.", OFFSET(y), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D },
  66. { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "vga" }, 0, 0, D },
  67. { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc" }, 0, 0, D },
  68. { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, D },
  69. { "follow_mouse", "Move the grabbing region when the mouse pointer reaches within specified amount of pixels to the edge of region.",
  70. OFFSET(follow_mouse), AV_OPT_TYPE_INT, { .i64 = 0 }, FOLLOW_CENTER, INT_MAX, D, "follow_mouse" },
  71. { "centered", "Keep the mouse pointer at the center of grabbing region when following.", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, D, "follow_mouse" },
  72. { "show_region", "Show the grabbing region.", OFFSET(show_region), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D },
  73. { "region_border", "Set the region border thickness.", OFFSET(region_border), AV_OPT_TYPE_INT, { .i64 = 3 }, 1, 128, D },
  74. { NULL },
  75. };
  76. static const AVClass xcbgrab_class = {
  77. .class_name = "xcbgrab indev",
  78. .item_name = av_default_item_name,
  79. .option = options,
  80. .version = LIBAVUTIL_VERSION_INT,
  81. .category = AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT,
  82. };
  83. static int xcbgrab_reposition(AVFormatContext *s,
  84. xcb_query_pointer_reply_t *p,
  85. xcb_get_geometry_reply_t *geo)
  86. {
  87. XCBGrabContext *c = s->priv_data;
  88. int x = c->x, y = c->y, p_x = p->win_x, p_y = p->win_y;
  89. int w = c->width, h = c->height, f = c->follow_mouse;
  90. if (!p || !geo)
  91. return AVERROR(EIO);
  92. if (f == FOLLOW_CENTER) {
  93. x = p_x - w / 2;
  94. y = p_y - h / 2;
  95. } else {
  96. int left = x + f;
  97. int right = x + w - f;
  98. int top = y + f;
  99. int bottom = y + h + f;
  100. if (p_x > right) {
  101. x += p_x - right;
  102. } else if (p_x < left) {
  103. x -= left - p_x;
  104. }
  105. if (p_y > bottom) {
  106. y += p_y - bottom;
  107. } else if (p_y < top) {
  108. y -= top - p_y;
  109. }
  110. }
  111. c->x = FFMIN(FFMAX(0, x), geo->width - w);
  112. c->y = FFMIN(FFMAX(0, y), geo->height - h);
  113. return 0;
  114. }
  115. static int xcbgrab_frame(AVFormatContext *s, AVPacket *pkt)
  116. {
  117. XCBGrabContext *c = s->priv_data;
  118. xcb_get_image_cookie_t iq;
  119. xcb_get_image_reply_t *img;
  120. xcb_drawable_t drawable = c->screen->root;
  121. uint8_t *data;
  122. int length, ret;
  123. iq = xcb_get_image(c->conn, XCB_IMAGE_FORMAT_Z_PIXMAP, drawable,
  124. c->x, c->y, c->width, c->height, ~0);
  125. img = xcb_get_image_reply(c->conn, iq, NULL);
  126. if (!img)
  127. return AVERROR(EAGAIN);
  128. data = xcb_get_image_data(img);
  129. length = xcb_get_image_data_length(img);
  130. ret = av_new_packet(pkt, length);
  131. if (!ret)
  132. memcpy(pkt->data, data, length);
  133. free(img);
  134. return ret;
  135. }
  136. static void wait_frame(AVFormatContext *s, AVPacket *pkt)
  137. {
  138. XCBGrabContext *c = s->priv_data;
  139. int64_t curtime, delay;
  140. int64_t frame_time = av_rescale_q(1, c->time_base, AV_TIME_BASE_Q);
  141. c->time_frame += frame_time;
  142. for (;;) {
  143. curtime = av_gettime();
  144. delay = c->time_frame - curtime;
  145. if (delay <= 0)
  146. break;
  147. av_usleep(delay);
  148. }
  149. pkt->pts = curtime;
  150. }
  151. #if CONFIG_LIBXCB_SHM
  152. static int check_shm(xcb_connection_t *conn)
  153. {
  154. xcb_shm_query_version_cookie_t cookie = xcb_shm_query_version(conn);
  155. xcb_shm_query_version_reply_t *reply;
  156. reply = xcb_shm_query_version_reply(conn, cookie, NULL);
  157. if (reply) {
  158. free(reply);
  159. return 1;
  160. }
  161. return 0;
  162. }
  163. static void dealloc_shm(void *unused, uint8_t *data)
  164. {
  165. shmdt(data);
  166. }
  167. static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket *pkt)
  168. {
  169. XCBGrabContext *c = s->priv_data;
  170. xcb_shm_get_image_cookie_t iq;
  171. xcb_shm_get_image_reply_t *img;
  172. xcb_drawable_t drawable = c->screen->root;
  173. uint8_t *data;
  174. int size = c->frame_size + FF_INPUT_BUFFER_PADDING_SIZE;
  175. int id = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777);
  176. xcb_generic_error_t *e = NULL;
  177. if (id == -1) {
  178. char errbuf[1024];
  179. int err = AVERROR(errno);
  180. av_strerror(err, errbuf, sizeof(errbuf));
  181. av_log(s, AV_LOG_ERROR, "Cannot get %d bytes of shared memory: %s.\n",
  182. size, errbuf);
  183. return err;
  184. }
  185. xcb_shm_attach(c->conn, c->segment, id, 0);
  186. iq = xcb_shm_get_image(c->conn, drawable,
  187. c->x, c->y, c->width, c->height, ~0,
  188. XCB_IMAGE_FORMAT_Z_PIXMAP, c->segment, 0);
  189. xcb_shm_detach(c->conn, c->segment);
  190. img = xcb_shm_get_image_reply(c->conn, iq, &e);
  191. xcb_flush(c->conn);
  192. if (e) {
  193. av_log(s, AV_LOG_ERROR,
  194. "Cannot get the image data "
  195. "event_error: response_type:%u error_code:%u "
  196. "sequence:%u resource_id:%u minor_code:%u major_code:%u.\n",
  197. e->response_type, e->error_code,
  198. e->sequence, e->resource_id, e->minor_code, e->major_code);
  199. shmctl(id, IPC_RMID, 0);
  200. return AVERROR(EACCES);
  201. }
  202. free(img);
  203. data = shmat(id, NULL, 0);
  204. shmctl(id, IPC_RMID, 0);
  205. if ((intptr_t)data == -1)
  206. return AVERROR(errno);
  207. pkt->buf = av_buffer_create(data, size, dealloc_shm, NULL, 0);
  208. if (!pkt->buf) {
  209. shmdt(data);
  210. return AVERROR(ENOMEM);
  211. }
  212. pkt->data = pkt->buf->data;
  213. pkt->size = c->frame_size;
  214. return 0;
  215. }
  216. #endif /* CONFIG_LIBXCB_SHM */
  217. #if CONFIG_LIBXCB_XFIXES
  218. static int check_xfixes(xcb_connection_t *conn)
  219. {
  220. xcb_xfixes_query_version_cookie_t cookie;
  221. xcb_xfixes_query_version_reply_t *reply;
  222. cookie = xcb_xfixes_query_version(conn, XCB_XFIXES_MAJOR_VERSION,
  223. XCB_XFIXES_MINOR_VERSION);
  224. reply = xcb_xfixes_query_version_reply(conn, cookie, NULL);
  225. if (reply) {
  226. free(reply);
  227. return 1;
  228. }
  229. return 0;
  230. }
  231. #define BLEND(target, source, alpha) \
  232. (target) + ((source) * (255 - (alpha)) + 255 / 2) / 255
  233. static void xcbgrab_draw_mouse(AVFormatContext *s, AVPacket *pkt,
  234. xcb_query_pointer_reply_t *p,
  235. xcb_get_geometry_reply_t *geo)
  236. {
  237. XCBGrabContext *gr = s->priv_data;
  238. uint32_t *cursor;
  239. uint8_t *image = pkt->data;
  240. int stride = gr->bpp / 8;
  241. xcb_xfixes_get_cursor_image_cookie_t cc;
  242. xcb_xfixes_get_cursor_image_reply_t *ci;
  243. int cx, cy, x, y, w, h, c_off, i_off;
  244. cc = xcb_xfixes_get_cursor_image(gr->conn);
  245. ci = xcb_xfixes_get_cursor_image_reply(gr->conn, cc, NULL);
  246. if (!ci)
  247. return;
  248. cursor = xcb_xfixes_get_cursor_image_cursor_image(ci);
  249. if (!cursor)
  250. return;
  251. cx = ci->x - ci->xhot;
  252. cy = ci->y - ci->yhot;
  253. x = FFMAX(cx, gr->x);
  254. y = FFMAX(cy, gr->y);
  255. w = FFMIN(cx + ci->width, gr->x + gr->width) - x;
  256. h = FFMIN(cy + ci->height, gr->y + gr->height) - y;
  257. c_off = x - cx;
  258. i_off = x - gr->x;
  259. cursor += (y - cy) * ci->width;
  260. image += (y - gr->y) * gr->width * stride;
  261. for (y = 0; y < h; y++) {
  262. cursor += c_off;
  263. image += i_off * stride;
  264. for (x = 0; x < w; x++, cursor++, image += stride) {
  265. int r, g, b, a;
  266. r = *cursor & 0xff;
  267. g = (*cursor >> 8) & 0xff;
  268. b = (*cursor >> 16) & 0xff;
  269. a = (*cursor >> 24) & 0xff;
  270. if (!a)
  271. continue;
  272. if (a == 255) {
  273. image[0] = r;
  274. image[1] = g;
  275. image[2] = b;
  276. } else {
  277. image[0] = BLEND(r, image[0], a);
  278. image[1] = BLEND(g, image[1], a);
  279. image[2] = BLEND(b, image[2], a);
  280. }
  281. }
  282. cursor += ci->width - w - c_off;
  283. image += (gr->width - w - i_off) * stride;
  284. }
  285. free(ci);
  286. }
  287. #endif /* CONFIG_LIBXCB_XFIXES */
  288. static void xcbgrab_update_region(AVFormatContext *s)
  289. {
  290. XCBGrabContext *c = s->priv_data;
  291. const uint32_t args[] = { c->x - c->region_border,
  292. c->y - c->region_border };
  293. xcb_configure_window(c->conn,
  294. c->window,
  295. XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y,
  296. args);
  297. }
  298. static int xcbgrab_read_packet(AVFormatContext *s, AVPacket *pkt)
  299. {
  300. XCBGrabContext *c = s->priv_data;
  301. xcb_query_pointer_cookie_t pc;
  302. xcb_get_geometry_cookie_t gc;
  303. xcb_query_pointer_reply_t *p = NULL;
  304. xcb_get_geometry_reply_t *geo = NULL;
  305. int ret = 0;
  306. wait_frame(s, pkt);
  307. if (c->follow_mouse || c->draw_mouse) {
  308. pc = xcb_query_pointer(c->conn, c->screen->root);
  309. gc = xcb_get_geometry(c->conn, c->screen->root);
  310. p = xcb_query_pointer_reply(c->conn, pc, NULL);
  311. geo = xcb_get_geometry_reply(c->conn, gc, NULL);
  312. }
  313. if (c->follow_mouse && p->same_screen)
  314. xcbgrab_reposition(s, p, geo);
  315. if (c->show_region)
  316. xcbgrab_update_region(s);
  317. #if CONFIG_LIBXCB_SHM
  318. if (c->has_shm && xcbgrab_frame_shm(s, pkt) < 0)
  319. c->has_shm = 0;
  320. #endif
  321. if (!c->has_shm)
  322. ret = xcbgrab_frame(s, pkt);
  323. #if CONFIG_LIBXCB_XFIXES
  324. if (c->draw_mouse && p->same_screen)
  325. xcbgrab_draw_mouse(s, pkt, p, geo);
  326. #endif
  327. free(p);
  328. free(geo);
  329. return ret;
  330. }
  331. static av_cold int xcbgrab_read_close(AVFormatContext *s)
  332. {
  333. XCBGrabContext *ctx = s->priv_data;
  334. xcb_disconnect(ctx->conn);
  335. return 0;
  336. }
  337. static xcb_screen_t *get_screen(const xcb_setup_t *setup, int screen_num)
  338. {
  339. xcb_screen_iterator_t it = xcb_setup_roots_iterator(setup);
  340. xcb_screen_t *screen = NULL;
  341. for (; it.rem > 0; xcb_screen_next (&it)) {
  342. if (!screen_num) {
  343. screen = it.data;
  344. break;
  345. }
  346. screen_num--;
  347. }
  348. return screen;
  349. }
  350. static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth,
  351. int *pix_fmt)
  352. {
  353. XCBGrabContext *c = s->priv_data;
  354. const xcb_setup_t *setup = xcb_get_setup(c->conn);
  355. const xcb_format_t *fmt = xcb_setup_pixmap_formats(setup);
  356. int length = xcb_setup_pixmap_formats_length(setup);
  357. *pix_fmt = 0;
  358. while (length--) {
  359. if (fmt->depth == depth) {
  360. switch (depth) {
  361. case 32:
  362. if (fmt->bits_per_pixel == 32)
  363. *pix_fmt = AV_PIX_FMT_ARGB;
  364. break;
  365. case 24:
  366. if (fmt->bits_per_pixel == 32)
  367. *pix_fmt = AV_PIX_FMT_RGB32;
  368. else if (fmt->bits_per_pixel == 24)
  369. *pix_fmt = AV_PIX_FMT_RGB24;
  370. break;
  371. case 16:
  372. if (fmt->bits_per_pixel == 16)
  373. *pix_fmt = AV_PIX_FMT_RGB565;
  374. break;
  375. case 15:
  376. if (fmt->bits_per_pixel == 16)
  377. *pix_fmt = AV_PIX_FMT_RGB555;
  378. break;
  379. case 8:
  380. if (fmt->bits_per_pixel == 8)
  381. *pix_fmt = AV_PIX_FMT_RGB8;
  382. break;
  383. }
  384. }
  385. if (*pix_fmt) {
  386. c->bpp = fmt->bits_per_pixel;
  387. c->frame_size = c->width * c->height * fmt->bits_per_pixel / 8;
  388. return 0;
  389. }
  390. fmt++;
  391. }
  392. av_log(s, AV_LOG_ERROR, "Pixmap format not mappable.\n");
  393. return AVERROR_PATCHWELCOME;
  394. }
  395. static int create_stream(AVFormatContext *s)
  396. {
  397. XCBGrabContext *c = s->priv_data;
  398. AVStream *st = avformat_new_stream(s, NULL);
  399. xcb_get_geometry_cookie_t gc;
  400. xcb_get_geometry_reply_t *geo;
  401. int ret;
  402. if (!st)
  403. return AVERROR(ENOMEM);
  404. ret = av_parse_video_size(&c->width, &c->height, c->video_size);
  405. if (ret < 0)
  406. return ret;
  407. ret = av_parse_video_rate(&st->avg_frame_rate, c->framerate);
  408. if (ret < 0)
  409. return ret;
  410. avpriv_set_pts_info(st, 64, 1, 1000000);
  411. gc = xcb_get_geometry(c->conn, c->screen->root);
  412. geo = xcb_get_geometry_reply(c->conn, gc, NULL);
  413. c->width = FFMIN(geo->width, c->width);
  414. c->height = FFMIN(geo->height, c->height);
  415. c->time_base = (AVRational){ st->avg_frame_rate.den,
  416. st->avg_frame_rate.num };
  417. c->time_frame = av_gettime();
  418. st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
  419. st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
  420. st->codec->width = c->width;
  421. st->codec->height = c->height;
  422. st->codec->time_base = c->time_base;
  423. ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codec->pix_fmt);
  424. free(geo);
  425. return ret;
  426. }
  427. static void draw_rectangle(AVFormatContext *s)
  428. {
  429. XCBGrabContext *c = s->priv_data;
  430. xcb_gcontext_t gc = xcb_generate_id(c->conn);
  431. uint32_t mask = XCB_GC_FOREGROUND |
  432. XCB_GC_BACKGROUND |
  433. XCB_GC_LINE_WIDTH |
  434. XCB_GC_LINE_STYLE |
  435. XCB_GC_FILL_STYLE;
  436. uint32_t values[] = { c->screen->black_pixel,
  437. c->screen->white_pixel,
  438. c->region_border,
  439. XCB_LINE_STYLE_DOUBLE_DASH,
  440. XCB_FILL_STYLE_SOLID };
  441. xcb_rectangle_t r = { 1, 1,
  442. c->width + c->region_border * 2 - 3,
  443. c->height + c->region_border * 2 - 3 };
  444. xcb_create_gc(c->conn, gc, c->window, mask, values);
  445. xcb_poly_rectangle(c->conn, c->window, gc, 1, &r);
  446. }
  447. static void setup_window(AVFormatContext *s)
  448. {
  449. XCBGrabContext *c = s->priv_data;
  450. uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
  451. uint32_t values[] = { 1,
  452. XCB_EVENT_MASK_EXPOSURE |
  453. XCB_EVENT_MASK_STRUCTURE_NOTIFY };
  454. xcb_rectangle_t rect = { c->x, c->y, c->width, c->height };
  455. c->window = xcb_generate_id(c->conn);
  456. xcb_create_window(c->conn, XCB_COPY_FROM_PARENT,
  457. c->window,
  458. c->screen->root,
  459. c->x - c->region_border,
  460. c->y - c->region_border,
  461. c->width + c->region_border * 2,
  462. c->height + c->region_border * 2,
  463. 0,
  464. XCB_WINDOW_CLASS_INPUT_OUTPUT,
  465. XCB_COPY_FROM_PARENT,
  466. mask, values);
  467. #if XCB_SHAPE_RECTANGLES
  468. xcb_shape_rectangles(c->conn, XCB_SHAPE_SO_SUBTRACT,
  469. XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
  470. c->window,
  471. c->region_border, c->region_border,
  472. 1, &rect);
  473. #endif
  474. xcb_map_window(c->conn, c->window);
  475. draw_rectangle(s);
  476. }
  477. static av_cold int xcbgrab_read_header(AVFormatContext *s)
  478. {
  479. XCBGrabContext *c = s->priv_data;
  480. int screen_num, ret;
  481. const xcb_setup_t *setup;
  482. char *display_name = av_strdup(s->filename);
  483. if (s->filename) {
  484. if (!display_name)
  485. return AVERROR(ENOMEM);
  486. if (!sscanf(s->filename, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
  487. *display_name = 0;
  488. sscanf(s->filename, "+%d,%d", &c->x, &c->y);
  489. }
  490. }
  491. c->conn = xcb_connect(display_name, &screen_num);
  492. av_freep(&display_name);
  493. if ((ret = xcb_connection_has_error(c->conn))) {
  494. av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
  495. s->filename ? s->filename : "default", ret);
  496. return AVERROR(EIO);
  497. }
  498. setup = xcb_get_setup(c->conn);
  499. c->screen = get_screen(setup, screen_num);
  500. if (!c->screen) {
  501. av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",
  502. screen_num);
  503. xcbgrab_read_close(s);
  504. return AVERROR(EIO);
  505. }
  506. #if CONFIG_LIBXCB_SHM
  507. c->segment = xcb_generate_id(c->conn);
  508. #endif
  509. ret = create_stream(s);
  510. if (ret < 0) {
  511. xcbgrab_read_close(s);
  512. return ret;
  513. }
  514. #if CONFIG_LIBXCB_SHM
  515. c->has_shm = check_shm(c->conn);
  516. #endif
  517. #if CONFIG_LIBXCB_XFIXES
  518. if (c->draw_mouse) {
  519. if (!(c->draw_mouse = check_xfixes(c->conn))) {
  520. av_log(s, AV_LOG_WARNING,
  521. "XFixes not available, cannot draw the mouse.\n");
  522. }
  523. if (c->bpp < 24) {
  524. avpriv_report_missing_feature(s, "%d bits per pixel screen",
  525. c->bpp);
  526. c->draw_mouse = 0;
  527. }
  528. }
  529. #endif
  530. if (c->show_region)
  531. setup_window(s);
  532. return 0;
  533. }
  534. AVInputFormat ff_x11grab_xcb_demuxer = {
  535. .name = "x11grab",
  536. .long_name = NULL_IF_CONFIG_SMALL("X11 screen capture, using XCB"),
  537. .priv_data_size = sizeof(XCBGrabContext),
  538. .read_header = xcbgrab_read_header,
  539. .read_packet = xcbgrab_read_packet,
  540. .read_close = xcbgrab_read_close,
  541. .flags = AVFMT_NOFILE,
  542. .priv_class = &xcbgrab_class,
  543. };