X-Git-Url: http://git.videolan.org/gitweb.cgi/vlc.git/?p=vlc.git;p=vlc.git;a=blobdiff_plain;f=modules%2Faccess%2Fscreen%2Fx11.c;h=177f382346d74fc154f9f11956d239b7e01228a2;hp=e8ba1df76a0871c8b426c388cef2a9be332d9d81;hb=1590cffcccc6df3c65b5034e08b6bee121030164;hpb=c624c5f79002b425a62bad11baaea349203e1a34 diff --git a/modules/access/screen/x11.c b/modules/access/screen/x11.c index e8ba1df76a..177f382346 100644 --- a/modules/access/screen/x11.c +++ b/modules/access/screen/x11.c @@ -1,10 +1,11 @@ /***************************************************************************** * x11.c: Screen capture module. ***************************************************************************** - * Copyright (C) 2004 VideoLAN + * Copyright (C) 2004-2008 the VideoLAN team * $Id$ * * Authors: Gildas Bazin + * Antoine Cellerier * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,16 +19,18 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include #include #include @@ -38,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" ); @@ -69,9 +74,10 @@ int screen_InitCapture( demux_t *p_demux ) case 16: i_chroma = VLC_FOURCC('R','V','1','6'); break; case 24: - i_chroma = VLC_FOURCC('R','V','2','4'); break; case 32: - i_chroma = VLC_FOURCC('R','V','3','2'); break; + i_chroma = VLC_FOURCC('R','V','3','2'); + win_info.depth = 32; + break; default: msg_Err( p_demux, "unknown screen depth %i", win_info.depth ); XCloseDisplay( p_display ); @@ -79,9 +85,12 @@ int screen_InitCapture( demux_t *p_demux ) } es_format_Init( &p_sys->fmt, VIDEO_ES, i_chroma ); + p_sys->fmt.video.i_visible_width = p_sys->fmt.video.i_width = win_info.width; + p_sys->fmt.video.i_visible_height = p_sys->fmt.video.i_height = win_info.height; p_sys->fmt.video.i_bits_per_pixel = win_info.depth; + p_sys->fmt.video.i_chroma = i_chroma; #if 0 win_info.visual->red_mask; @@ -99,6 +108,12 @@ int screen_CloseCapture( demux_t *p_demux ) Display *p_display = (Display *)p_sys->p_data; XCloseDisplay( p_display ); + if( p_sys->p_blend ) + { + 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 ); + } return VLC_SUCCESS; } @@ -109,9 +124,27 @@ block_t *screen_Capture( demux_t *p_demux ) block_t *p_block; XImage *image; int i_size; + int root_x = 0, root_y = 0; + + if( p_sys->b_follow_mouse || p_sys->p_mouse ) + { + Window root = DefaultRootWindow( p_display ), child; + int win_x, win_y; + unsigned int mask; + if( XQueryPointer( p_display, root, + &root, &child, &root_x, &root_y, &win_x, &win_y, + &mask ) ) + { + if( p_sys->b_follow_mouse ) + FollowMouse( p_sys, root_x, root_y ); + } + else + msg_Dbg( p_demux, "XQueryPointer() failed" ); + + } image = XGetImage( p_display, DefaultRootWindow( p_display ), - 0, 0, p_sys->fmt.video.i_width, + p_sys->i_left, p_sys->i_top, p_sys->fmt.video.i_width, p_sys->fmt.video.i_height, AllPlanes, ZPixmap ); if( !image ) @@ -129,7 +162,11 @@ block_t *screen_Capture( demux_t *p_demux ) return 0; } - 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 );