[vlc-devel] [PATCH v5 05/24] video_output: separate the mouse move coordinates in video or UI coordinates

Steve Lhomme robux4 at ycbcr.xyz
Mon Aug 24 09:41:46 CEST 2020


Some may want to read UI coordinates (position in the visible video area) and
some may want to read video coordinates (position in the original unfiltered/
unresized video).

For now they are equal but this is going to change in upcoming patches.
---
 src/video_output/video_output.c | 8 ++++++++
 src/video_output/vout_intf.c    | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 7adbce19e7d..f8d9fd7a45d 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -154,6 +154,7 @@ typedef struct vout_thread_sys_t
 
     /* */
     vlc_mouse_t     mouse;
+    vlc_mouse_t     filtered_mouse;
     vlc_mouse_event mouse_event;
     void            *mouse_opaque;
 
@@ -1649,6 +1650,12 @@ static void ThreadProcessMouseState(vout_thread_sys_t *p_vout,
     }
     vlc_mutex_unlock(&sys->filter.lock);
 
+    if (vlc_mouse_HasMoved(&sys->filtered_mouse, m))
+    {
+        sys->filtered_mouse = *m;
+        var_SetCoords(vout, "video-mouse-moved", m->i_x, m->i_y);
+    }
+
     if (vlc_mouse_HasMoved(&sys->mouse, m))
         var_SetCoords(vout, "mouse-moved", m->i_x, m->i_y);
 
@@ -1671,6 +1678,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
     sys->mouse_event = cfg->mouse_event;
     sys->mouse_opaque = cfg->mouse_opaque;
     vlc_mouse_Init(&sys->mouse);
+    vlc_mouse_Init(&sys->filtered_mouse);
 
     sys->decoder_fifo = picture_fifo_New();
 
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 4fb207ff469..76d59f68861 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -276,6 +276,8 @@ void vout_CreateVars( vout_thread_t *p_vout )
     /* Mouse coordinates */
     var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER );
     var_Create( p_vout, "mouse-moved", VLC_VAR_COORDS );
+    // mouse move coordinates translated to original video size
+    var_Create( p_vout, "video-mouse-moved", VLC_VAR_COORDS );
 
     /* Device orientation */
     var_Create( p_vout, "viewpoint-moved", VLC_VAR_ADDRESS );
-- 
2.26.2



More information about the vlc-devel mailing list