]> git.sesse.net Git - vlc/blob - modules/video_output/xcb/xvideo.c
XCB_xv: wait until picture is displayed
[vlc] / modules / video_output / xcb / xvideo.c
1 /**
2  * @file xvideo.c
3  * @brief X C Bindings video output module for VLC media player
4  */
5 /*****************************************************************************
6  * Copyright © 2009 Rémi Denis-Courmont
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2.0
11  * of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  ****************************************************************************/
22
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
26
27 #include <stdlib.h>
28 #include <assert.h>
29
30 #include <xcb/xcb.h>
31 #include <xcb/shm.h>
32 #include <xcb/xv.h>
33
34 #include <vlc_common.h>
35 #include <vlc_plugin.h>
36 #include <vlc_vout_display.h>
37 #include <vlc_picture_pool.h>
38
39 #include "xcb_vlc.h"
40
41 #define DISPLAY_TEXT N_("X11 display")
42 #define DISPLAY_LONGTEXT N_( \
43     "X11 hardware display to use. By default VLC will " \
44     "use the value of the DISPLAY environment variable.")
45
46 #define SHM_TEXT N_("Use shared memory")
47 #define SHM_LONGTEXT N_( \
48     "Use shared memory to communicate between VLC and the X server.")
49
50 static int  Open (vlc_object_t *);
51 static void Close (vlc_object_t *);
52
53 /*
54  * Module descriptor
55  */
56 vlc_module_begin ()
57     set_shortname (N_("XVideo"))
58     set_description (N_("XVideo output (XCB)"))
59     set_category (CAT_VIDEO)
60     set_subcategory (SUBCAT_VIDEO_VOUT)
61     set_capability ("vout display", 155)
62     set_callbacks (Open, Close)
63
64     add_string ("x11-display", NULL, NULL,
65                 DISPLAY_TEXT, DISPLAY_LONGTEXT, true)
66         add_deprecated_alias ("xvideo-display")
67     add_bool ("x11-shm", true, NULL, SHM_TEXT, SHM_LONGTEXT, true)
68         add_deprecated_alias ("xvideo-shm")
69     add_shortcut ("xcb-xv")
70     add_shortcut ("xv")
71 vlc_module_end ()
72
73 #define MAX_PICTURES (VOUT_MAX_PICTURES)
74
75 struct vout_display_sys_t
76 {
77     xcb_connection_t *conn;
78     xcb_xv_query_adaptors_reply_t *adaptors;
79     vout_window_t *embed;/* VLC window */
80
81     xcb_window_t window; /* drawable X window */
82     xcb_gcontext_t gc;   /* context to put images */
83     xcb_xv_port_t port;  /* XVideo port */
84     uint32_t id;         /* XVideo format */
85     uint16_t width;      /* display width */
86     uint16_t height;     /* display height */
87     uint32_t data_size;  /* picture byte size (for non-SHM) */
88     bool shm;            /* whether to use MIT-SHM */
89
90     xcb_xv_query_image_attributes_reply_t *att;
91     picture_pool_t *pool; /* picture pool */
92     picture_resource_t resource[MAX_PICTURES];
93 };
94
95 static picture_t *Get (vout_display_t *);
96 static void Display (vout_display_t *, picture_t *);
97 static int Control (vout_display_t *, int, va_list);
98 static void Manage (vout_display_t *);
99
100 /**
101  * Check that the X server supports the XVideo extension.
102  */
103 static bool CheckXVideo (vout_display_t *vd, xcb_connection_t *conn)
104 {
105     xcb_xv_query_extension_reply_t *r;
106     xcb_xv_query_extension_cookie_t ck = xcb_xv_query_extension (conn);
107     bool ok = false;
108
109     r = xcb_xv_query_extension_reply (conn, ck, NULL);
110     if (r != NULL)
111     {   /* We need XVideo 2.2 for PutImage */
112         if ((r->major > 2) || (r->major == 2 && r->minor >= 2))
113         {
114             msg_Dbg (vd, "using XVideo extension v%"PRIu8".%"PRIu8,
115                      r->major, r->minor);
116             ok = true;
117         }
118         else
119             msg_Dbg (vd, "XVideo extension too old (v%"PRIu8".%"PRIu8,
120                      r->major, r->minor);
121         free (r);
122     }
123     else
124         msg_Dbg (vd, "XVideo extension not available");
125     return ok;
126 }
127
128 static vlc_fourcc_t ParseFormat (vout_display_t *vd,
129                                  const xcb_xv_image_format_info_t *restrict f)
130 {
131     if (f->byte_order != ORDER && f->bpp != 8)
132         return 0; /* Argh! */
133
134     switch (f->type)
135     {
136       case XCB_XV_IMAGE_FORMAT_INFO_TYPE_RGB:
137         switch (f->num_planes)
138         {
139           case 1:
140             switch (f->bpp)
141             {
142               case 32:
143                 if (f->depth == 24)
144                     return VLC_CODEC_RGB32;
145                 break;
146               case 24:
147                 if (f->depth == 24)
148                     return VLC_CODEC_RGB24;
149                 break;
150               case 16:
151                 if (f->depth == 16)
152                     return VLC_CODEC_RGB16;
153                 if (f->depth == 15)
154                     return VLC_CODEC_RGB15;
155                 break;
156               case 8:
157                 if (f->depth == 8)
158                     return VLC_CODEC_RGB8;
159                 break;
160             }
161             break;
162         }
163         msg_Err (vd, "unknown XVideo RGB format %"PRIx32" (%.4s)",
164                  f->id, f->guid);
165         msg_Dbg (vd, " %"PRIu8" planes, %"PRIu8" bits/pixel, "
166                  "depth %"PRIu8, f->num_planes, f->bpp, f->depth);
167         break;
168
169       case XCB_XV_IMAGE_FORMAT_INFO_TYPE_YUV:
170         if (f->u_sample_bits != f->v_sample_bits
171          || f->vhorz_u_period != f->vhorz_v_period
172          || f->vvert_u_period != f->vvert_v_period
173          || f->y_sample_bits != 8 || f->u_sample_bits != 8
174          || f->vhorz_y_period != 1 || f->vvert_y_period != 1)
175             goto bad;
176         switch (f->num_planes)
177         {
178           case 1:
179             switch (f->bpp)
180             {
181               /*untested: case 24:
182                 if (f->vhorz_u_period == 1 && f->vvert_u_period == 1)
183                     return VLC_CODEC_I444;
184                 break;*/
185               case 16:
186                 if (f->vhorz_u_period == 2 && f->vvert_u_period == 1)
187                 {
188                     if (!strcmp ((const char *)f->vcomp_order, "YUYV"))
189                         return VLC_CODEC_YUYV;
190                     if (!strcmp ((const char *)f->vcomp_order, "UYVY"))
191                         return VLC_CODEC_UYVY;
192                 }
193                 break;
194             }
195             break;
196           case 3:
197             switch (f->bpp)
198             {
199               case 12:
200                 if (f->vhorz_u_period == 2 && f->vvert_u_period == 2)
201                 {
202                     if (!strcmp ((const char *)f->vcomp_order, "YVU"))
203                         return VLC_CODEC_YV12;
204                     if (!strcmp ((const char *)f->vcomp_order, "YUV"))
205                         return VLC_CODEC_I420;
206                 }
207             }
208             break;
209         }
210     bad:
211         msg_Err (vd, "unknown XVideo YUV format %"PRIx32" (%.4s)", f->id,
212                  f->guid);
213         msg_Dbg (vd, " %"PRIu8" planes, %"PRIu32" bits/pixel, "
214                  "%"PRIu32"/%"PRIu32"/%"PRIu32" bits/sample", f->num_planes,
215                  f->bpp, f->y_sample_bits, f->u_sample_bits, f->v_sample_bits);
216         msg_Dbg (vd, " period: %"PRIu32"/%"PRIu32"/%"PRIu32"x"
217                  "%"PRIu32"/%"PRIu32"/%"PRIu32,
218                  f->vhorz_y_period, f->vhorz_u_period, f->vhorz_v_period,
219                  f->vvert_y_period, f->vvert_u_period, f->vvert_v_period);
220         msg_Warn (vd, " order: %.32s", f->vcomp_order);
221         break;
222     }
223     return 0;
224 }
225
226
227 static const xcb_xv_image_format_info_t *
228 FindFormat (vout_display_t *vd,
229             vlc_fourcc_t chroma, const video_format_t *fmt,
230             xcb_xv_port_t port,
231             const xcb_xv_list_image_formats_reply_t *list,
232             xcb_xv_query_image_attributes_reply_t **restrict pa)
233 {
234     xcb_connection_t *conn = vd->sys->conn;
235     const xcb_xv_image_format_info_t *f, *end;
236
237 #ifndef XCB_XV_OLD
238     f = xcb_xv_list_image_formats_format (list);
239 #else
240     f = (xcb_xv_image_format_info_t *) (list + 1);
241 #endif
242     end = f + xcb_xv_list_image_formats_format_length (list);
243     for (; f < end; f++)
244     {
245         if (chroma != ParseFormat (vd, f))
246             continue;
247
248         xcb_xv_query_image_attributes_reply_t *i;
249         i = xcb_xv_query_image_attributes_reply (conn,
250             xcb_xv_query_image_attributes (conn, port, f->id,
251                 fmt->i_width, fmt->i_height), NULL);
252         if (i == NULL)
253             continue;
254
255         if (i->width != fmt->i_width
256          || i->height != fmt->i_height)
257         {
258             msg_Warn (vd, "incompatible size %ux%u -> %"PRIu32"x%"PRIu32,
259                       fmt->i_width, fmt->i_height,
260                       i->width, i->height);
261             free (i);
262             continue;
263         }
264         *pa = i;
265         return f;
266     }
267     return NULL;
268 }
269
270
271 /**
272  * Get a list of XVideo adaptors for a given window.
273  */
274 static xcb_xv_query_adaptors_reply_t *GetAdaptors (vout_window_t *wnd,
275                                                    xcb_connection_t *conn)
276 {
277     xcb_xv_query_adaptors_cookie_t ck;
278
279     ck = xcb_xv_query_adaptors (conn, wnd->handle.xid);
280     return xcb_xv_query_adaptors_reply (conn, ck, NULL);
281 }
282
283 /**
284  * Probe the X server.
285  */
286 static int Open (vlc_object_t *obj)
287 {
288     vout_display_t *vd = (vout_display_t *)obj;
289     vout_display_sys_t *p_sys = malloc (sizeof (*p_sys));
290     if (p_sys == NULL)
291         return VLC_ENOMEM;
292
293     vd->sys = p_sys;
294
295     /* Connect to X */
296     p_sys->conn = Connect (obj);
297     if (p_sys->conn == NULL)
298     {
299         free (p_sys);
300         return VLC_EGENERIC;
301     }
302
303     if (!CheckXVideo (vd, p_sys->conn))
304     {
305         msg_Warn (vd, "Please enable XVideo 2.2 for faster video display");
306         xcb_disconnect (p_sys->conn);
307         free (p_sys);
308         return VLC_EGENERIC;
309     }
310
311     const xcb_screen_t *screen;
312     p_sys->embed = GetWindow (vd, p_sys->conn, &screen, &p_sys->shm);
313     if (p_sys->embed == NULL)
314     {
315         xcb_disconnect (p_sys->conn);
316         free (p_sys);
317         return VLC_EGENERIC;
318     }
319
320     /* */
321     p_sys->att = NULL;
322     p_sys->pool = NULL;
323
324     /* Cache adaptors infos */
325     p_sys->adaptors = GetAdaptors (p_sys->embed, p_sys->conn);
326     if (p_sys->adaptors == NULL)
327         goto error;
328
329     /* */
330     video_format_t fmt = vd->fmt;
331     bool found_adaptor = false;
332
333     /* FIXME: check max image size */
334     xcb_xv_adaptor_info_iterator_t it;
335     for (it = xcb_xv_query_adaptors_info_iterator (p_sys->adaptors);
336          it.rem > 0;
337          xcb_xv_adaptor_info_next (&it))
338     {
339         const xcb_xv_adaptor_info_t *a = it.data;
340
341         /* FIXME: Open() should fail if none of the ports are usable to VLC */
342         if (!(a->type & XCB_XV_TYPE_IMAGE_MASK))
343             continue;
344
345         xcb_xv_list_image_formats_reply_t *r;
346         r = xcb_xv_list_image_formats_reply (p_sys->conn,
347             xcb_xv_list_image_formats (p_sys->conn, a->base_id), NULL);
348         if (r == NULL)
349             continue;
350
351         const xcb_xv_image_format_info_t *xfmt;
352
353         /* */
354         const vlc_fourcc_t *chromas, chromas_default[] = {
355             fmt.i_chroma,
356             VLC_CODEC_RGB24,
357             VLC_CODEC_RGB15,
358             VLC_CODEC_YUYV,
359             0
360         };
361         if (vlc_fourcc_IsYUV (fmt.i_chroma))
362             chromas = vlc_fourcc_GetYUVFallback (fmt.i_chroma);
363         else
364             chromas = chromas_default;
365
366         for (size_t i = 0; chromas[i]; i++)
367         {
368             vlc_fourcc_t chroma = chromas[i];
369             xfmt = FindFormat (vd, chroma, &fmt, a->base_id, r, &p_sys->att);
370             if (xfmt != NULL)
371             {
372                 fmt.i_chroma = chroma;
373                 goto found_format;
374             }
375         }
376         free (r);
377         continue;
378
379     found_format:
380         /* Grab a port */
381         /* XXX: assume all of an adapter's ports have the same formats */
382         for (unsigned i = 0; i < a->num_ports; i++)
383         {
384              xcb_xv_port_t port = a->base_id + i;
385              xcb_xv_grab_port_reply_t *gr =
386                  xcb_xv_grab_port_reply (p_sys->conn,
387                      xcb_xv_grab_port (p_sys->conn, port,
388                                        XCB_CURRENT_TIME), NULL);
389              uint8_t result = gr ? gr->result : 0xff;
390
391              free (gr);
392              if (result == 0)
393              {
394                  p_sys->port = port;
395                  goto grabbed_port;
396              }
397              msg_Dbg (vd, "cannot grab port %"PRIu32, port);
398         }
399         continue;
400
401     grabbed_port:
402         msg_Dbg (vd, "using port %"PRIu32, p_sys->port);
403
404         p_sys->id = xfmt->id;
405         msg_Dbg (vd, "using image format 0x%"PRIx32, p_sys->id);
406         if (xfmt->type == XCB_XV_IMAGE_FORMAT_INFO_TYPE_RGB)
407         {
408             fmt.i_rmask = xfmt->red_mask;
409             fmt.i_gmask = xfmt->green_mask;
410             fmt.i_bmask = xfmt->blue_mask;
411         }
412         else
413         if (xfmt->num_planes == 3
414          && !strcmp ((const char *)xfmt->vcomp_order, "YVU"))
415             fmt.i_chroma = VLC_CODEC_YV12;
416         free (r);
417         found_adaptor = true;
418         break;
419     }
420     if (!found_adaptor)
421     {
422         msg_Err (vd, "no available XVideo adaptor");
423         goto error;
424     }
425
426     /* Create window */
427     {
428         const uint32_t mask =
429             /* XCB_CW_EVENT_MASK */
430             XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
431             XCB_EVENT_MASK_POINTER_MOTION;
432         xcb_void_cookie_t c;
433         xcb_window_t window = xcb_generate_id (p_sys->conn);
434
435         c = xcb_create_window_checked (p_sys->conn, screen->root_depth, window,
436                                        p_sys->embed->handle.xid, 0, 0, 1, 1, 0,
437                                        XCB_WINDOW_CLASS_INPUT_OUTPUT,
438                                        screen->root_visual,
439                                        XCB_CW_EVENT_MASK, &mask);
440         if (CheckError (vd, p_sys->conn, "cannot create X11 window", c))
441             goto error;
442         p_sys->window = window;
443         msg_Dbg (vd, "using X11 window %08"PRIx32, p_sys->window);
444         xcb_map_window (p_sys->conn, window);
445
446         vout_display_place_t place;
447
448         vout_display_PlacePicture (&place, &vd->source, vd->cfg, false);
449         p_sys->width  = place.width;
450         p_sys->height = place.height;
451
452         /* */
453         const uint32_t values[] = { place.x, place.y, place.width, place.height };
454         xcb_configure_window (p_sys->conn, p_sys->window,
455                               XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
456                               XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
457                               values);
458     }
459
460     /* Create graphic context */
461     p_sys->gc = xcb_generate_id (p_sys->conn);
462     xcb_create_gc (p_sys->conn, p_sys->gc, p_sys->window, 0, NULL);
463     msg_Dbg (vd, "using X11 graphic context %08"PRIx32, p_sys->gc);
464
465     /* */
466     p_sys->pool = NULL;
467
468     /* */
469     vout_display_info_t info = vd->info;
470     info.has_pictures_invalid = false;
471
472     /* Setup vout_display_t once everything is fine */
473     vd->fmt = fmt;
474     vd->info = info;
475
476     vd->get = Get;
477     vd->prepare = NULL;
478     vd->display = Display;
479     vd->control = Control;
480     vd->manage = Manage;
481
482     /* */
483     unsigned width, height;
484     if (!GetWindowSize (p_sys->embed, p_sys->conn, &width, &height))
485         vout_display_SendEventDisplaySize (vd, width, height);
486     vout_display_SendEventFullscreen (vd, false);
487
488     return VLC_SUCCESS;
489
490 error:
491     Close (obj);
492     return VLC_EGENERIC;
493 }
494
495
496 /**
497  * Disconnect from the X server.
498  */
499 static void Close (vlc_object_t *obj)
500 {
501     vout_display_t *vd = (vout_display_t *)obj;
502     vout_display_sys_t *p_sys = vd->sys;
503
504     if (p_sys->pool)
505     {
506         for (unsigned i = 0; i < MAX_PICTURES; i++)
507         {
508             picture_resource_t *res = &p_sys->resource[i];
509
510             if (!res->p->p_pixels)
511                 break;
512             PictureResourceFree (res, p_sys->conn);
513         }
514         picture_pool_Delete (p_sys->pool);
515     }
516
517     free (p_sys->att);
518     free (p_sys->adaptors);
519     vout_display_DeleteWindow (vd, p_sys->embed);
520     xcb_disconnect (p_sys->conn);
521     free (p_sys);
522 }
523
524 /**
525  * Return a direct buffer
526  */
527 static picture_t *Get (vout_display_t *vd)
528 {
529     vout_display_sys_t *p_sys = vd->sys;
530
531     if (!p_sys->pool)
532     {
533         picture_t *pic = picture_New (vd->fmt.i_chroma,
534                                       p_sys->att->width, p_sys->att->height, 0);
535         if (!pic)
536             return NULL;
537
538         memset (p_sys->resource, 0, sizeof(p_sys->resource));
539
540         const uint32_t *offsets =
541             xcb_xv_query_image_attributes_offsets (p_sys->att);
542         p_sys->data_size = p_sys->att->data_size;
543
544         unsigned count;
545         picture_t *pic_array[MAX_PICTURES];
546         for (count = 0; count < MAX_PICTURES; count++)
547         {
548             picture_resource_t *res = &p_sys->resource[count];
549
550             for (int i = 0; i < pic->i_planes; i++)
551             {
552                 res->p[i].i_lines = pic->p[i].i_lines; /* FIXME seems wrong*/
553                 res->p[i].i_pitch = pic->p[i].i_pitch;
554             }
555             if (PictureResourceAlloc (vd, res, p_sys->att->data_size,
556                                       p_sys->conn, p_sys->shm))
557                 break;
558
559             /* Allocate further planes as specified by XVideo */
560             /* We assume that offsets[0] is zero */
561             for (int i = 1; i < pic->i_planes; i++)
562                 res->p[i].p_pixels = res->p[0].p_pixels + offsets[i];
563             pic_array[count] = picture_NewFromResource (&vd->fmt, res);
564             if (!pic_array[count])
565             {
566                 PictureResourceFree (res, p_sys->conn);
567                 memset (res, 0, sizeof(*res));
568                 break;
569             }
570         }
571         picture_Release (pic);
572
573         if (count == 0)
574             return NULL;
575
576         p_sys->pool = picture_pool_New (count, pic_array);
577         if (!p_sys->pool)
578         {
579             /* TODO release picture resources */
580             return NULL;
581         }
582         /* FIXME should also do it in case of error ? */
583         xcb_flush (p_sys->conn);
584     }
585
586     return picture_pool_Get (p_sys->pool);
587 }
588
589 /**
590  * Sends an image to the X server.
591  */
592 static void Display (vout_display_t *vd, picture_t *pic)
593 {
594     vout_display_sys_t *p_sys = vd->sys;
595     xcb_shm_seg_t segment = pic->p_sys->segment;
596     xcb_void_cookie_t ck;
597
598     if (segment)
599         ck = xcb_xv_shm_put_image_checked (p_sys->conn, p_sys->port,
600                               p_sys->window, p_sys->gc, segment, p_sys->id, 0,
601                    /* Src: */ vd->source.i_x_offset,
602                               vd->source.i_y_offset,
603                               vd->source.i_visible_width,
604                               vd->source.i_visible_height,
605                    /* Dst: */ 0, 0, p_sys->width, p_sys->height,
606                 /* Memory: */ pic->p->i_pitch / pic->p->i_pixel_pitch,
607                               pic->p->i_visible_lines, false);
608     else
609         ck = xcb_xv_put_image_checked (p_sys->conn, p_sys->port, p_sys->window,
610                           p_sys->gc, p_sys->id,
611                           vd->source.i_x_offset,
612                           vd->source.i_y_offset,
613                           vd->source.i_visible_width,
614                           vd->source.i_visible_height,
615                           0, 0, p_sys->width, p_sys->height,
616                           vd->source.i_width, vd->source.i_height,
617                           p_sys->data_size, pic->p->p_pixels);
618
619     /* Wait for reply. See x11.c for rationale. */
620     xcb_generic_error_t *e = xcb_request_check (p_sys->conn, ck);
621     if (e != NULL)
622     {
623         msg_Dbg (vd, "%s: X11 error %d", "cannot put image", e->error_code);
624         free (e);
625     }
626
627     picture_Release (pic);
628 }
629
630 static int Control (vout_display_t *vd, int query, va_list ap)
631 {
632     vout_display_sys_t *p_sys = vd->sys;
633
634     switch (query)
635     {
636     case VOUT_DISPLAY_CHANGE_FULLSCREEN:
637     {
638         const vout_display_cfg_t *c = va_arg (ap, const vout_display_cfg_t *);
639         return vout_window_SetFullScreen (p_sys->embed, c->is_fullscreen);
640     }
641
642     case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
643     case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
644     case VOUT_DISPLAY_CHANGE_ZOOM:
645     case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
646     case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
647     {
648         const vout_display_cfg_t *cfg;
649         const video_format_t *source;
650
651         if (query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT
652          || query == VOUT_DISPLAY_CHANGE_SOURCE_CROP)
653         {
654             source = (const video_format_t *)va_arg (ap, const video_format_t *);
655             cfg = vd->cfg;
656         }
657         else
658         {
659             source = &vd->source;
660             cfg = (const vout_display_cfg_t*)va_arg (ap, const vout_display_cfg_t *);
661         }
662
663         /* */
664         if (query == VOUT_DISPLAY_CHANGE_DISPLAY_SIZE
665          && (cfg->display.width  != vd->cfg->display.width
666            ||cfg->display.height != vd->cfg->display.height)
667          && vout_window_SetSize (p_sys->embed,
668                                   cfg->display.width,
669                                   cfg->display.height))
670             return VLC_EGENERIC;
671
672         vout_display_place_t place;
673         vout_display_PlacePicture (&place, source, cfg, false);
674         p_sys->width  = place.width;
675         p_sys->height = place.height;
676
677         /* Move the picture within the window */
678         const uint32_t values[] = { place.x, place.y,
679                                     place.width, place.height, };
680         xcb_configure_window (p_sys->conn, p_sys->window,
681                               XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
682                             | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
683                               values);
684         xcb_flush (p_sys->conn);
685         return VLC_SUCCESS;
686     }
687     case VOUT_DISPLAY_CHANGE_ON_TOP:
688     {
689         int on_top = (int)va_arg (ap, int);
690         return vout_window_SetOnTop (p_sys->embed, on_top);
691     }
692
693     /* TODO */
694 #if 0
695     /* Hide the mouse. It will be send when
696      * vout_display_t::info.b_hide_mouse is false */
697     VOUT_DISPLAY_HIDE_MOUSE,
698 #endif
699     case VOUT_DISPLAY_RESET_PICTURES:
700         assert(0);
701     default:
702         msg_Err (vd, "Unknown request in XCB vout display");
703         return VLC_EGENERIC;
704     }
705 }
706
707 static void Manage (vout_display_t *vd)
708 {
709     vout_display_sys_t *p_sys = vd->sys;
710
711     ManageEvent (vd, p_sys->conn, p_sys->window);
712 }
713