[vlc-devel] [PATCH v5 07/24] video_output: move the mouse variables generation in the UI thread

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


These mouse variables are handled by the UI and should not be modified by the
display filters.
The hotkey/gestures are based on what is visible on the screen (resized,
filtered, etc) and not what is originally in the source material.
skins2 also checks for mouse movements, but doesn't use the values.

Only the libvlc API and the event callback set via ES_OUT_VOUT_SET_MOUSE_EVENT
want to know the mouse coordinates according to the original source material.
---
 src/video_output/video_output.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index f8d9fd7a45d..579ff937264 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -396,9 +396,23 @@ void vout_MouseState(vout_thread_t *vout, const vlc_mouse_t *mouse)
         vout_display_TranslateMouseState(sys->display, &cmd.mouse, mouse);
     else
         cmd.mouse = *mouse;
+
+    bool moved = vlc_mouse_HasMoved(&sys->mouse, &cmd.mouse);
+    bool button = vlc_mouse_HasButton(&sys->mouse, &cmd.mouse);
+    bool left_pressed = button && vlc_mouse_HasPressed(&sys->mouse, &cmd.mouse, MOUSE_BUTTON_LEFT);
+    sys->mouse = cmd.mouse;
     vlc_mutex_unlock(&sys->display_lock);
 
     vout_control_Push(&sys->control, &cmd);
+
+    if (moved)
+        var_SetCoords(vout, "mouse-moved", cmd.mouse.i_x, cmd.mouse.i_y);
+
+    if (button)
+        var_SetInteger(vout, "mouse-button-down", cmd.mouse.i_pressed);
+
+    if (cmd.mouse.b_double_click)
+        var_ToggleBool(vout, "fullscreen");
 }
 
 void vout_PutSubpicture( vout_thread_t *vout, subpicture_t *subpic )
@@ -1634,7 +1648,6 @@ static void ThreadProcessMouseState(vout_thread_sys_t *p_vout,
 {
     vlc_mouse_t tmp1, tmp2;
     const vlc_mouse_t *m;
-    vout_thread_t *vout = &p_vout->obj;
     vout_thread_sys_t *sys = p_vout;
 
     /* pass mouse coordinates in the filter chains. */
@@ -1656,16 +1669,6 @@ static void ThreadProcessMouseState(vout_thread_sys_t *p_vout,
         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);
-
-    if (vlc_mouse_HasButton(&sys->mouse, m))
-        var_SetInteger(vout, "mouse-button-down", m->i_pressed);
-
-    if (m->b_double_click)
-        var_ToggleBool(vout, "fullscreen");
-    sys->mouse = *m;
-
     if (sys->mouse_event)
         sys->mouse_event(m, sys->mouse_opaque);
 }
-- 
2.26.2



More information about the vlc-devel mailing list