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