1 /*****************************************************************************
2 * omapfb.c : omap framebuffer plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2008-2009 the VideoLAN team
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
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.
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.
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 *****************************************************************************/
30 #include <errno.h> /* ENOMEM */
31 #include <fcntl.h> /* open() */
32 #include <unistd.h> /* close() */
34 #include <sys/ioctl.h>
35 #include <sys/mman.h> /* mmap() */
38 #include <asm/arch-omap/omapfb.h>
40 /* Embedded window handling */
42 #include <X11/Xutil.h>
43 #include <X11/keysym.h>
49 #include <vlc_common.h>
50 #include <vlc_plugin.h>
53 #include <vlc_window.h>
54 #include <vlc_playlist.h>
56 /*****************************************************************************
58 *****************************************************************************/
59 static int Create ( vlc_object_t * );
60 static void Destroy ( vlc_object_t * );
62 static int Init ( vout_thread_t * );
63 static void End ( vout_thread_t * );
64 static int Manage ( vout_thread_t * );
65 static void DisplayVideo ( vout_thread_t *, picture_t * );
66 static int Control ( vout_thread_t *, int, va_list );
68 static void FreePicture ( vout_thread_t *, picture_t * );
70 static int OpenDisplay ( vout_thread_t * );
71 static void CloseDisplay ( vout_thread_t * );
72 static void UpdateScreen ( vout_thread_t *,
73 int, int, int, int, int, int, int );
75 static int InitWindow ( vout_thread_t * );
76 static void CreateWindow ( vout_sys_t * );
77 static void ToggleFullScreen ( vout_thread_t * );
80 static const int i_backlight_on_interval = 300;
83 /*****************************************************************************
85 *****************************************************************************/
86 #define FB_DEV_VAR "omapfbdev"
88 #define DEVICE_TEXT N_("OMAP Framebuffer device")
89 #define DEVICE_LONGTEXT N_( \
90 "OMAP Framebuffer device to use for rendering (usually /dev/fb0).")
92 #define CHROMA_TEXT N_("Chroma used.")
93 #define CHROMA_LONGTEXT N_( \
94 "Force use of a specific chroma for output. Default is Y420 (specific to N770/N8xx hardware)." )
96 #define OVERLAY_TEXT N_("Embed the overlay")
97 #define OVERLAY_LONGTEXT N_( \
98 "Embed the framebuffer overlay into a X11 window" )
101 set_shortname( "OMAP framebuffer" );
102 set_category( CAT_VIDEO );
103 set_subcategory( SUBCAT_VIDEO_VOUT );
104 add_file( FB_DEV_VAR, "/dev/fb0", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
106 add_string( "omap-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
108 add_bool( "omap-embedded", true, NULL, OVERLAY_TEXT, OVERLAY_LONGTEXT,
110 set_description( N_("OMAP framebuffer video output") );
111 set_capability( "video output", 200 );
112 set_callbacks( Create, Destroy );
115 /*****************************************************************************
116 * omap_window_t: simple structure with the geometry of a window
117 *****************************************************************************/
126 /*****************************************************************************
127 * vout_sys_t: video output omap framebuffer method descriptor
128 *****************************************************************************
129 * This structure is part of the video output thread descriptor.
130 * It describes the FB specific properties of an output thread.
131 *****************************************************************************/
134 /* Framebuffer information */
135 int i_fd; /* device handle */
136 struct fb_var_screeninfo fb_vinfo; /* current mode information */
137 struct fb_fix_screeninfo fb_finfo;
138 struct omapfb_caps caps;
141 /* Window information */
142 struct omap_window_t output_window; /* Size of the real output window */
143 struct omap_window_t main_window; /* Size of the area we got to display */
144 struct omap_window_t embedded_window; /* Size of the embedded window */
146 /* Video information */
147 uint32_t i_video_width; /* video width */
148 uint32_t i_video_height; /* video height */
149 vlc_fourcc_t i_chroma;
150 int i_color_format; /* OMAPFB_COLOR_* */
152 bool b_video_enabled; /* Video must be displayed? */
153 picture_t *p_output_picture;
156 uint8_t *p_video; /* base adress */
157 uint8_t *p_center; /* output adress */
158 size_t i_page_size; /* page size */
159 int i_bytes_per_pixel; /* Bytes used by one pixel */
160 int i_line_len; /* Length of one line in bytes */
164 vout_window_t *owner_window;
166 mtime_t i_time_button_last_pressed; /* To detect double click */
173 osso_context_t *p_octx;
174 int i_backlight_on_counter;
178 /*****************************************************************************
179 * Create: allocates omapfb video thread output method
180 *****************************************************************************
181 * This function allocates and initializes a FB vout method.
182 *****************************************************************************/
183 static int Create( vlc_object_t *p_this )
185 vout_thread_t *p_vout = (vout_thread_t *)p_this;
188 if( p_vout->fmt_in.i_chroma != VLC_CODEC_I420 &&
189 p_vout->fmt_in.i_chroma != VLC_CODEC_YV12 )
192 /* Allocate instance and initialize some members */
193 p_vout->p_sys = p_sys = calloc( 1, sizeof( vout_sys_t ) );
194 if( p_vout->p_sys == NULL )
197 p_vout->pf_init = Init;
198 p_vout->pf_end = End;
199 p_vout->pf_manage = Manage;
200 p_vout->pf_render = NULL;
201 p_vout->pf_display = DisplayVideo;
202 p_vout->pf_control = Control;
204 p_sys->b_embed = var_CreateGetInteger( p_vout, "omap-embedded" );
205 p_sys->b_video_enabled = true;
207 if( OpenDisplay( p_vout ) )
209 free( p_vout->p_sys );
213 if( InitWindow( p_vout ) )
215 free( p_vout->p_sys );
220 p_vout->p_sys->i_backlight_on_counter = i_backlight_on_interval;
221 p_vout->p_sys->p_octx = osso_initialize( "vlc", VERSION, 0, NULL );
222 if ( p_vout->p_sys->p_octx == NULL ) {
223 msg_Err( p_vout, "Could not get osso context" );
225 msg_Dbg( p_vout, "Initialized osso context" );
232 /*****************************************************************************
233 * Destroy: destroy omapfb video thread output method
234 *****************************************************************************
235 * Terminate an output method created by Create
236 *****************************************************************************/
237 static void Destroy( vlc_object_t *p_this )
239 vout_thread_t *p_vout = (vout_thread_t *)p_this;
241 CloseDisplay( p_vout );
243 if( p_vout->p_sys->b_embed )
245 vout_ReleaseWindow( p_vout->p_sys->owner_window );
246 if( p_vout->b_fullscreen )
247 XDestroyWindow( p_vout->p_sys->p_display, p_vout->p_sys->window );
248 XCloseDisplay( p_vout->p_sys->p_display );
252 if ( p_vout->p_sys->p_octx != NULL ) {
253 msg_Dbg( p_vout, "Deinitializing osso context" );
254 osso_deinitialize( p_vout->p_sys->p_octx );
258 /* Destroy structure */
259 free( p_vout->p_sys );
263 /*****************************************************************************
264 * Init: initialize omap framebuffer video thread output method
265 *****************************************************************************/
266 static int Init( vout_thread_t *p_vout )
268 vout_sys_t *p_sys = (vout_sys_t *)p_vout->p_sys;
270 // We want to keep the same aspect
271 p_vout->fmt_out.i_aspect = p_vout->output.i_aspect = p_vout->render.i_aspect;
272 // We ask where the video should be displayed in the video area
273 vout_PlacePicture( p_vout, p_sys->main_window.i_width,
274 p_sys->main_window.i_height,
275 &p_sys->output_window.i_x,
276 &p_sys->output_window.i_y,
277 &p_sys->output_window.i_width,
278 &p_sys->output_window.i_height );
279 p_sys->output_window.i_x = ( p_sys->output_window.i_x +
280 p_sys->main_window.i_x ) & ~1;
281 p_sys->output_window.i_y = ( p_sys->output_window.i_y +
282 p_sys->main_window.i_y ) & ~1;
284 // Hardware upscaling better than software
285 if( p_vout->fmt_render.i_width <= p_sys->main_window.i_width &&
286 p_vout->fmt_render.i_height <= p_sys->main_window.i_height )
288 p_sys->i_video_width =
289 p_vout->output.i_width =
290 p_vout->fmt_out.i_width =
291 p_vout->fmt_out.i_visible_width = p_vout->fmt_render.i_width;
292 p_sys->i_video_height =
293 p_vout->output.i_height =
294 p_vout->fmt_out.i_height =
295 p_vout->fmt_out.i_visible_height = p_vout->fmt_render.i_height;
299 p_sys->i_video_width =
300 p_vout->output.i_width =
301 p_vout->fmt_out.i_width =
302 p_vout->fmt_out.i_visible_width = p_sys->output_window.i_width;
303 p_sys->i_video_height =
304 p_vout->output.i_height =
305 p_vout->fmt_out.i_height =
306 p_vout->fmt_out.i_visible_height = p_sys->output_window.i_height;
309 p_vout->output.i_chroma =
310 p_vout->fmt_out.i_chroma = VLC_CODEC_I420;
311 p_sys->i_color_format = OMAPFB_COLOR_YUV420;
313 // place in the framebuffer where we have to write
314 p_sys->p_center = p_sys->p_video + p_sys->output_window.i_x*p_sys->i_bytes_per_pixel
315 + p_sys->output_window.i_y*p_sys->i_line_len;
317 // We get and set a direct render vlc picture
318 I_OUTPUTPICTURES = 0;
319 picture_t *p_pic = NULL;
322 for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
324 if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
326 p_pic = p_vout->p_picture + i_index;
331 /* Allocate the picture */
337 p_sys->p_output_picture = p_pic;
338 p_pic->p->p_pixels = p_vout->p_sys->p_center;
339 p_pic->p->i_pixel_pitch = p_vout->p_sys->i_bytes_per_pixel;
340 p_pic->p->i_lines = p_sys->i_video_height;
341 p_pic->p->i_visible_lines = p_sys->i_video_height;
342 p_pic->p->i_pitch = p_sys->i_line_len;
343 p_pic->p->i_visible_pitch = p_sys->i_line_len;
345 p_pic->i_status = DESTROYED_PICTURE;
346 p_pic->i_type = DIRECT_PICTURE;
348 PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
355 /*****************************************************************************
356 * End: terminate omap framebuffer video thread output method
357 *****************************************************************************/
358 static void End( vout_thread_t *p_vout )
360 /* Clear the screen */
361 UpdateScreen( p_vout, 0, 0,
362 p_vout->p_sys->fb_vinfo.xres,
363 p_vout->p_sys->fb_vinfo.yres,
364 p_vout->p_sys->fb_vinfo.xres,
365 p_vout->p_sys->fb_vinfo.yres,
366 OMAPFB_COLOR_RGB565 );
369 /*****************************************************************************
370 * Control: control facility for the vout
371 *****************************************************************************/
372 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
377 /*****************************************************************************
378 * FreePicture: Destroy the picture and make it free again
379 ******************************************************************************/
380 static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic )
382 p_pic->p->p_pixels = NULL;
383 p_pic->i_status = FREE_PICTURE;
386 /*****************************************************************************
387 * Manage: handle omapfb events
388 *****************************************************************************
389 * This function should be called regularly by video output thread.
390 *****************************************************************************/
391 static int Manage( vout_thread_t *p_vout )
395 while( XPending( p_vout->p_sys->p_display ) )
397 XNextEvent( p_vout->p_sys->p_display, &xevent );
399 if( xevent.type == ButtonPress &&
400 ((XButtonEvent *)&xevent)->button == Button1 )
402 /* detect double-clicks */
403 if( ( ((XButtonEvent *)&xevent)->time -
404 p_vout->p_sys->i_time_button_last_pressed ) < 300 )
406 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
409 p_vout->p_sys->i_time_button_last_pressed =
410 ((XButtonEvent *)&xevent)->time;
412 else if( xevent.type == KeyPress )
417 x_key_symbol = XKeycodeToKeysym( p_vout->p_sys->p_display,
418 xevent.xkey.keycode, 0 );
420 switch( x_key_symbol )
423 val.i_int = ACTIONID_PLAY_PAUSE; break;
425 val.i_int = ACTIONID_QUIT; break;
427 val.i_int = ACTIONID_JUMP_BACKWARD_MEDIUM; break;
429 val.i_int = ACTIONID_JUMP_FORWARD_MEDIUM; break;
431 val.i_int = ACTIONID_JUMP_FORWARD_SHORT; break;
433 val.i_int = ACTIONID_JUMP_BACKWARD_SHORT; break;
435 val.i_int = ACTIONID_TOGGLE_FULLSCREEN; break;
437 val.i_int = ACTIONID_VOL_UP; break;
439 val.i_int = ACTIONID_VOL_DOWN; break;
441 var_SetInteger( p_vout->p_libvlc, "key-action", val.i_int );
443 else if( ( xevent.type == VisibilityNotify &&
444 xevent.xvisibility.state == VisibilityUnobscured ) ||
445 xevent.type == FocusIn )
447 p_vout->p_sys->b_video_enabled = true;
448 p_vout->p_sys->p_output_picture->p->p_pixels =
449 p_vout->p_sys->p_center;
450 XSetInputFocus( p_vout->p_sys->p_display, p_vout->p_sys->window,
451 RevertToParent, CurrentTime );
453 else if( ( xevent.type == VisibilityNotify &&
454 xevent.xvisibility.state != VisibilityUnobscured ) ||
455 xevent.type == FocusOut || xevent.type == UnmapNotify )
457 UpdateScreen( p_vout, 0, 0,
458 p_vout->p_sys->fb_vinfo.xres,
459 p_vout->p_sys->fb_vinfo.yres,
460 p_vout->p_sys->fb_vinfo.xres,
461 p_vout->p_sys->fb_vinfo.yres,
462 OMAPFB_COLOR_RGB565 );
463 p_vout->p_sys->b_video_enabled = false;
464 p_vout->p_sys->p_output_picture->p->p_pixels =
465 p_vout->p_sys->p_null;
469 if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
471 /* Update the object variable and trigger callback */
472 var_SetBool( p_vout, "fullscreen", !p_vout->b_fullscreen );
474 if( p_vout->p_sys->b_embed )
475 ToggleFullScreen( p_vout );
476 p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
479 if( p_vout->i_changes & VOUT_SIZE_CHANGE )
481 FreePicture( p_vout, p_vout->p_sys->p_output_picture );
484 msg_Err( p_vout, "cannot reinit framebuffer screen" );
491 if ( p_vout->p_sys->p_octx != NULL ) {
492 if ( p_vout->p_sys->i_backlight_on_counter == i_backlight_on_interval ) {
493 if ( osso_display_blanking_pause( p_vout->p_sys->p_octx ) != OSSO_OK ) {
494 msg_Err( p_vout, "Could not disable backlight blanking" );
496 msg_Dbg( p_vout, "Backlight blanking disabled" );
498 p_vout->p_sys->i_backlight_on_counter = 0;
500 p_vout->p_sys->i_backlight_on_counter ++;
508 /*****************************************************************************
509 * DisplayVideo: displays previously rendered output
510 *****************************************************************************
511 * This function update the screen resulting in the display of the last
513 *****************************************************************************/
514 static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
518 if( !p_vout->p_sys->b_video_enabled )
521 UpdateScreen( p_vout,
522 p_vout->p_sys->output_window.i_x,
523 p_vout->p_sys->output_window.i_y,
524 p_vout->p_sys->i_video_width,
525 p_vout->p_sys->i_video_height,
526 p_vout->p_sys->output_window.i_width,
527 p_vout->p_sys->output_window.i_height,
528 p_vout->p_sys->i_color_format );
530 // Wait for the window to be fully displayed
531 ioctl( p_vout->p_sys->i_fd, OMAPFB_SYNC_GFX);
534 /*****************************************************************************
535 * OpenDisplay: initialize framebuffer
536 *****************************************************************************/
537 static int OpenDisplay( vout_thread_t *p_vout )
539 vout_sys_t *p_sys = (vout_sys_t *) p_vout->p_sys;
540 char *psz_device; /* framebuffer device path */
542 /* Open framebuffer device */
543 if( !(psz_device = config_GetPsz( p_vout, FB_DEV_VAR )) )
545 msg_Err( p_vout, "don't know which fb device to open" );
549 p_sys->i_fd = open( psz_device, O_RDWR );
550 if( p_sys->i_fd == -1 )
552 msg_Err( p_vout, "cannot open %s (%m)", psz_device );
558 // Get caps, try older interface if needed
559 if( ioctl( p_sys->i_fd, OMAPFB_GET_CAPS, &p_sys->caps ) != 0 )
561 if( ioctl( p_sys->i_fd, OMAP_IOR( 42, unsigned long ), &p_sys->caps ) != 0 )
563 msg_Err( p_vout, "OMAPFB_GET_CAPS ioctl failed" );
564 close( p_sys->i_fd );
569 if( ( p_sys->caps.ctrl & OMAPFB_CAPS_TEARSYNC ) != 0 )
570 p_sys->b_tearsync = true;
572 if( ioctl( p_sys->i_fd, FBIOGET_VSCREENINFO, &p_sys->fb_vinfo ) )
574 msg_Err( p_vout, "Can't get VSCREENINFO: %s", strerror(errno) );
575 close( p_sys->i_fd );
578 if( ioctl( p_sys->i_fd, FBIOGET_FSCREENINFO, &p_sys->fb_finfo ) )
580 msg_Err( p_vout, "Can't get FSCREENINFO: %s", strerror(errno) );
581 close( p_sys->i_fd );
585 p_sys->i_bytes_per_pixel = 2;
586 p_sys->i_page_size = p_sys->fb_finfo.smem_len;
587 p_sys->i_line_len = p_sys->fb_finfo.line_length;
589 if( (p_sys->p_video = (uint8_t *)mmap( 0, p_sys->i_page_size, PROT_READ | PROT_WRITE, MAP_SHARED,
590 p_sys->i_fd, 0 )) == MAP_FAILED )
592 msg_Err( p_vout, "Can't mmap: %s", strerror(errno) );
593 close( p_sys->i_fd );
597 p_sys->p_display = XOpenDisplay( NULL );
599 /* Open /dev/null and map it */
600 p_sys->i_null_fd = open( "/dev/zero", O_RDWR );
601 if( p_sys->i_null_fd == -1 )
603 msg_Err( p_vout, "cannot open /dev/zero (%m)" );
604 munmap( p_sys->p_video, p_sys->i_page_size );
605 close( p_sys->i_fd );
609 if( (p_sys->p_null = (uint8_t *)mmap( 0, p_sys->i_page_size, PROT_READ | PROT_WRITE,
610 MAP_PRIVATE, p_sys->i_null_fd, 0 )) == MAP_FAILED )
612 msg_Err( p_vout, "Can't mmap 2: %s", strerror(errno) );
613 munmap( p_sys->p_video, p_sys->i_page_size );
614 close( p_sys->i_null_fd );
615 close( p_sys->i_fd );
622 /*****************************************************************************
623 * CloseDisplay: terminate FB video thread output method
624 *****************************************************************************/
625 static void CloseDisplay( vout_thread_t *p_vout )
627 munmap( p_vout->p_sys->p_video, p_vout->p_sys->i_page_size );
628 munmap( p_vout->p_sys->p_null, p_vout->p_sys->i_page_size );
630 close( p_vout->p_sys->i_fd );
631 close( p_vout->p_sys->i_null_fd );
634 /*****************************************************************************
635 * UpdateScreen: update the screen of the omapfb
636 *****************************************************************************/
637 static void UpdateScreen( vout_thread_t *p_vout, int i_x, int i_y,
638 int i_width, int i_height,
639 int i_out_width, int i_out_height, int i_format )
641 struct omapfb_update_window update;
644 update.width = i_width;
645 update.height = i_height;
648 update.out_width = i_out_width;
649 update.out_height = i_out_height;
650 update.format = i_format;
651 if( p_vout->p_sys->b_tearsync )
652 update.format |= OMAPFB_FORMAT_FLAG_TEARSYNC;
653 ioctl( p_vout->p_sys->i_fd, OMAPFB_UPDATE_WINDOW, &update );
656 /*****************************************************************************
657 * InitWindow: get embedded window and init X11
658 *****************************************************************************/
659 static int InitWindow( vout_thread_t *p_vout )
661 vout_sys_t *p_sys = (vout_sys_t *)p_vout->p_sys;
665 p_sys->p_display = XOpenDisplay( NULL );
667 // Request window from interface
668 p_sys->owner_window =
669 vout_RequestXWindow( p_vout,
670 &p_sys->embedded_window.i_x,
671 &p_sys->embedded_window.i_y,
672 &p_sys->embedded_window.i_width,
673 &p_sys->embedded_window.i_height );
674 p_sys->main_window = p_sys->embedded_window;
676 // We have to create a new window to get some events
677 // (ButtonPress for example)
678 CreateWindow( p_sys );
682 // No embedding, fullscreen framebuffer overlay with no events handling
683 p_sys->main_window.i_x = p_sys->main_window.i_y = 0;
684 p_sys->main_window.i_width = p_sys->fb_vinfo.xres;
685 p_sys->main_window.i_height = p_sys->fb_vinfo.yres;
686 p_vout->b_fullscreen = true;
687 var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
693 static void CreateWindow( vout_sys_t *p_sys )
695 XSetWindowAttributes xwindow_attributes;
696 xwindow_attributes.backing_store = Always;
697 xwindow_attributes.background_pixel =
698 BlackPixel( p_sys->p_display, DefaultScreen(p_sys->p_display) );
699 xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask;
700 p_sys->window = XCreateWindow( p_sys->p_display,
701 p_sys->owner_window->handle.xid,
703 p_sys->main_window.i_width,
704 p_sys->main_window.i_height,
707 CWBackingStore | CWBackPixel | CWEventMask,
708 &xwindow_attributes );
710 XMapWindow( p_sys->p_display, p_sys->window );
711 XSelectInput( p_sys->p_display, p_sys->window,
712 KeyPressMask | ButtonPressMask | StructureNotifyMask |
713 VisibilityChangeMask | FocusChangeMask );
714 XSelectInput( p_sys->p_display, p_sys->owner_window->handle.xid,
715 StructureNotifyMask );
716 XSetInputFocus( p_sys->p_display, p_sys->window, RevertToParent, CurrentTime );
719 static void ToggleFullScreen ( vout_thread_t * p_vout )
721 p_vout->b_fullscreen = !p_vout->b_fullscreen;
723 if( p_vout->b_fullscreen )
725 msg_Dbg( p_vout, "Entering fullscreen mode" );
726 XReparentWindow( p_vout->p_sys->p_display,
727 p_vout->p_sys->window,
728 DefaultRootWindow( p_vout->p_sys->p_display ),
733 /* init X event structure for _NET_WM_FULLSCREEN client msg */
734 xev.xclient.type = ClientMessage;
735 xev.xclient.serial = 0;
736 xev.xclient.send_event = True;
737 xev.xclient.message_type = XInternAtom( p_vout->p_sys->p_display,
738 "_NET_WM_STATE", False );
739 xev.xclient.window = p_vout->p_sys->window;
740 xev.xclient.format = 32;
741 if( p_vout->b_fullscreen )
742 xev.xclient.data.l[0] = 1;
744 xev.xclient.data.l[0] = 0;
745 xev.xclient.data.l[1] = XInternAtom( p_vout->p_sys->p_display,
746 "_NET_WM_STATE_FULLSCREEN", False );
747 xev.xclient.data.l[2] = 0;
748 xev.xclient.data.l[3] = 0;
749 xev.xclient.data.l[4] = 0;
751 XSendEvent( p_vout->p_sys->p_display,
752 DefaultRootWindow( p_vout->p_sys->p_display ), False,
753 SubstructureRedirectMask | SubstructureNotifyMask, &xev);
755 p_vout->p_sys->main_window.i_x = p_vout->p_sys->main_window.i_y = 0;
756 p_vout->p_sys->main_window.i_width = p_vout->p_sys->fb_vinfo.xres;
757 p_vout->p_sys->main_window.i_height = p_vout->p_sys->fb_vinfo.yres;
761 msg_Dbg( p_vout, "Leaving fullscreen mode" );
763 XDestroyWindow( p_vout->p_sys->p_display, p_vout->p_sys->window );
765 p_vout->p_sys->main_window = p_vout->p_sys->embedded_window;
766 CreateWindow( p_vout->p_sys );
769 XSync( p_vout->p_sys->p_display, False);
771 /* signal that the size needs to be updated */
772 p_vout->i_changes |= VOUT_SIZE_CHANGE;