56eeea98122ecb7056f41c21b3676039d72cf862
[libav.git] / libavdevice / x11grab.c
1 /*
2 * X11 video grab interface
3 *
4 * This file is part of Libav.
5 *
6 * Libav integration:
7 * Copyright (C) 2006 Clemens Fruhwirth <clemens@endorphin.org>
8 * Edouard Gomez <ed.gomez@free.fr>
9 *
10 * This file contains code from grab.c:
11 * Copyright (c) 2000-2001 Fabrice Bellard
12 *
13 * This file contains code from the xvidcap project:
14 * Copyright (C) 1997-1998 Rasca, Berlin
15 * 2003-2004 Karl H. Beckers, Frankfurt
16 *
17 * Libav is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * Libav is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with Libav; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
32 /**
33 * @file
34 * X11 frame device demuxer
35 * @author Clemens Fruhwirth <clemens@endorphin.org>
36 * @author Edouard Gomez <ed.gomez@free.fr>
37 */
38
39 #include "config.h"
40
41 #include <time.h>
42 #include <sys/shm.h>
43
44 #include <X11/X.h>
45 #include <X11/Xlib.h>
46 #include <X11/Xlibint.h>
47 #include <X11/Xproto.h>
48 #include <X11/Xutil.h>
49
50 #include <X11/extensions/shape.h>
51 #include <X11/extensions/Xfixes.h>
52 #include <X11/extensions/XShm.h>
53
54 #include "libavutil/log.h"
55 #include "libavutil/opt.h"
56 #include "libavutil/parseutils.h"
57 #include "libavutil/time.h"
58
59 #include "libavformat/avformat.h"
60 #include "libavformat/internal.h"
61
62 /** X11 device demuxer context */
63 typedef struct X11GrabContext {
64 const AVClass *class; /**< Class for private options. */
65 int frame_size; /**< Size in bytes of a grabbed frame */
66 AVRational time_base; /**< Time base */
67 int64_t time_frame; /**< Current time */
68
69 char *video_size; /**< String describing video size, set by a private option. */
70 int height; /**< Height of the grab frame */
71 int width; /**< Width of the grab frame */
72 int x_off; /**< Horizontal top-left corner coordinate */
73 int y_off; /**< Vertical top-left corner coordinate */
74
75 Display *dpy; /**< X11 display from which x11grab grabs frames */
76 XImage *image; /**< X11 image holding the grab */
77 int use_shm; /**< !0 when using XShm extension */
78 XShmSegmentInfo shminfo; /**< When using XShm, keeps track of XShm infos */
79 int draw_mouse; /**< Set by a private option. */
80 int follow_mouse; /**< Set by a private option. */
81 int show_region; /**< set by a private option. */
82 char *framerate; /**< Set by a private option. */
83
84 Window region_win; /**< This is used by show_region option. */
85 } X11GrabContext;
86
87 #define REGION_WIN_BORDER 3
88
89 /**
90 * Draw grabbing region window
91 *
92 * @param s x11grab context
93 */
94 static void x11grab_draw_region_win(X11GrabContext *s)
95 {
96 Display *dpy = s->dpy;
97 Window win = s->region_win;
98 int screen = DefaultScreen(dpy);
99 GC gc = XCreateGC(dpy, win, 0, 0);
100
101 XSetForeground(dpy, gc, WhitePixel(dpy, screen));
102 XSetBackground(dpy, gc, BlackPixel(dpy, screen));
103 XSetLineAttributes(dpy, gc, REGION_WIN_BORDER, LineDoubleDash, 0, 0);
104 XDrawRectangle(dpy, win, gc, 1, 1,
105 (s->width + REGION_WIN_BORDER * 2) - 1 * 2 - 1,
106 (s->height + REGION_WIN_BORDER * 2) - 1 * 2 - 1);
107 XFreeGC(dpy, gc);
108 }
109
110 /**
111 * Initialize grabbing region window
112 *
113 * @param s x11grab context
114 */
115 static void x11grab_region_win_init(X11GrabContext *s)
116 {
117 Display *dpy = s->dpy;
118 XRectangle rect;
119 XSetWindowAttributes attribs = { .override_redirect = True };
120 int screen = DefaultScreen(dpy);
121
122 s->region_win = XCreateWindow(dpy, RootWindow(dpy, screen),
123 s->x_off - REGION_WIN_BORDER,
124 s->y_off - REGION_WIN_BORDER,
125 s->width + REGION_WIN_BORDER * 2,
126 s->height + REGION_WIN_BORDER * 2,
127 0, CopyFromParent,
128 InputOutput, CopyFromParent,
129 CWOverrideRedirect, &attribs);
130 rect.x = 0;
131 rect.y = 0;
132 rect.width = s->width;
133 rect.height = s->height;
134 XShapeCombineRectangles(dpy, s->region_win,
135 ShapeBounding, REGION_WIN_BORDER, REGION_WIN_BORDER,
136 &rect, 1, ShapeSubtract, 0);
137 XMapWindow(dpy, s->region_win);
138 XSelectInput(dpy, s->region_win, ExposureMask | StructureNotifyMask);
139 x11grab_draw_region_win(s);
140 }
141
142 /**
143 * Initialize the x11 grab device demuxer (public device demuxer API).
144 *
145 * @param s1 Context from avformat core
146 * @return <ul>
147 * <li>AVERROR(ENOMEM) no memory left</li>
148 * <li>AVERROR(EIO) other failure case</li>
149 * <li>0 success</li>
150 * </ul>
151 */
152 static int x11grab_read_header(AVFormatContext *s1)
153 {
154 X11GrabContext *x11grab = s1->priv_data;
155 Display *dpy;
156 AVStream *st = NULL;
157 enum AVPixelFormat input_pixfmt;
158 XImage *image;
159 int x_off = 0, y_off = 0, ret = 0, screen, use_shm;
160 char *param, *offset;
161 AVRational framerate;
162
163 param = av_strdup(s1->filename);
164 if (!param)
165 goto out;
166
167 offset = strchr(param, '+');
168 if (offset) {
169 sscanf(offset, "%d,%d", &x_off, &y_off);
170 x11grab->draw_mouse = !strstr(offset, "nomouse");
171 *offset = 0;
172 }
173
174 ret = av_parse_video_size(&x11grab->width, &x11grab->height,
175 x11grab->video_size);
176 if (ret < 0) {
177 av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n");
178 goto out;
179 }
180
181 ret = av_parse_video_rate(&framerate, x11grab->framerate);
182 if (ret < 0) {
183 av_log(s1, AV_LOG_ERROR, "Could not parse framerate: %s.\n",
184 x11grab->framerate);
185 goto out;
186 }
187 av_log(s1, AV_LOG_INFO,
188 "device: %s -> display: %s x: %d y: %d width: %d height: %d\n",
189 s1->filename, param, x_off, y_off, x11grab->width, x11grab->height);
190
191 dpy = XOpenDisplay(param);
192 if (!dpy) {
193 av_log(s1, AV_LOG_ERROR, "Could not open X display.\n");
194 ret = AVERROR(EIO);
195 goto out;
196 }
197
198 st = avformat_new_stream(s1, NULL);
199 if (!st) {
200 ret = AVERROR(ENOMEM);
201 goto out;
202 }
203 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
204
205 screen = DefaultScreen(dpy);
206
207 if (x11grab->follow_mouse) {
208 int screen_w, screen_h;
209 Window w;
210
211 screen_w = DisplayWidth(dpy, screen);
212 screen_h = DisplayHeight(dpy, screen);
213 XQueryPointer(dpy, RootWindow(dpy, screen), &w, &w, &x_off, &y_off,
214 &ret, &ret, &ret);
215 x_off -= x11grab->width / 2;
216 y_off -= x11grab->height / 2;
217 x_off = FFMIN(FFMAX(x_off, 0), screen_w - x11grab->width);
218 y_off = FFMIN(FFMAX(y_off, 0), screen_h - x11grab->height);
219 av_log(s1, AV_LOG_INFO,
220 "followmouse is enabled, resetting grabbing region to x: %d y: %d\n",
221 x_off, y_off);
222 }
223
224 use_shm = XShmQueryExtension(dpy);
225 av_log(s1, AV_LOG_INFO,
226 "shared memory extension %sfound\n", use_shm ? "" : "not ");
227
228 if (use_shm) {
229 int scr = XDefaultScreen(dpy);
230 image = XShmCreateImage(dpy,
231 DefaultVisual(dpy, scr),
232 DefaultDepth(dpy, scr),
233 ZPixmap,
234 NULL,
235 &x11grab->shminfo,
236 x11grab->width, x11grab->height);
237 x11grab->shminfo.shmid = shmget(IPC_PRIVATE,
238 image->bytes_per_line * image->height,
239 IPC_CREAT | 0777);
240 if (x11grab->shminfo.shmid == -1) {
241 av_log(s1, AV_LOG_ERROR, "Fatal: Can't get shared memory!\n");
242 ret = AVERROR(ENOMEM);
243 goto out;
244 }
245 x11grab->shminfo.shmaddr = image->data = shmat(x11grab->shminfo.shmid, 0, 0);
246 x11grab->shminfo.readOnly = False;
247
248 if (!XShmAttach(dpy, &x11grab->shminfo)) {
249 av_log(s1, AV_LOG_ERROR, "Fatal: Failed to attach shared memory!\n");
250 /* needs some better error subroutine :) */
251 ret = AVERROR(EIO);
252 goto out;
253 }
254 } else {
255 image = XGetImage(dpy, RootWindow(dpy, screen),
256 x_off, y_off,
257 x11grab->width, x11grab->height,
258 AllPlanes, ZPixmap);
259 }
260
261 switch (image->bits_per_pixel) {
262 case 8:
263 av_log(s1, AV_LOG_DEBUG, "8 bit palette\n");
264 input_pixfmt = AV_PIX_FMT_PAL8;
265 break;
266 case 16:
267 if (image->red_mask == 0xf800 &&
268 image->green_mask == 0x07e0 &&
269 image->blue_mask == 0x001f) {
270 av_log(s1, AV_LOG_DEBUG, "16 bit RGB565\n");
271 input_pixfmt = AV_PIX_FMT_RGB565;
272 } else if (image->red_mask == 0x7c00 &&
273 image->green_mask == 0x03e0 &&
274 image->blue_mask == 0x001f) {
275 av_log(s1, AV_LOG_DEBUG, "16 bit RGB555\n");
276 input_pixfmt = AV_PIX_FMT_RGB555;
277 } else {
278 av_log(s1, AV_LOG_ERROR,
279 "RGB ordering at image depth %i not supported ... aborting\n",
280 image->bits_per_pixel);
281 av_log(s1, AV_LOG_ERROR,
282 "color masks: r 0x%.6lx g 0x%.6lx b 0x%.6lx\n",
283 image->red_mask, image->green_mask, image->blue_mask);
284 ret = AVERROR(EIO);
285 goto out;
286 }
287 break;
288 case 24:
289 if (image->red_mask == 0xff0000 &&
290 image->green_mask == 0x00ff00 &&
291 image->blue_mask == 0x0000ff) {
292 input_pixfmt = AV_PIX_FMT_BGR24;
293 } else if (image->red_mask == 0x0000ff &&
294 image->green_mask == 0x00ff00 &&
295 image->blue_mask == 0xff0000) {
296 input_pixfmt = AV_PIX_FMT_RGB24;
297 } else {
298 av_log(s1, AV_LOG_ERROR,
299 "rgb ordering at image depth %i not supported ... aborting\n",
300 image->bits_per_pixel);
301 av_log(s1, AV_LOG_ERROR,
302 "color masks: r 0x%.6lx g 0x%.6lx b 0x%.6lx\n",
303 image->red_mask, image->green_mask, image->blue_mask);
304 ret = AVERROR(EIO);
305 goto out;
306 }
307 break;
308 case 32:
309 input_pixfmt = AV_PIX_FMT_RGB32;
310 break;
311 default:
312 av_log(s1, AV_LOG_ERROR,
313 "image depth %i not supported ... aborting\n",
314 image->bits_per_pixel);
315 ret = AVERROR(EINVAL);
316 goto out;
317 }
318
319 x11grab->frame_size = x11grab->width * x11grab->height * image->bits_per_pixel / 8;
320 x11grab->dpy = dpy;
321 x11grab->time_base = (AVRational) { framerate.den, framerate.num };
322 x11grab->time_frame = av_gettime() / av_q2d(x11grab->time_base);
323 x11grab->x_off = x_off;
324 x11grab->y_off = y_off;
325 x11grab->image = image;
326 x11grab->use_shm = use_shm;
327
328 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
329 st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
330 st->codec->width = x11grab->width;
331 st->codec->height = x11grab->height;
332 st->codec->pix_fmt = input_pixfmt;
333 st->codec->time_base = x11grab->time_base;
334 st->codec->bit_rate = x11grab->frame_size * 1 / av_q2d(x11grab->time_base) * 8;
335
336 out:
337 av_free(param);
338 return ret;
339 }
340
341 /**
342 * Paint a mouse pointer in an X11 image.
343 *
344 * @param image image to paint the mouse pointer to
345 * @param s context used to retrieve original grabbing rectangle
346 * coordinates
347 */
348 static void paint_mouse_pointer(XImage *image, X11GrabContext *s)
349 {
350 int x_off = s->x_off;
351 int y_off = s->y_off;
352 int width = s->width;
353 int height = s->height;
354 Display *dpy = s->dpy;
355 XFixesCursorImage *xcim;
356 int x, y;
357 int line, column;
358 int to_line, to_column;
359 int pixstride = image->bits_per_pixel >> 3;
360 /* Warning: in its insanity, xlib provides unsigned image data through a
361 * char* pointer, so we have to make it uint8_t to make things not break.
362 * Anyone who performs further investigation of the xlib API likely risks
363 * permanent brain damage. */
364 uint8_t *pix = image->data;
365
366 /* Code doesn't currently support 16-bit or PAL8 */
367 if (image->bits_per_pixel != 24 && image->bits_per_pixel != 32)
368 return;
369
370 xcim = XFixesGetCursorImage(dpy);
371
372 x = xcim->x - xcim->xhot;
373 y = xcim->y - xcim->yhot;
374
375 to_line = FFMIN((y + xcim->height), (height + y_off));
376 to_column = FFMIN((x + xcim->width), (width + x_off));
377
378 for (line = FFMAX(y, y_off); line < to_line; line++) {
379 for (column = FFMAX(x, x_off); column < to_column; column++) {
380 int xcim_addr = (line - y) * xcim->width + column - x;
381 int image_addr = ((line - y_off) * width + column - x_off) * pixstride;
382 int r = (uint8_t)(xcim->pixels[xcim_addr] >> 0);
383 int g = (uint8_t)(xcim->pixels[xcim_addr] >> 8);
384 int b = (uint8_t)(xcim->pixels[xcim_addr] >> 16);
385 int a = (uint8_t)(xcim->pixels[xcim_addr] >> 24);
386
387 if (a == 255) {
388 pix[image_addr + 0] = r;
389 pix[image_addr + 1] = g;
390 pix[image_addr + 2] = b;
391 } else if (a) {
392 /* pixel values from XFixesGetCursorImage come premultiplied by alpha */
393 pix[image_addr + 0] = r + (pix[image_addr + 0] * (255 - a) + 255 / 2) / 255;
394 pix[image_addr + 1] = g + (pix[image_addr + 1] * (255 - a) + 255 / 2) / 255;
395 pix[image_addr + 2] = b + (pix[image_addr + 2] * (255 - a) + 255 / 2) / 255;
396 }
397 }
398 }
399
400 XFree(xcim);
401 xcim = NULL;
402 }
403
404 /**
405 * Read new data in the image structure.
406 *
407 * @param dpy X11 display to grab from
408 * @param d
409 * @param image Image where the grab will be put
410 * @param x Top-Left grabbing rectangle horizontal coordinate
411 * @param y Top-Left grabbing rectangle vertical coordinate
412 * @return 0 if error, !0 if successful
413 */
414 static int xget_zpixmap(Display *dpy, Drawable d, XImage *image, int x, int y)
415 {
416 xGetImageReply rep;
417 xGetImageReq *req;
418 long nbytes;
419
420 if (!image)
421 return 0;
422
423 LockDisplay(dpy);
424 GetReq(GetImage, req);
425
426 /* First set up the standard stuff in the request */
427 req->drawable = d;
428 req->x = x;
429 req->y = y;
430 req->width = image->width;
431 req->height = image->height;
432 req->planeMask = (unsigned int)AllPlanes;
433 req->format = ZPixmap;
434
435 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.length) {
436 UnlockDisplay(dpy);
437 SyncHandle();
438 return 0;
439 }
440
441 nbytes = (long)rep.length << 2;
442 _XReadPad(dpy, image->data, nbytes);
443
444 UnlockDisplay(dpy);
445 SyncHandle();
446 return 1;
447 }
448
449 /**
450 * Grab a frame from x11 (public device demuxer API).
451 *
452 * @param s1 Context from avformat core
453 * @param pkt Packet holding the brabbed frame
454 * @return frame size in bytes
455 */
456 static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
457 {
458 X11GrabContext *s = s1->priv_data;
459 Display *dpy = s->dpy;
460 XImage *image = s->image;
461 int x_off = s->x_off;
462 int y_off = s->y_off;
463 int follow_mouse = s->follow_mouse;
464 int screen;
465 Window root;
466 int64_t curtime, delay;
467 struct timespec ts;
468
469 /* Calculate the time of the next frame */
470 s->time_frame += INT64_C(1000000);
471
472 /* wait based on the frame rate */
473 for (;;) {
474 curtime = av_gettime();
475 delay = s->time_frame * av_q2d(s->time_base) - curtime;
476 if (delay <= 0) {
477 if (delay < INT64_C(-1000000) * av_q2d(s->time_base))
478 s->time_frame += INT64_C(1000000);
479 break;
480 }
481 ts.tv_sec = delay / 1000000;
482 ts.tv_nsec = (delay % 1000000) * 1000;
483 nanosleep(&ts, NULL);
484 }
485
486 av_init_packet(pkt);
487 pkt->data = image->data;
488 pkt->size = s->frame_size;
489 pkt->pts = curtime;
490
491 screen = DefaultScreen(dpy);
492 root = RootWindow(dpy, screen);
493 if (follow_mouse) {
494 int screen_w, screen_h;
495 int pointer_x, pointer_y, _;
496 Window w;
497
498 screen_w = DisplayWidth(dpy, screen);
499 screen_h = DisplayHeight(dpy, screen);
500 XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
501 if (follow_mouse == -1) {
502 // follow the mouse, put it at center of grabbing region
503 x_off += pointer_x - s->width / 2 - x_off;
504 y_off += pointer_y - s->height / 2 - y_off;
505 } else {
506 // follow the mouse, but only move the grabbing region when mouse
507 // reaches within certain pixels to the edge.
508 if (pointer_x > x_off + s->width - follow_mouse)
509 x_off += pointer_x - (x_off + s->width - follow_mouse);
510 else if (pointer_x < x_off + follow_mouse)
511 x_off -= (x_off + follow_mouse) - pointer_x;
512 if (pointer_y > y_off + s->height - follow_mouse)
513 y_off += pointer_y - (y_off + s->height - follow_mouse);
514 else if (pointer_y < y_off + follow_mouse)
515 y_off -= (y_off + follow_mouse) - pointer_y;
516 }
517 // adjust grabbing region position if it goes out of screen.
518 s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width);
519 s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height);
520
521 if (s->show_region && s->region_win)
522 XMoveWindow(dpy, s->region_win,
523 s->x_off - REGION_WIN_BORDER,
524 s->y_off - REGION_WIN_BORDER);
525 }
526
527 if (s->show_region) {
528 if (s->region_win) {
529 XEvent evt = { .type = NoEventMask };
530 // Clean up the events, and do the initial draw or redraw.
531 while (XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask,
532 &evt))
533 ;
534 if (evt.type)
535 x11grab_draw_region_win(s);
536 } else {
537 x11grab_region_win_init(s);
538 }
539 }
540
541 if (s->use_shm) {
542 if (!XShmGetImage(dpy, root, image, x_off, y_off, AllPlanes))
543 av_log(s1, AV_LOG_INFO, "XShmGetImage() failed\n");
544 } else {
545 if (!xget_zpixmap(dpy, root, image, x_off, y_off))
546 av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
547 }
548
549 if (s->draw_mouse)
550 paint_mouse_pointer(image, s);
551
552 return s->frame_size;
553 }
554
555 /**
556 * Close x11 frame grabber (public device demuxer API).
557 *
558 * @param s1 Context from avformat core
559 * @return 0 success, !0 failure
560 */
561 static int x11grab_read_close(AVFormatContext *s1)
562 {
563 X11GrabContext *x11grab = s1->priv_data;
564
565 /* Detach cleanly from shared mem */
566 if (x11grab->use_shm) {
567 XShmDetach(x11grab->dpy, &x11grab->shminfo);
568 shmdt(x11grab->shminfo.shmaddr);
569 shmctl(x11grab->shminfo.shmid, IPC_RMID, NULL);
570 }
571
572 /* Destroy X11 image */
573 if (x11grab->image) {
574 XDestroyImage(x11grab->image);
575 x11grab->image = NULL;
576 }
577
578 if (x11grab->region_win)
579 XDestroyWindow(x11grab->dpy, x11grab->region_win);
580
581 /* Free X11 display */
582 XCloseDisplay(x11grab->dpy);
583 return 0;
584 }
585
586 #define OFFSET(x) offsetof(X11GrabContext, x)
587 #define DEC AV_OPT_FLAG_DECODING_PARAM
588 static const AVOption options[] = {
589 { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC },
590 { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC },
591 { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, DEC },
592 { "follow_mouse", "Move the grabbing region when the mouse pointer reaches within specified amount of pixels to the edge of region.",
593 OFFSET(follow_mouse), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT_MAX, DEC, "follow_mouse" },
594 { "centered", "Keep the mouse pointer at the center of grabbing region when following.", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, DEC, "follow_mouse" },
595 { "show_region", "Show the grabbing region.", OFFSET(show_region), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, DEC },
596 { NULL },
597 };
598
599 static const AVClass x11_class = {
600 .class_name = "X11grab indev",
601 .item_name = av_default_item_name,
602 .option = options,
603 .version = LIBAVUTIL_VERSION_INT,
604 };
605
606 /** x11 grabber device demuxer declaration */
607 AVInputFormat ff_x11grab_demuxer = {
608 .name = "x11grab",
609 .long_name = NULL_IF_CONFIG_SMALL("X11grab"),
610 .priv_data_size = sizeof(X11GrabContext),
611 .read_header = x11grab_read_header,
612 .read_packet = x11grab_read_packet,
613 .read_close = x11grab_read_close,
614 .flags = AVFMT_NOFILE,
615 .priv_class = &x11_class,
616 };