[vlc-devel] [PATCH 1/2] core: window: add a new event callback

Thomas Guillem thomas at gllm.fr
Fri Nov 25 18:41:09 CET 2016



On Fri, Nov 25, 2016, at 18:33, Rémi Denis-Courmont wrote:
> On November 25, 2016 6:39:34 PM GMT+02:00, Thomas Guillem
> <thomas at gllm.fr> wrote:
> >vout_window_ReportSize and vout_window_ReportClose use this new
> >callback.
> >---
> > include/vlc_vout_window.h | 26 ++++++++++++++++++++------
> > src/video_output/opengl.c | 17 ++++++++++++++++-
> > src/video_output/window.c | 24 +++++++++++++++++++++---
> > 3 files changed, 57 insertions(+), 10 deletions(-)
> >
> >diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h
> >index 63351ba..c302e28 100644
> >--- a/include/vlc_vout_window.h
> >+++ b/include/vlc_vout_window.h
> >@@ -64,6 +64,11 @@ enum {
> >     VOUT_WINDOW_SET_FULLSCREEN, /* int b_fullscreen */
> > };
> > 
> >+enum {
> >+    VOUT_WINDOW_EVENT_RESIZED,  /* unsigned width, unsigned height */
> >+    VOUT_WINDOW_EVENT_CLOSED,   /* void */
> >+};
> >+
> > typedef struct vout_window_cfg_t {
> >     /* Window handle type */
> >     unsigned type;
> >@@ -86,8 +91,7 @@ typedef struct vout_window_cfg_t {
> > 
> > typedef struct vout_window_owner {
> >     void *sys;
> >-    void (*resized)(vout_window_t *, unsigned width, unsigned height);
> >-    void (*closed)(vout_window_t *);
> >+    void (*event)(vout_window_t *, int type, va_list args);
> > } vout_window_owner_t;
> > 
> > /**
> >@@ -198,17 +202,27 @@ static inline int
> >vout_window_SetFullScreen(vout_window_t *window, bool full)
> >  return vout_window_Control(window, VOUT_WINDOW_SET_FULLSCREEN, full);
> > }
> > 
> >+static inline void vout_window_SendEvent(vout_window_t *window, int
> >type, ...)
> >+{
> >+    if (window->owner.event != NULL)
> >+    {
> >+        va_list args;
> >+
> >+        va_start(args, type);
> >+        window->owner.event(window, type, args);
> >+        va_end(args);
> >+    }
> >+}
> >+
> > static inline void vout_window_ReportSize(vout_window_t *window,
> >                                       unsigned width, unsigned height)
> > {
> >-    if (window->owner.resized != NULL)
> >-        window->owner.resized(window, width, height);
> >+    vout_window_SendEvent(window, VOUT_WINDOW_EVENT_RESIZED, width,
> >height);
> > }
> > 
> > static inline void vout_window_ReportClose(vout_window_t *window)
> > {
> >-    if (window->owner.closed != NULL)
> >-        window->owner.closed(window);
> >+    vout_window_SendEvent(window, VOUT_WINDOW_EVENT_CLOSED);
> > }
> > 
> > /** @} */
> >diff --git a/src/video_output/opengl.c b/src/video_output/opengl.c
> >index ac16c3f..1a42253 100644
> >--- a/src/video_output/opengl.c
> >+++ b/src/video_output/opengl.c
> >@@ -106,6 +106,21 @@ static void
> >vlc_gl_surface_ResizeNotify(vout_window_t *surface,
> >     vlc_mutex_unlock(&sys->lock);
> > }
> > 
> >+static void vlc_gl_surface_Event(vout_window_t *wnd, int type, va_list
> >args)
> >+{
> >+    switch (type)
> >+    {
> >+        case VOUT_WINDOW_EVENT_RESIZED:
> >+            vlc_gl_surface_ResizeNotify(wnd, va_arg(args, unsigned),
> >+                                        va_arg(args, unsigned));
> >+            break;
> >+        case VOUT_WINDOW_EVENT_CLOSED:
> >+            /* TODO */
> >+            break;
> >+        default: vlc_assert_unreachable();
> >+    }
> >+}
> >+
> > vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *obj,
> >                                 const vout_window_cfg_t *cfg,
> >                                 struct vout_window_t **restrict wp)
> >@@ -120,7 +135,7 @@ vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *obj,
> > 
> >     vout_window_owner_t owner = {
> >         .sys = sys,
> >-        .resized = vlc_gl_surface_ResizeNotify,
> >+        .event = vlc_gl_surface_Event,
> >     };
> > 
> > vout_window_t *surface = vout_window_New(obj, "$window", cfg, &owner);
> >diff --git a/src/video_output/window.c b/src/video_output/window.c
> >index 2487668..11ed099 100644
> >--- a/src/video_output/window.c
> >+++ b/src/video_output/window.c
> >@@ -65,7 +65,7 @@ vout_window_t *vout_window_New(vlc_object_t *obj,
> >const char *module,
> >     if (owner != NULL)
> >         window->owner = *owner;
> >     else
> >-        window->owner.resized = NULL;
> >+        window->owner.event = NULL;
> > 
> >     w->module = vlc_module_load(window, "vout window", module,
> >                                 module && *module,
> >@@ -149,6 +149,25 @@ static void
> >vout_display_window_CloseNotify(vout_window_t *window)
> >     vout_SendEventClose(vout);
> > }
> > 
> >+static void vout_display_window_Event(vout_window_t *window, int type,
> >+                                      va_list args)
> >+{
> >+    switch (type)
> >+    {
> >+        case VOUT_WINDOW_EVENT_RESIZED:
> >+        {
> >+            unsigned width = va_arg(args, unsigned);
> >+            unsigned height = va_arg(args, unsigned);
> >+            vout_display_window_ResizeNotify(window, width, height);
> >+            break;
> >+        }
> >+        case VOUT_WINDOW_EVENT_CLOSED:
> >+            vout_display_window_CloseNotify(window);
> >+            break;
> >+        default: vlc_assert_unreachable();
> >+    }
> >+}
> >+
> > /**
> >  * Creates a video window, initially without any attached display.
> >  */
> >@@ -166,8 +185,7 @@ vout_window_t
> >*vout_display_window_New(vout_thread_t *vout,
> > 
> >     vout_window_owner_t owner = {
> >         .sys = state,
> >-        .resized = vout_display_window_ResizeNotify,
> >-        .closed = vout_display_window_CloseNotify,
> >+        .event = vout_display_window_Event,
> >     };
> >     vout_window_t *window;
> > 
> >-- 
> >2.9.3
> >
> >_______________________________________________
> >vlc-devel mailing list
> >To unsubscribe or modify your subscription options:
> >https://mailman.videolan.org/listinfo/vlc-devel
> 
> That looks backward to me.  What is the benefit of muxing those events??

No benefits. To me, it looks better that way with the next patch. This
commit can be dropped.

> -- 
> Rémi Denis-Courmont
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list