[vlc-devel] [PATCH v4 05/23] video_output: move the mouse events generation in the UI thread
Steve Lhomme
robux4 at ycbcr.xyz
Fri Aug 21 11:59:23 CEST 2020
The mouse events 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 and not what is originally in the source material.
---
src/video_output/video_output.c | 43 ++++++++++++++++++---------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 538f892947a..e29fc18545c 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -395,9 +395,32 @@ 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 (left_pressed) {
+ /* FIXME? */
+ int x, y;
+
+ var_GetCoords(vout, "mouse-moved", &x, &y);
+ var_SetCoords(vout, "mouse-clicked", x, y);
+ }
+ }
+
+ if (cmd.mouse.b_double_click)
+ var_ToggleBool(vout, "fullscreen");
}
void vout_PutSubpicture( vout_thread_t *vout, subpicture_t *subpic )
@@ -1633,7 +1656,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. */
@@ -1649,25 +1671,6 @@ static void ThreadProcessMouseState(vout_thread_sys_t *p_vout,
}
vlc_mutex_unlock(&sys->filter.lock);
- 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 (vlc_mouse_HasPressed(&sys->mouse, m, MOUSE_BUTTON_LEFT)) {
- /* FIXME? */
- int x, y;
-
- var_GetCoords(vout, "mouse-moved", &x, &y);
- var_SetCoords(vout, "mouse-clicked", x, y);
- }
- }
-
- 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