vlc | branch: master | Rémi Denis-Courmont <r...@remlab.net> | Sat Dec 1 16:12:16 2018 +0200| [928fa188029642b896cf07989491ebe613464a4d] | committer: Rémi Denis-Courmont
window: add constant operations structure > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=928fa188029642b896cf07989491ebe613464a4d --- include/vlc_vout_window.h | 26 +++++++++++++++----------- modules/gui/macosx/VLCVideoOutputProvider.m | 6 +++++- modules/gui/minimal_macosx/intf.m | 6 +++++- modules/gui/qt/qt.cpp | 6 +++++- modules/gui/skins2/src/skin_main.cpp | 6 +++++- modules/video_output/android/window.c | 6 +++++- modules/video_output/drawable.c | 6 +++++- modules/video_output/wayland/xdg-shell.c | 6 +++++- modules/video_output/wdummy.c | 6 +++++- modules/video_output/win32/glwin32.c | 7 ++++++- modules/video_output/xcb/window.c | 8 ++++++-- src/video_output/window.c | 1 - 12 files changed, 67 insertions(+), 23 deletions(-) diff --git a/include/vlc_vout_window.h b/include/vlc_vout_window.h index 55ed516c2a..9981fff10f 100644 --- a/include/vlc_vout_window.h +++ b/include/vlc_vout_window.h @@ -127,6 +127,19 @@ struct vout_window_callbacks { void (*output_event)(vout_window_t *, const char *id, const char *desc); }; +struct vout_window_operations { + /** + * Control callback (mandatory) + * + * This callback handles some control request regarding the window. + * See \ref vout_window_control. + * + * This field should not be used directly when manipulating a window. + * vout_window_Control() should be used instead. + */ + int (*control)(vout_window_t *, int, va_list); +}; + typedef struct vout_window_owner { const struct vout_window_callbacks *cbs; void *sys; @@ -188,16 +201,7 @@ struct vout_window_t { struct wl_display *wl; /**< Wayland display (client pointer) */ } display; - /** - * Control callback (mandatory) - * - * This callback handles some control request regarding the window. - * See \ref vout_window_control. - * - * This field should not be used directly when manipulating a window. - * vout_window_Control() should be used instead. - */ - int (*control)(vout_window_t *, int query, va_list); + const struct vout_window_operations *ops; struct { bool has_double_click; /**< Whether double click events are sent, @@ -233,7 +237,7 @@ void vout_window_SetInhibition(vout_window_t *window, bool enabled); static inline int vout_window_vaControl(vout_window_t *window, int query, va_list ap) { - return window->control(window, query, ap); + return window->ops->control(window, query, ap); } /** diff --git a/modules/gui/macosx/VLCVideoOutputProvider.m b/modules/gui/macosx/VLCVideoOutputProvider.m index 4837c2ac4e..92736c6721 100644 --- a/modules/gui/macosx/VLCVideoOutputProvider.m +++ b/modules/gui/macosx/VLCVideoOutputProvider.m @@ -43,6 +43,10 @@ static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false); static int WindowControl(vout_window_t *, int i_query, va_list); +static const struct vout_window_operations ops = { + WindowControl, +}; + int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg) { @autoreleasepool { @@ -74,7 +78,7 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg) p_wnd->handle.nsobject = (void *)CFBridgingRetain(videoView); p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT; - p_wnd->control = WindowControl; + p_wnd->ops = &ops; } if (cfg->is_fullscreen) vout_window_SetFullScreen(p_wnd, NULL); diff --git a/modules/gui/minimal_macosx/intf.m b/modules/gui/minimal_macosx/intf.m index 6064e847c2..c3ab7fd1ac 100644 --- a/modules/gui/minimal_macosx/intf.m +++ b/modules/gui/minimal_macosx/intf.m @@ -102,6 +102,10 @@ static void Run(intf_thread_t *p_intf) *****************************************************************************/ static int WindowControl(vout_window_t *, int i_query, va_list); +static const struct vout_window_operations ops = { + WindowControl, +}; + int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg) { @autoreleasepool { @@ -122,7 +126,7 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg) p_wnd->handle.nsobject = (void *)CFBridgingRetain([o_window contentView]); p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT; - p_wnd->control = WindowControl; + p_wnd->ops = &ops; } if (cfg->is_fullscreen) diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp index c7c6ee24d0..073a418e3d 100644 --- a/modules/gui/qt/qt.cpp +++ b/modules/gui/qt/qt.cpp @@ -694,6 +694,10 @@ static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg, */ static int WindowControl( vout_window_t *, int i_query, va_list ); +static const struct vout_window_operations window_ops = { + WindowControl, +}; + static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg ) { if( cfg->is_standalone ) @@ -727,7 +731,7 @@ static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg ) return VLC_EGENERIC; p_wnd->info.has_double_click = true; - p_wnd->control = WindowControl; + p_wnd->ops = &window_ops; p_wnd->sys = (vout_window_sys_t*)p_mi; return VLC_SUCCESS; } diff --git a/modules/gui/skins2/src/skin_main.cpp b/modules/gui/skins2/src/skin_main.cpp index 1872a1a1d1..de9554b2d1 100644 --- a/modules/gui/skins2/src/skin_main.cpp +++ b/modules/gui/skins2/src/skin_main.cpp @@ -342,6 +342,10 @@ static void WindowCloseLocal( intf_thread_t* pIntf, vlc_object_t *pObj ) VoutManager::instance( pIntf )->releaseWnd( pWnd ); } +static const struct vout_window_operations window_ops = { + WindowControl, +}; + static int WindowOpen( vout_window_t *pWnd, const vout_window_cfg_t *cfg ) { if( var_InheritBool( pWnd, "video-wallpaper" ) ) @@ -375,7 +379,7 @@ static int WindowOpen( vout_window_t *pWnd, const vout_window_cfg_t *cfg ) pWnd->sys = sys; pWnd->sys->cfg = *cfg; pWnd->sys->pIntf = pIntf; - pWnd->control = WindowControl; + pWnd->ops = &window_ops; pWnd->type = VOUT_WINDOW_TYPE_DUMMY; diff --git a/modules/video_output/android/window.c b/modules/video_output/android/window.c index 3101ccef2f..d0617cd47e 100644 --- a/modules/video_output/android/window.c +++ b/modules/video_output/android/window.c @@ -82,6 +82,10 @@ static void OnNewMouseCoords(vout_window_t *wnd, } } +static const struct vout_window_operations ops = { + .control = Control, +}; + /** * Create an Android native window. */ @@ -99,7 +103,7 @@ static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg) wnd->type = VOUT_WINDOW_TYPE_ANDROID_NATIVE; wnd->handle.anativewindow = p_sys->p_awh; - wnd->control = Control; + wnd->ops = &ops; return VLC_SUCCESS; diff --git a/modules/video_output/drawable.c b/modules/video_output/drawable.c index 71c897328b..db71e885dd 100644 --- a/modules/video_output/drawable.c +++ b/modules/video_output/drawable.c @@ -62,6 +62,10 @@ static int Control (vout_window_t *, int, va_list); static vlc_mutex_t serializer = VLC_STATIC_MUTEX; static uintptr_t *used = NULL; +static const struct vout_window_operations ops = { + .control = Control, +}; + /** * Find the drawable set by libvlc application. */ @@ -101,7 +105,7 @@ skip: wnd->type = VOUT_WINDOW_TYPE_HWND; wnd->handle.hwnd = (void *)val; - wnd->control = Control; + wnd->ops = &ops; wnd->sys = (void *)val; return VLC_SUCCESS; } diff --git a/modules/video_output/wayland/xdg-shell.c b/modules/video_output/wayland/xdg-shell.c index 636fd5db7e..d37f415c74 100644 --- a/modules/video_output/wayland/xdg-shell.c +++ b/modules/video_output/wayland/xdg-shell.c @@ -236,6 +236,10 @@ static int Control(vout_window_t *wnd, int cmd, va_list ap) return VLC_SUCCESS; } +static const struct vout_window_operations ops = { + .control = Control, +}; + #ifdef XDG_SHELL static void xdg_toplevel_configure_cb(void *data, struct xdg_toplevel *toplevel, @@ -573,7 +577,7 @@ static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg) wnd->type = VOUT_WINDOW_TYPE_WAYLAND; wnd->handle.wl = surface; wnd->display.wl = display; - wnd->control = Control; + wnd->ops = &ops; if (vlc_clone(&sys->thread, Thread, wnd, VLC_THREAD_PRIORITY_LOW)) goto error; diff --git a/modules/video_output/wdummy.c b/modules/video_output/wdummy.c index bfaf95b727..f3fc8630d5 100644 --- a/modules/video_output/wdummy.c +++ b/modules/video_output/wdummy.c @@ -55,10 +55,14 @@ static int Control(vout_window_t *wnd, int query, va_list ap) } } +static const struct vout_window_operations ops = { + .control = Control, +}; + static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg) { wnd->type = VOUT_WINDOW_TYPE_DUMMY; - wnd->control = Control; + wnd->ops = &ops; vout_window_ReportSize(wnd, cfg->width, cfg->height); return VLC_SUCCESS; } diff --git a/modules/video_output/win32/glwin32.c b/modules/video_output/win32/glwin32.c index c3a074783d..e1fc112cf2 100644 --- a/modules/video_output/win32/glwin32.c +++ b/modules/video_output/win32/glwin32.c @@ -90,6 +90,11 @@ static int EmbedVideoWindow_Control(vout_window_t *wnd, int query, va_list ap) return VLC_EGENERIC; } +static const struct vout_window_operations embedVideoWindow_Ops = +{ + .control = EmbedVideoWindow_Control, +}; + static vout_window_t *EmbedVideoWindow_Create(vout_display_t *vd) { vout_display_sys_t *sys = vd->sys; @@ -103,7 +108,7 @@ static vout_window_t *EmbedVideoWindow_Create(vout_display_t *vd) wnd->type = VOUT_WINDOW_TYPE_HWND; wnd->handle.hwnd = sys->sys.hvideownd; - wnd->control = EmbedVideoWindow_Control; + wnd->ops = &embedVideoWindow_Ops; return wnd; } diff --git a/modules/video_output/xcb/window.c b/modules/video_output/xcb/window.c index 6152d420ce..1cd830a120 100644 --- a/modules/video_output/xcb/window.c +++ b/modules/video_output/xcb/window.c @@ -561,6 +561,10 @@ static void set_wm_deco(xcb_connection_t *conn, xcb_window_t window, bool on) atom, 32, ARRAY_SIZE(motif_wm_hints), motif_wm_hints); } +static const struct vout_window_operations ops = { + .control = Control, +}; + /** * Create an X11 window. */ @@ -631,7 +635,7 @@ static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg) wnd->type = VOUT_WINDOW_TYPE_XID; wnd->handle.xid = window; wnd->display.x11 = display; - wnd->control = Control; + wnd->ops = &ops; wnd->sys = p_sys; p_sys->conn = conn; @@ -838,7 +842,7 @@ static int EmOpen (vout_window_t *wnd, const vout_window_cfg_t *cfg) wnd->type = VOUT_WINDOW_TYPE_XID; wnd->display.x11 = NULL; wnd->handle.xid = window; - wnd->control = Control; + wnd->ops = &ops; wnd->sys = p_sys; p_sys->conn = conn; diff --git a/src/video_output/window.c b/src/video_output/window.c index ebbfde191e..824709869d 100644 --- a/src/video_output/window.c +++ b/src/video_output/window.c @@ -63,7 +63,6 @@ vout_window_t *vout_window_New(vlc_object_t *obj, const char *module, memset(&window->handle, 0, sizeof(window->handle)); window->info.has_double_click = false; - window->control = NULL; window->sys = NULL; assert(owner != NULL); window->owner = *owner; _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits