Use --x11-display whenever calling XOpenDisplay (except Qt4 this far)
[vlc.git] / modules / access / screen / x11.c
index 61b4e75..177f382 100644 (file)
@@ -41,11 +41,13 @@ int screen_InitCapture( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     Display *p_display;
+    char *psz_display = var_CreateGetNonEmptyString( p_demux, "x11-display" );
     XWindowAttributes win_info;
     int i_chroma;
 
     /* Open the display */
-    p_display = XOpenDisplay( NULL );
+    p_display = XOpenDisplay( psz_display );
+    free( psz_display );
     if( !p_display )
     {
         msg_Err( p_demux, "cannot open display" );
@@ -108,7 +110,7 @@ int screen_CloseCapture( demux_t *p_demux )
     XCloseDisplay( p_display );
     if( p_sys->p_blend )
     {
-        module_Unneed( p_sys->p_blend, p_sys->p_blend->p_module );
+        module_unneed( p_sys->p_blend, p_sys->p_blend->p_module );
         vlc_object_detach( p_sys->p_blend );
         vlc_object_release( p_sys->p_blend );
     }
@@ -160,56 +162,11 @@ block_t *screen_Capture( demux_t *p_demux )
         return 0;
     }
 
-    if( !p_sys->p_mouse )
-        vlc_memcpy( p_block->p_buffer, image->data, i_size );
-    else
-    {
-        if( !p_sys->dst.i_planes )
-            vout_InitPicture( p_demux, &p_sys->dst,
-                              p_sys->fmt.video.i_chroma,
-                              p_sys->fmt.video.i_width,
-                              p_sys->fmt.video.i_height,
-                              p_sys->fmt.video.i_aspect );
-        if( !p_sys->p_blend )
-        {
-            p_sys->p_blend = vlc_object_create( p_demux, sizeof(filter_t) );
-            if( !p_sys->p_blend )
-                msg_Err( p_demux, "Could not allocate memory for blending module" );
-            else
-            {
-                es_format_Init( &p_sys->p_blend->fmt_in, VIDEO_ES,
-                                VLC_FOURCC('R','G','B','A') );
-                p_sys->p_blend->fmt_in.video = p_sys->p_mouse->format;
-                p_sys->p_blend->fmt_out = p_sys->fmt;
-                p_sys->p_blend->p_module =
-                    module_Need( p_sys->p_blend, "video blending", 0, 0 );
-                if( !p_sys->p_blend->p_module )
-                {
-                    msg_Err( p_demux, "Could not load video blending module" );
-                    vlc_object_detach( p_sys->p_blend );
-                    vlc_object_release( p_sys->p_blend );
-                    p_sys->p_blend = NULL;
-                }
-            }
-        }
-        if( p_sys->p_blend )
-        {
-            vlc_memcpy( p_block->p_buffer, image->data, i_size );
-            p_sys->dst.p->p_pixels = p_block->p_buffer;
-            p_sys->p_blend->pf_video_blend( p_sys->p_blend,
-                                            &p_sys->dst,
-                                            p_sys->p_mouse,
-                                            root_x,
-                                            root_y,
-                                            255 );
-        }
-        else
-        {
-            picture_Release( p_sys->p_mouse );
-            p_sys->p_mouse = NULL;
-            vlc_memcpy( p_block->p_buffer, image->data, i_size );
-        }
-    }
+    vlc_memcpy( p_block->p_buffer, image->data, i_size );
+
+    if( p_sys->p_mouse )
+        RenderCursor( p_demux, root_x, root_y,
+                      p_block->p_buffer );
 
     XDestroyImage( image );