]> git.sesse.net Git - vlc/commitdiff
Implement mouse pointer support in win32 screen.
authorAntoine Cellerier <dionoea@videolan.org>
Tue, 9 Sep 2008 17:11:25 +0000 (19:11 +0200)
committerAntoine Cellerier <dionoea@videolan.org>
Tue, 9 Sep 2008 17:13:05 +0000 (19:13 +0200)
Also fix mouse pointer position when capture a subscreen in x11.

NEWS
modules/access/screen/screen.c
modules/access/screen/screen.h
modules/access/screen/win32.c
modules/access/screen/x11.c

diff --git a/NEWS b/NEWS
index 2e6127ad9590da6ff203c6bfb17e85866e4b8236..5cd8309f0fa7a3aa5ee09ec669b07125baaa5018 100644 (file)
--- 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.
 
index b401e3399d44fa960c6a9d9bd303632674e9d7f0..c349a78901cf98f2bd7b8624f5c9e0e540a5d334 100644 (file)
@@ -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
index 7c9506c5cddd405dc3748e71456e2ad0ce398b99..28f1433dca9a2053e5d75290e129af855e36bbcd 100644 (file)
@@ -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
index 05ba39223e53d5e8f50d03e223c27d880f3a05b2..6b4ddbfc3b3a610878dcf7fe85bf9075ea65eee7 100644 (file)
@@ -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 <gbazin@videolan.org>
@@ -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;
     }
 
index 61b4e75e62cb2025c06d5ebd7e7fa6700b502526..f630cec39efa6b479252327c6487066a6237f973 100644 (file)
@@ -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 );