Commit a8eb61e4 authored by Antoine Cellerier's avatar Antoine Cellerier

Implement mouse pointer support in win32 screen.

Also fix mouse pointer position when capture a subscreen in x11.
parent 13c381a0
...@@ -2,7 +2,7 @@ Changes between 0.9.1 and 1.0.0-git: ...@@ -2,7 +2,7 @@ Changes between 0.9.1 and 1.0.0-git:
------------------------------------ ------------------------------------
Inputs: 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 * Screen module now supports partial screen capture and mouse following on
windows. windows.
......
...@@ -192,7 +192,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -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_width = p_sys->fmt.video.i_width;
p_sys->i_screen_height = p_sys->fmt.video.i_height; 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_width = p_sys->i_width;
p_sys->fmt.video.i_visible_height =
p_sys->fmt.video.i_height = p_sys->i_height; p_sys->fmt.video.i_height = p_sys->i_height;
p_sys->b_follow_mouse = var_CreateGetInteger( p_demux, p_sys->b_follow_mouse = var_CreateGetInteger( p_demux,
"screen-follow-mouse" ); "screen-follow-mouse" );
...@@ -324,3 +326,62 @@ void FollowMouse( demux_sys_t *p_sys, int i_x, int i_y ) ...@@ -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 ); p_sys->i_screen_height - p_sys->i_height );
} }
#endif #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
...@@ -28,9 +28,6 @@ ...@@ -28,9 +28,6 @@
#if !defined( HAVE_BEOS ) && !defined( HAVE_DARWIN ) #if !defined( HAVE_BEOS ) && !defined( HAVE_DARWIN )
# define SCREEN_SUBSCREEN # define SCREEN_SUBSCREEN
#endif
#if !defined( HAVE_WIN32 ) && !defined( HAVE_BEOS ) && !defined( HAVE_DARWIN )
# define SCREEN_MOUSE # define SCREEN_MOUSE
#endif #endif
...@@ -76,3 +73,6 @@ block_t *screen_Capture( demux_t * ); ...@@ -76,3 +73,6 @@ block_t *screen_Capture( demux_t * );
#ifdef SCREEN_SUBSCREEN #ifdef SCREEN_SUBSCREEN
void FollowMouse( demux_sys_t *, int, int ); void FollowMouse( demux_sys_t *, int, int );
#endif #endif
#ifdef SCREEN_MOUSE
void RenderCursor( demux_t *, int, int, uint8_t * );
#endif
/***************************************************************************** /*****************************************************************************
* win32.c: Screen capture module. * win32.c: Screen capture module.
***************************************************************************** *****************************************************************************
* Copyright (C) 2004 the VideoLAN team * Copyright (C) 2004-2008 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Gildas Bazin <gbazin@videolan.org> * Authors: Gildas Bazin <gbazin@videolan.org>
...@@ -97,9 +97,12 @@ int screen_InitCapture( demux_t *p_demux ) ...@@ -97,9 +97,12 @@ int screen_InitCapture( demux_t *p_demux )
} }
es_format_Init( &p_sys->fmt, VIDEO_ES, i_chroma ); 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_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_height = GetDeviceCaps( p_data->hdc_src, VERTRES );
p_sys->fmt.video.i_bits_per_pixel = i_bits_per_pixel; p_sys->fmt.video.i_bits_per_pixel = i_bits_per_pixel;
p_sys->fmt.video.i_chroma = i_chroma;
switch( i_chroma ) switch( i_chroma )
{ {
...@@ -275,6 +278,15 @@ block_t *screen_Capture( demux_t *p_demux ) ...@@ -275,6 +278,15 @@ block_t *screen_Capture( demux_t *p_demux )
block_t *p_block = p_data->p_block; block_t *p_block = p_data->p_block;
p_data->i_fragment = 0; p_data->i_fragment = 0;
p_data->p_block = 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; return p_block;
} }
......
...@@ -160,56 +160,11 @@ block_t *screen_Capture( demux_t *p_demux ) ...@@ -160,56 +160,11 @@ block_t *screen_Capture( demux_t *p_demux )
return 0; return 0;
} }
if( !p_sys->p_mouse )
vlc_memcpy( p_block->p_buffer, image->data, i_size ); vlc_memcpy( p_block->p_buffer, image->data, i_size );
else
{ if( p_sys->p_mouse )
if( !p_sys->dst.i_planes ) RenderCursor( p_demux, root_x, root_y,
vout_InitPicture( p_demux, &p_sys->dst, p_block->p_buffer );
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 );
}
}
XDestroyImage( image ); XDestroyImage( image );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment