]> git.sesse.net Git - vlc/blob - modules/video_output/omapfb.c
Removed es_format_t::i_aspect.
[vlc] / modules / video_output / omapfb.c
1 /*****************************************************************************
2 * omapfb.c : omap framebuffer plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2008-2009 the VideoLAN team
5 * $Id$
6 *
7 * Authors: Antoine Lejeune <phytos @ videolan.org>
8 *          Based on fb.c and work of Siarhei Siamashka on mplayer for Maemo
9 *          Needs a recent omapfb.h to compile
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <errno.h>                                                 /* ENOMEM */
31 #include <fcntl.h>                                                 /* open() */
32 #include <unistd.h>                                               /* close() */
33
34 #include <sys/ioctl.h>
35 #include <sys/mman.h>                                              /* mmap() */
36
37 #include <linux/fb.h>
38 #include <asm/arch-omap/omapfb.h>
39
40 /* Embedded window handling */
41 #include <X11/Xlib.h>
42 #include <X11/Xutil.h>
43
44 #include <vlc_common.h>
45 #include <vlc_plugin.h>
46 #include <vlc_vout.h>
47 #include <vlc_vout_window.h>
48 #include <vlc_playlist.h>
49 #include <vlc_charset.h>
50
51 /*****************************************************************************
52 * Local prototypes
53 *****************************************************************************/
54 static int  Create           ( vlc_object_t * );
55 static void Destroy          ( vlc_object_t * );
56
57 static int  Init             ( vout_thread_t * );
58 static void End              ( vout_thread_t * );
59 static int  Manage           ( vout_thread_t * );
60 static void DisplayVideo     ( vout_thread_t *, picture_t * );
61 static int  Control          ( vout_thread_t *, int, va_list );
62
63 static void FreePicture      ( vout_thread_t *, picture_t * );
64
65 static int  OpenDisplay      ( vout_thread_t * );
66 static void CloseDisplay     ( vout_thread_t * );
67 static void UpdateScreen     ( vout_thread_t *,
68                                int, int, int, int, int, int, int );
69
70 static int  InitWindow       ( vout_thread_t * );
71 static void CreateWindow     ( vout_sys_t * );
72 static void ToggleFullScreen ( vout_thread_t * );
73
74 /*****************************************************************************
75  * Module descriptor
76  *****************************************************************************/
77 #define FB_DEV_VAR "omapfbdev"
78
79 #define DEVICE_TEXT N_("OMAP Framebuffer device")
80 #define DEVICE_LONGTEXT N_( \
81     "OMAP Framebuffer device to use for rendering (usually /dev/fb0).")
82
83 #define CHROMA_TEXT N_("Chroma used.")
84 #define CHROMA_LONGTEXT N_( \
85     "Force use of a specific chroma for output. Default is Y420 (specific to N770/N8xx hardware)." )
86
87 #define OVERLAY_TEXT N_("Embed the overlay")
88 #define OVERLAY_LONGTEXT N_( \
89     "Embed the framebuffer overlay into a X11 window" )
90
91 vlc_module_begin();
92     set_shortname( "OMAP framebuffer" );
93     set_category( CAT_VIDEO );
94     set_subcategory( SUBCAT_VIDEO_VOUT );
95     add_file( FB_DEV_VAR, "/dev/fb0", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
96               false )
97     add_string( "omap-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
98                 true )
99     add_bool( "omap-embedded", true, NULL, OVERLAY_TEXT, OVERLAY_LONGTEXT,
100                  true )
101     set_description( N_("OMAP framebuffer video output") );
102     set_capability( "video output", 200 );
103     set_callbacks( Create, Destroy );
104 vlc_module_end();
105
106 /*****************************************************************************
107  * omap_window_t: simple structure with the geometry of a window
108  *****************************************************************************/
109 struct omap_window_t
110 {
111     uint32_t i_x;
112     uint32_t i_y;
113     uint32_t i_width;
114     uint32_t i_height;
115 };
116
117 /*****************************************************************************
118 * vout_sys_t: video output omap framebuffer method descriptor
119  *****************************************************************************
120  * This structure is part of the video output thread descriptor.
121  * It describes the FB specific properties of an output thread.
122  *****************************************************************************/
123 struct vout_sys_t
124 {
125     /* Framebuffer information */
126     int                         i_fd;                       /* device handle */
127     struct fb_var_screeninfo    fb_vinfo;        /* current mode information */
128     struct fb_fix_screeninfo    fb_finfo;
129     struct omapfb_caps          caps;
130     bool                        b_tearsync;
131
132     /* Window information */
133     struct omap_window_t output_window;    /* Size of the real output window */
134     struct omap_window_t main_window;  /* Size of the area we got to display */
135     struct omap_window_t embedded_window;     /* Size of the embedded window */
136
137     /* Video information */
138     uint32_t             i_video_width;                       /* video width */
139     uint32_t             i_video_height;                     /* video height */
140     vlc_fourcc_t         i_chroma;
141     int                  i_color_format;                   /* OMAPFB_COLOR_* */
142     bool                 b_video_enabled;        /* Video must be displayed? */
143     picture_t           *p_output_picture;
144
145     /* Video memory */
146     uint8_t    *p_video;                                      /* base adress */
147     uint8_t    *p_center;                                   /* output adress */
148     size_t      i_page_size;                                    /* page size */
149     int         i_bytes_per_pixel;                /* Bytes used by one pixel */
150     int         i_line_len;                   /* Length of one line in bytes */
151
152     /* X11 */
153     Display   *p_display;
154     vout_window_t *owner_window;
155     Window     window;
156     mtime_t    i_time_button_last_pressed;         /* To detect double click */
157
158     /* Dummy memory */
159     int        i_null_fd;
160     uint8_t   *p_null;
161 };
162
163 /*****************************************************************************
164  * Create: allocates omapfb video thread output method
165  *****************************************************************************
166  * This function allocates and initializes a FB vout method.
167  *****************************************************************************/
168 static int Create( vlc_object_t *p_this )
169 {
170     vout_thread_t *p_vout = (vout_thread_t *)p_this;
171     vout_sys_t    *p_sys;
172
173     if( p_vout->fmt_in.i_chroma != VLC_CODEC_I420 &&
174         p_vout->fmt_in.i_chroma != VLC_CODEC_YV12 )
175         return VLC_EGENERIC;
176
177     /* Allocate instance and initialize some members */
178     p_vout->p_sys = p_sys = calloc( 1, sizeof( vout_sys_t ) );
179     if( p_vout->p_sys == NULL )
180         return VLC_ENOMEM;
181
182     p_vout->pf_init = Init;
183     p_vout->pf_end = End;
184     p_vout->pf_manage = Manage;
185     p_vout->pf_render = NULL;
186     p_vout->pf_display = DisplayVideo;
187     p_vout->pf_control = Control;
188     p_sys->b_video_enabled = true;
189
190     if( OpenDisplay( p_vout ) )
191     {
192         free( p_vout->p_sys );
193         return VLC_EGENERIC;
194     }
195
196     if( InitWindow( p_vout ) )
197     {
198         free( p_vout->p_sys );
199         return VLC_EGENERIC;
200     }
201
202     return VLC_SUCCESS;
203 }
204
205 /*****************************************************************************
206  * Destroy: destroy omapfb video thread output method
207  *****************************************************************************
208  * Terminate an output method created by Create
209  *****************************************************************************/
210 static void Destroy( vlc_object_t *p_this )
211 {
212     vout_thread_t *p_vout = (vout_thread_t *)p_this;
213
214     CloseDisplay( p_vout );
215
216     if( p_vout->p_sys->owner_window )
217     {
218         vout_window_Delete( p_vout->p_sys->owner_window );
219         XCloseDisplay( p_vout->p_sys->p_display );
220     }
221
222     /* Destroy structure */
223     free( p_vout->p_sys );
224 }
225
226
227 /*****************************************************************************
228  * Init: initialize omap framebuffer video thread output method
229  *****************************************************************************/
230 static int Init( vout_thread_t *p_vout )
231 {
232     vout_sys_t *p_sys = (vout_sys_t *)p_vout->p_sys;
233
234     // We want to keep the same aspect
235     p_vout->output.i_aspect = p_vout->render.i_aspect;
236     p_vout->fmt_out.i_sar_num = p_vout->render.i_aspect * p_vout->render.i_height;
237     p_vout->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR      * p_vout->render.i_width;
238     // We ask where the video should be displayed in the video area
239     vout_PlacePicture( p_vout, p_sys->main_window.i_width,
240                        p_sys->main_window.i_height,
241                        &p_sys->output_window.i_x,
242                        &p_sys->output_window.i_y,
243                        &p_sys->output_window.i_width,
244                        &p_sys->output_window.i_height );
245     p_sys->output_window.i_x = ( p_sys->output_window.i_x +
246                                  p_sys->main_window.i_x ) & ~1;
247     p_sys->output_window.i_y = ( p_sys->output_window.i_y +
248                                  p_sys->main_window.i_y ) & ~1;
249
250     // Hardware upscaling better than software
251     if( p_vout->fmt_render.i_width <= p_sys->main_window.i_width &&
252         p_vout->fmt_render.i_height <= p_sys->main_window.i_height )
253     {
254         p_sys->i_video_width =
255         p_vout->output.i_width =
256         p_vout->fmt_out.i_width =
257         p_vout->fmt_out.i_visible_width = p_vout->fmt_render.i_width;
258         p_sys->i_video_height =
259         p_vout->output.i_height =
260         p_vout->fmt_out.i_height =
261         p_vout->fmt_out.i_visible_height = p_vout->fmt_render.i_height;
262     }
263     else
264     {
265         p_sys->i_video_width =
266         p_vout->output.i_width =
267         p_vout->fmt_out.i_width =
268         p_vout->fmt_out.i_visible_width = p_sys->output_window.i_width;
269         p_sys->i_video_height =
270         p_vout->output.i_height =
271         p_vout->fmt_out.i_height =
272         p_vout->fmt_out.i_visible_height = p_sys->output_window.i_height;
273     }
274
275     p_vout->output.i_chroma =
276     p_vout->fmt_out.i_chroma = VLC_FOURCC( 'Y','4','2','0' );
277     p_sys->i_color_format = OMAPFB_COLOR_YUV420;
278
279     // place in the framebuffer where we have to write
280     p_sys->p_center = p_sys->p_video + p_sys->output_window.i_x*p_sys->i_bytes_per_pixel
281                       + p_sys->output_window.i_y*p_sys->i_line_len;
282
283     // We get and set a direct render vlc picture
284     I_OUTPUTPICTURES = 0;
285     picture_t *p_pic = NULL;
286     int i_index;
287
288     for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
289     {
290         if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
291         {
292             p_pic = p_vout->p_picture + i_index;
293             break;
294         }
295     }
296
297     /* Allocate the picture */
298     if( p_pic == NULL )
299     {
300         return VLC_EGENERIC;
301     }
302
303     p_sys->p_output_picture = p_pic;
304     p_pic->p->p_pixels = p_vout->p_sys->p_center;
305     p_pic->p->i_pixel_pitch = p_vout->p_sys->i_bytes_per_pixel;
306     p_pic->p->i_lines = p_sys->i_video_height;
307     p_pic->p->i_visible_lines = p_sys->i_video_height;
308     p_pic->p->i_pitch = p_sys->i_line_len;
309     p_pic->p->i_visible_pitch = p_sys->i_line_len;
310     p_pic->i_planes = 1;
311     p_pic->i_status = DESTROYED_PICTURE;
312     p_pic->i_type   = DIRECT_PICTURE;
313
314     PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
315
316     I_OUTPUTPICTURES++;
317
318     return VLC_SUCCESS;
319 }
320
321 /*****************************************************************************
322  * End: terminate omap framebuffer video thread output method
323  *****************************************************************************/
324 static void End( vout_thread_t *p_vout )
325 {
326     /* Clear the screen */
327     UpdateScreen( p_vout, 0, 0,
328                   p_vout->p_sys->fb_vinfo.xres,
329                   p_vout->p_sys->fb_vinfo.yres,
330                   p_vout->p_sys->fb_vinfo.xres,
331                   p_vout->p_sys->fb_vinfo.yres,
332                   OMAPFB_COLOR_RGB565 );
333 }
334
335 /*****************************************************************************
336  * Control: control facility for the vout
337  *****************************************************************************/
338 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
339 {
340     return VLC_EGENERIC;
341 }
342
343 /*****************************************************************************
344 * FreePicture: Destroy the picture and make it free again
345 ******************************************************************************/
346 static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic )
347 {
348     p_pic->p->p_pixels = NULL;
349     p_pic->i_status = FREE_PICTURE;
350 }
351
352 /*****************************************************************************
353  * Manage: handle omapfb events
354  *****************************************************************************
355  * This function should be called regularly by video output thread.
356  *****************************************************************************/
357 static int Manage( vout_thread_t *p_vout )
358 {
359     XEvent xevent;
360
361     while( XPending( p_vout->p_sys->p_display ) )
362     {
363         XNextEvent( p_vout->p_sys->p_display, &xevent );
364
365         if( xevent.type == ButtonPress &&
366             ((XButtonEvent *)&xevent)->button == Button1 )
367         {
368             /* detect double-clicks */
369             if( ( ((XButtonEvent *)&xevent)->time -
370                     p_vout->p_sys->i_time_button_last_pressed ) < 300 )
371             {
372                 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
373             }
374
375             p_vout->p_sys->i_time_button_last_pressed =
376                         ((XButtonEvent *)&xevent)->time;
377         }
378         else if( ( xevent.type == VisibilityNotify &&
379                  xevent.xvisibility.state != VisibilityUnobscured ) ||
380                  xevent.type == UnmapNotify )
381         {
382             UpdateScreen( p_vout, 0, 0,
383                           p_vout->p_sys->fb_vinfo.xres,
384                           p_vout->p_sys->fb_vinfo.yres,
385                           p_vout->p_sys->fb_vinfo.xres,
386                           p_vout->p_sys->fb_vinfo.yres,
387                           OMAPFB_COLOR_RGB565 );
388             p_vout->p_sys->b_video_enabled = false;
389             p_vout->p_sys->p_output_picture->p->p_pixels =
390                 p_vout->p_sys->p_null;
391          }
392     }
393
394     if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
395     {
396         /* Update the object variable and trigger callback */
397         p_vout->b_fullscreen = !p_vout->b_fullscreen;
398         var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
399
400         if( p_vout->p_sys->owner_window )
401             vout_window_SetFullscreen( p_vout->p_sys->owner_window,
402                                        p_vout->b_fullscreen );
403         p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
404     }
405
406     if( p_vout->i_changes & VOUT_SIZE_CHANGE )
407     {
408         FreePicture( p_vout, p_vout->p_sys->p_output_picture );
409         if( Init( p_vout ) )
410         {
411             msg_Err( p_vout, "cannot reinit framebuffer screen" );
412             return VLC_EGENERIC;
413         }
414     }
415     return VLC_SUCCESS;
416 }
417
418 /*****************************************************************************
419  * DisplayVideo: displays previously rendered output
420  *****************************************************************************
421  * This function update the screen resulting in the display of the last
422  * rendered picture.
423  *****************************************************************************/
424 static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
425 {
426     VLC_UNUSED( p_pic );
427
428     if( !p_vout->p_sys->b_video_enabled )
429         return;
430
431     UpdateScreen( p_vout,
432                   p_vout->p_sys->output_window.i_x,
433                   p_vout->p_sys->output_window.i_y,
434                   p_vout->p_sys->i_video_width,
435                   p_vout->p_sys->i_video_height,
436                   p_vout->p_sys->output_window.i_width,
437                   p_vout->p_sys->output_window.i_height,
438                   p_vout->p_sys->i_color_format );
439
440     // Wait for the window to be fully displayed
441     ioctl( p_vout->p_sys->i_fd, OMAPFB_SYNC_GFX);
442 }
443
444 /*****************************************************************************
445  * OpenDisplay: initialize framebuffer
446  *****************************************************************************/
447 static int OpenDisplay( vout_thread_t *p_vout )
448 {
449     vout_sys_t *p_sys = (vout_sys_t *) p_vout->p_sys;
450     char *psz_device;                             /* framebuffer device path */
451
452     /* Open framebuffer device */
453     if( !(psz_device = var_CreateGetNonEmptyString( p_vout, FB_DEV_VAR )) )
454     {
455         msg_Err( p_vout, "don't know which fb device to open" );
456         return VLC_EGENERIC;
457     }
458
459     p_sys->i_fd = utf8_open( psz_device, O_RDWR );
460     if( p_sys->i_fd == -1 )
461     {
462         msg_Err( p_vout, "cannot open %s (%m)", psz_device );
463         free( psz_device );
464         return VLC_EGENERIC;
465     }
466     free( psz_device );
467
468     // Get caps, try older interface if needed
469     if( ioctl( p_sys->i_fd, OMAPFB_GET_CAPS, &p_sys->caps ) != 0 )
470     {
471         if( ioctl( p_sys->i_fd, OMAP_IOR( 42, unsigned long ), &p_sys->caps ) != 0 )
472         {
473             msg_Err( p_vout, "OMAPFB_GET_CAPS ioctl failed" );
474             close( p_sys->i_fd );
475             return VLC_EGENERIC;
476         }
477     }
478
479     if( ( p_sys->caps.ctrl & OMAPFB_CAPS_TEARSYNC ) != 0 )
480         p_sys->b_tearsync = true;
481
482     if( ioctl( p_sys->i_fd, FBIOGET_VSCREENINFO, &p_sys->fb_vinfo ) )
483     {
484         msg_Err( p_vout, "Can't get VSCREENINFO: %m" );
485         close( p_sys->i_fd );
486         return VLC_EGENERIC;
487     }
488     if( ioctl( p_sys->i_fd, FBIOGET_FSCREENINFO, &p_sys->fb_finfo ) )
489     {
490         msg_Err( p_vout, "Can't get FSCREENINFO: %m" );
491         close( p_sys->i_fd );
492         return VLC_EGENERIC;
493     }
494
495     p_sys->i_bytes_per_pixel = 2;
496     p_sys->i_page_size = p_sys->fb_finfo.smem_len;
497     p_sys->i_line_len = p_sys->fb_finfo.line_length;
498
499     if( (p_sys->p_video = (uint8_t *)mmap( 0, p_sys->i_page_size, PROT_READ | PROT_WRITE, MAP_SHARED,
500                                             p_sys->i_fd, 0 )) == MAP_FAILED )
501     {
502         msg_Err( p_vout, "Can't mmap: %m" );
503         close( p_sys->i_fd );
504         return VLC_EGENERIC;
505     }
506
507     p_sys->p_display = XOpenDisplay( NULL );
508
509     /* Open /dev/null and map it */
510     p_sys->i_null_fd = utf8_open( "/dev/zero", O_RDWR );
511     if( p_sys->i_null_fd == -1 )
512     {
513         msg_Err( p_vout, "cannot open /dev/zero (%m)" );
514         munmap( p_sys->p_video, p_sys->i_page_size );
515         close( p_sys->i_fd );
516         return VLC_EGENERIC;
517     }
518
519     if( (p_sys->p_null = (uint8_t *)mmap( 0, p_sys->i_page_size, PROT_READ | PROT_WRITE,
520                                           MAP_PRIVATE, p_sys->i_null_fd, 0 )) == MAP_FAILED )
521     {
522         msg_Err( p_vout, "Can't mmap 2: %m" );
523         munmap( p_sys->p_video, p_sys->i_page_size );
524         close( p_sys->i_null_fd );
525         close( p_sys->i_fd );
526         return VLC_EGENERIC;
527     }
528
529     return VLC_SUCCESS;
530 }
531
532 /*****************************************************************************
533  * CloseDisplay: terminate FB video thread output method
534  *****************************************************************************/
535 static void CloseDisplay( vout_thread_t *p_vout )
536 {
537     munmap( p_vout->p_sys->p_video, p_vout->p_sys->i_page_size );
538     munmap( p_vout->p_sys->p_null,  p_vout->p_sys->i_page_size );
539
540     close( p_vout->p_sys->i_fd );
541     close( p_vout->p_sys->i_null_fd );
542 }
543
544 /*****************************************************************************
545  * UpdateScreen: update the screen of the omapfb
546  *****************************************************************************/
547 static void UpdateScreen( vout_thread_t *p_vout, int i_x, int i_y,
548                           int i_width, int i_height,
549                           int i_out_width, int i_out_height, int i_format )
550 {
551     struct omapfb_update_window update;
552     update.x = i_x;
553     update.y = i_y;
554     update.width = i_width;
555     update.height = i_height;
556     update.out_x = i_x;
557     update.out_y = i_y;
558     update.out_width = i_out_width;
559     update.out_height = i_out_height;
560     update.format = i_format;
561     if( p_vout->p_sys->b_tearsync )
562         update.format |= OMAPFB_FORMAT_FLAG_TEARSYNC;
563     ioctl( p_vout->p_sys->i_fd, OMAPFB_UPDATE_WINDOW, &update );
564 }
565
566 /*****************************************************************************
567  * InitWindow: get embedded window and init X11
568  *****************************************************************************/
569 static int InitWindow( vout_thread_t *p_vout )
570 {
571     vout_sys_t *p_sys = (vout_sys_t *)p_vout->p_sys;
572
573     if( var_CreateGetBool( p_vout, "omap-embedded" ) )
574     {
575         p_sys->p_display = XOpenDisplay( NULL );
576
577         // Request window from interface
578         vout_window_cfg_t wnd_cfg;
579
580         memset( &wnd_cfg, 0, sizeof(wnd_cfg) );
581         wnd_cfg.type   = VOUT_WINDOW_TYPE_XID;
582         wnd_cfg.x      = p_sys->embedded_window.i_x;
583         wnd_cfg.y      = p_sys->embedded_window.i_y;
584         wnd_cfg.width  = p_sys->embedded_window.i_width;
585         wnd_cfg.height = p_sys->embedded_window.i_height;
586
587         p_sys->owner_window = vout_window_New( VLC_OBJECT(p_vout), NULL, &wnd_cfg );
588         p_sys->main_window = p_sys->embedded_window;
589
590         // We have to create a new window to get some events
591         CreateWindow( p_sys );
592     }
593     else
594     {
595         // No embedding, fullscreen framebuffer overlay with no events handling
596         p_sys->main_window.i_x = p_sys->main_window.i_y = 0;
597         p_sys->main_window.i_width = p_sys->fb_vinfo.xres;
598         p_sys->main_window.i_height = p_sys->fb_vinfo.yres;
599         p_vout->b_fullscreen = true;
600         var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
601     }
602
603     return VLC_SUCCESS;
604 }
605
606 static void CreateWindow( vout_sys_t *p_sys )
607 {
608     XSetWindowAttributes    xwindow_attributes;
609     xwindow_attributes.backing_store = Always;
610     xwindow_attributes.background_pixel =
611         BlackPixel( p_sys->p_display, DefaultScreen(p_sys->p_display) );
612     xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask
613                                   | VisibilityChangeMask;
614     p_sys->window = XCreateWindow( p_sys->p_display,
615                                    p_sys->owner_window->xid,
616                                    0, 0,
617                                    p_sys->main_window.i_width,
618                                    p_sys->main_window.i_height,
619                                    0,
620                                    0, InputOutput, 0,
621                                    CWBackingStore | CWBackPixel | CWEventMask,
622                                    &xwindow_attributes );
623
624     XMapWindow( p_sys->p_display, p_sys->window );
625     XSelectInput( p_sys->p_display, p_sys->owner_window->xid,
626                   StructureNotifyMask );
627 }
628