splitter: filter mouse events, not mouse states
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 13 Jan 2019 13:35:26 +0000 (15:35 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 13 Jan 2019 13:54:57 +0000 (15:54 +0200)
include/vlc_video_splitter.h
modules/video_splitter/clone.c
modules/video_splitter/panoramix.c
modules/video_splitter/wall.c

index 3dad42a..9ca1fbe 100644 (file)
@@ -36,6 +36,8 @@
 
 typedef struct video_splitter_t video_splitter_t;
 
+struct vout_window_mouse_event_t;
+
 /** Structure describing a video splitter output properties
  */
 typedef struct
@@ -92,8 +94,8 @@ struct video_splitter_t
 
     int             (*pf_filter)( video_splitter_t *, picture_t *pp_dst[],
                                   picture_t *p_src );
-    int             (*pf_mouse) ( video_splitter_t *, vlc_mouse_t *,
-                                  int i_index, const vlc_mouse_t *p_new );
+    int (*mouse)(video_splitter_t *, int idx,
+                 struct vout_window_mouse_event_t *);
 
     void *p_sys;
 };
@@ -142,16 +144,12 @@ static inline int video_splitter_Filter( video_splitter_t *p_splitter,
 {
     return p_splitter->pf_filter( p_splitter, pp_dst, p_src );
 }
-static inline int video_splitter_Mouse( video_splitter_t *p_splitter,
-                                        vlc_mouse_t *p_mouse,
-                                        int i_index, const vlc_mouse_t *p_new )
+
+static inline int video_splitter_Mouse(video_splitter_t *splitter, int index,
+                                       struct vout_window_mouse_event_t *ev)
 {
-    if( !p_splitter->pf_mouse )
-    {
-        *p_mouse = *p_new;
-        return VLC_SUCCESS;
-    }
-    return p_splitter->pf_mouse( p_splitter, p_mouse, i_index, p_new );
+    return (splitter->mouse != NULL)
+        ? splitter->mouse(splitter, index, ev) : VLC_SUCCESS;
 }
 
 #endif /* VLC_VIDEO_SPLITTER_H */
index 5f1ab93..201c9f1 100644 (file)
@@ -155,7 +155,7 @@ static int Open( vlc_object_t *p_this )
 
     /* */
     p_splitter->pf_filter = Filter;
-    p_splitter->pf_mouse  = NULL;
+    p_splitter->mouse = NULL;
 
     msg_Dbg( p_splitter, "spawning %i clone(s)", p_splitter->i_output );
 
index 591415f..88fa1ba 100644 (file)
@@ -35,6 +35,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_video_splitter.h>
+#include <vlc_vout_window.h>
 
 #define OVERLAP
 
@@ -298,9 +299,7 @@ typedef struct
 /* */
 static int Filter( video_splitter_t *, picture_t *pp_dst[], picture_t * );
 
-static int Mouse( video_splitter_t *, vlc_mouse_t *,
-                  int i_index, const vlc_mouse_t *p_new );
-
+static int Mouse( video_splitter_t *, int, vout_window_mouse_event_t * );
 
 /* */
 static int Configuration( panoramix_output_t pp_output[ROW_MAX][COL_MAX],
@@ -692,7 +691,7 @@ static int Open( vlc_object_t *p_this )
 
     /* */
     p_splitter->pf_filter = Filter;
-    p_splitter->pf_mouse  = Mouse;
+    p_splitter->mouse = Mouse;
 
     return VLC_SUCCESS;
 }
@@ -784,8 +783,8 @@ static int Filter( video_splitter_t *p_splitter, picture_t *pp_dst[], picture_t
 /**
  * It converts mouse events
  */
-static int Mouse( video_splitter_t *p_splitter, vlc_mouse_t *p_mouse,
-                  int i_index, const vlc_mouse_t *p_new )
+static int Mouse( video_splitter_t *p_splitter, int i_index,
+                  vout_window_mouse_event_t *restrict ev )
 {
     video_splitter_sys_t *p_sys = p_splitter->p_sys;
 
@@ -796,14 +795,14 @@ static int Mouse( video_splitter_t *p_splitter, vlc_mouse_t *p_mouse,
             const panoramix_output_t *p_output = &p_sys->pp_output[x][y];
             if( p_output->b_active && p_output->i_output == i_index )
             {
-                const int i_x = p_new->i_x - p_output->filter.black.i_left;
-                const int i_y = p_new->i_y - p_output->filter.black.i_top;
+                const int i_x = ev->x - p_output->filter.black.i_left;
+                const int i_y = ev->y - p_output->filter.black.i_top;
+
                 if( i_x >= 0 && i_x < p_output->i_width  - p_output->filter.black.i_right &&
                     i_y >= 0 && i_y < p_output->i_height - p_output->filter.black.i_bottom )
                 {
-                    *p_mouse = *p_new;
-                    p_mouse->i_x = p_output->i_src_x + i_x;
-                    p_mouse->i_y = p_output->i_src_y + i_y;
+                    ev->x = p_output->i_src_x + i_x;
+                    ev->y = p_output->i_src_y + i_y;
                     return VLC_SUCCESS;
                 }
             }
index 0328043..8c244d0 100644 (file)
@@ -33,6 +33,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_video_splitter.h>
+#include <vlc_vout_window.h>
 
 #define ROW_MAX (15)
 #define COL_MAX (15)
@@ -108,8 +109,7 @@ typedef struct
 } video_splitter_sys_t;
 
 static int Filter( video_splitter_t *, picture_t *pp_dst[], picture_t * );
-static int Mouse( video_splitter_t *, vlc_mouse_t *,
-                  int i_index, const vlc_mouse_t *p_new );
+static int Mouse( video_splitter_t *, int, vout_window_mouse_event_t * );
 
 /**
  * This function allocates and initializes a Wall splitter module.
@@ -367,7 +367,7 @@ static int Open( vlc_object_t *p_this )
 
     /* */
     p_splitter->pf_filter = Filter;
-    p_splitter->pf_mouse = Mouse;
+    p_splitter->mouse = Mouse;
 
     return VLC_SUCCESS;
 }
@@ -422,8 +422,8 @@ static int Filter( video_splitter_t *p_splitter, picture_t *pp_dst[], picture_t
     picture_Release( p_src );
     return VLC_SUCCESS;
 }
-static int Mouse( video_splitter_t *p_splitter, vlc_mouse_t *p_mouse,
-                  int i_index, const vlc_mouse_t *p_new )
+static int Mouse( video_splitter_t *p_splitter, int i_index,
+                  vout_window_mouse_event_t *restrict ev )
 {
     video_splitter_sys_t *p_sys = p_splitter->p_sys;
 
@@ -432,11 +432,11 @@ static int Mouse( video_splitter_t *p_splitter, vlc_mouse_t *p_mouse,
         for( int x = 0; x < p_sys->i_col; x++ )
         {
             wall_output_t *p_output = &p_sys->pp_output[x][y];
+
             if( p_output->b_active && p_output->i_output == i_index )
             {
-                *p_mouse = *p_new;
-                p_mouse->i_x += p_output->i_left;
-                p_mouse->i_y += p_output->i_top;
+                ev->x += p_output->i_left;
+                ev->y += p_output->i_top;
                 return VLC_SUCCESS;
             }
         }