From: Antoine Cellerier Date: Tue, 9 Sep 2008 17:11:25 +0000 (+0200) Subject: Implement mouse pointer support in win32 screen. X-Git-Tag: 1.0.0-pre1~3398 X-Git-Url: http://git.videolan.org/gitweb.cgi/vlc.git/?p=vlc.git;p=vlc.git;a=commitdiff_plain;h=a8eb61e4d0ebc9bc6a0ed6567968bfb8552f1945 Implement mouse pointer support in win32 screen. Also fix mouse pointer position when capture a subscreen in x11. --- diff --git a/NEWS b/NEWS index 2e6127ad95..5cd8309f0f 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ Changes between 0.9.1 and 1.0.0-git: ------------------------------------ Inputs: - * Mouse cursor support in x11 screen module + * Mouse cursor support in x11 and win32 screen modules * Screen module now supports partial screen capture and mouse following on windows. diff --git a/modules/access/screen/screen.c b/modules/access/screen/screen.c index b401e3399d..c349a78901 100644 --- a/modules/access/screen/screen.c +++ b/modules/access/screen/screen.c @@ -192,7 +192,9 @@ static int Open( vlc_object_t *p_this ) { p_sys->i_screen_width = p_sys->fmt.video.i_width; p_sys->i_screen_height = p_sys->fmt.video.i_height; + p_sys->fmt.video.i_visible_width = p_sys->fmt.video.i_width = p_sys->i_width; + p_sys->fmt.video.i_visible_height = p_sys->fmt.video.i_height = p_sys->i_height; p_sys->b_follow_mouse = var_CreateGetInteger( p_demux, "screen-follow-mouse" ); @@ -324,3 +326,62 @@ void FollowMouse( demux_sys_t *p_sys, int i_x, int i_y ) p_sys->i_screen_height - p_sys->i_height ); } #endif + +#ifdef SCREEN_MOUSE +void RenderCursor( demux_t *p_demux, int i_x, int i_y, + uint8_t *p_dst ) +{ + demux_sys_t *p_sys = p_demux->p_sys; + 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 ) + { + p_sys->dst.p->p_pixels = p_dst; + p_sys->p_blend->pf_video_blend( p_sys->p_blend, + &p_sys->dst, + p_sys->p_mouse, +#ifdef SCREEN_SUBSCREEN + i_x-p_sys->i_left, +#else + i_x, +#endif +#ifdef SCREEN_SUBSCREEN + i_y-p_sys->i_top, +#else + i_y, +#endif + 255 ); + } + else + { + picture_Release( p_sys->p_mouse ); + p_sys->p_mouse = NULL; + } +} +#endif diff --git a/modules/access/screen/screen.h b/modules/access/screen/screen.h index 7c9506c5cd..28f1433dca 100644 --- a/modules/access/screen/screen.h +++ b/modules/access/screen/screen.h @@ -28,9 +28,6 @@ #if !defined( HAVE_BEOS ) && !defined( HAVE_DARWIN ) # define SCREEN_SUBSCREEN -#endif - -#if !defined( HAVE_WIN32 ) && !defined( HAVE_BEOS ) && !defined( HAVE_DARWIN ) # define SCREEN_MOUSE #endif @@ -76,3 +73,6 @@ block_t *screen_Capture( demux_t * ); #ifdef SCREEN_SUBSCREEN void FollowMouse( demux_sys_t *, int, int ); #endif +#ifdef SCREEN_MOUSE +void RenderCursor( demux_t *, int, int, uint8_t * ); +#endif diff --git a/modules/access/screen/win32.c b/modules/access/screen/win32.c index 05ba39223e..6b4ddbfc3b 100644 --- a/modules/access/screen/win32.c +++ b/modules/access/screen/win32.c @@ -1,7 +1,7 @@ /***************************************************************************** * win32.c: Screen capture module. ***************************************************************************** - * Copyright (C) 2004 the VideoLAN team + * Copyright (C) 2004-2008 the VideoLAN team * $Id$ * * Authors: Gildas Bazin @@ -97,9 +97,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 = GetDeviceCaps( p_data->hdc_src, HORZRES ); + p_sys->fmt.video.i_visible_height = p_sys->fmt.video.i_height = GetDeviceCaps( p_data->hdc_src, VERTRES ); p_sys->fmt.video.i_bits_per_pixel = i_bits_per_pixel; + p_sys->fmt.video.i_chroma = i_chroma; switch( i_chroma ) { @@ -275,6 +278,15 @@ block_t *screen_Capture( demux_t *p_demux ) block_t *p_block = p_data->p_block; p_data->i_fragment = 0; p_data->p_block = 0; + + if( p_sys->p_mouse ) + { + POINT pos; + GetCursorPos( &pos ); + RenderCursor( p_demux, pos.x, pos.y, + p_block->p_buffer ); + } + return p_block; } diff --git a/modules/access/screen/x11.c b/modules/access/screen/x11.c index 61b4e75e62..f630cec39e 100644 --- a/modules/access/screen/x11.c +++ b/modules/access/screen/x11.c @@ -160,56 +160,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 );