Commit 681329fa authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

window: check and set window type in all plugins

parent 53b1f060
......@@ -118,6 +118,10 @@ static int WindowControl(vout_window_t *, int i_query, va_list);
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
{
if (cfg->type != VOUT_WINDOW_TYPE_INVALID
&& cfg->type != VOUT_WINDOW_TYPE_NSOBJECT)
return VLC_EGENERIC;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
intf_thread_t *p_intf = VLCIntf;
if (!p_intf) {
......@@ -156,6 +160,7 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
[o_vout_provider_lock unlock];
p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
p_wnd->control = WindowControl;
[o_pool release];
......
......@@ -148,6 +148,10 @@ static int WindowControl(vout_window_t *, int i_query, va_list);
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
{
if (cfg->type != VOUT_WINDOW_TYPE_INVALID
&& cfg->type != VOUT_WINDOW_TYPE_NSOBJECT)
return VLC_EGENERIC;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
......@@ -168,6 +172,7 @@ int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
if (var_GetBool(pl_Get(p_wnd), "fullscreen"))
[o_window performSelectorOnMainThread:@selector(enterFullscreen) withObject:nil waitUntilDone:NO];
p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
p_wnd->control = WindowControl;
[o_pool release];
......
......@@ -659,9 +659,12 @@ static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
msg_Dbg( p_wnd, "Qt interface not found" );
return VLC_EGENERIC;
}
if( p_intf->p_sys->voutWindowType != cfg->type )
if( cfg->type != VOUT_WINDOW_TYPE_INVALID
&& cfg->type != p_intf->p_sys->voutWindowType )
return VLC_EGENERIC;
switch( cfg->type )
switch( p_intf->p_sys->voutWindowType )
{
case VOUT_WINDOW_TYPE_XID:
if( var_InheritBool( p_wnd, "video-wallpaper" ) )
......@@ -685,7 +688,9 @@ static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
if( !wid )
return VLC_EGENERIC;
switch( cfg->type )
p_wnd->type = p_intf->p_sys->voutWindowType;
switch( p_wnd->type )
{
case VOUT_WINDOW_TYPE_XID:
p_wnd->handle.xid = (uintptr_t)wid;
......@@ -697,6 +702,8 @@ static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
case VOUT_WINDOW_TYPE_NSOBJECT:
p_wnd->handle.nsobject = (void *)wid;
break;
default:
assert(0);
}
p_wnd->control = WindowControl;
......
......@@ -344,6 +344,16 @@ static void WindowCloseLocal( intf_thread_t* pIntf, vlc_object_t *pObj )
static int WindowOpen( vout_window_t *pWnd, const vout_window_cfg_t *cfg )
{
if( cfg->type != VOUT_WINDOW_TYPE_INVALID )
{
#ifdef X11_SKINS
if( cfg->type != VOUT_WINDOW_TYPE_XID )
#else
if( cfg->type != VOUT_WINDOW_TYPE_HWND )
#endif
return VLC_EGENERIC;
}
vout_window_sys_t* sys;
vlc_mutex_lock( &skin_load.mutex );
......@@ -372,6 +382,11 @@ static int WindowOpen( vout_window_t *pWnd, const vout_window_cfg_t *cfg )
pWnd->sys = sys;
pWnd->sys->cfg = *cfg;
pWnd->sys->pIntf = pIntf;
#ifdef X11_SKINS
pWnd->type = VOUT_WINDOW_TYPE_XID;
#else
pWnd->type = VOUT_WINDOW_TYPE_HWND;
#endif
pWnd->control = WindowControl;
// force execution in the skins2 thread context
......
......@@ -74,6 +74,10 @@ struct vout_window_sys_t
*/
static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
if (cfg->type != VOUT_WINDOW_TYPE_INVALID
&& cfg->type != VOUT_WINDOW_TYPE_ANDROID_NATIVE)
return VLC_EGENERIC;
vout_window_sys_t *p_sys = malloc(sizeof (*p_sys));
if (p_sys == NULL)
return VLC_ENOMEM;
......@@ -100,6 +104,7 @@ static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
if (p_sys->window == NULL)
goto error;
wnd->type = VOUT_WINDOW_TYPE_ANDROID_NATIVE;
wnd->handle.anativewindow = p_sys->window;
wnd->control = Control;
wnd->sys = p_sys;
......
......@@ -67,7 +67,10 @@ static uintptr_t *used = NULL;
*/
static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
VLC_UNUSED (cfg);
if (cfg->type != VOUT_WINDOW_TYPE_INVALID
&& cfg->type != VOUT_WINDOW_TYPE_HWND)
return VLC_EGENERIC;
uintptr_t val = var_InheritInteger (wnd, "drawable-hwnd");
if (val == 0)
return VLC_EGENERIC;
......@@ -100,6 +103,7 @@ skip:
if (val == 0)
return VLC_EGENERIC;
wnd->type = VOUT_WINDOW_TYPE_HWND;
wnd->handle.hwnd = (void *)val;
wnd->control = Control;
wnd->sys = (void *)val;
......
......@@ -193,6 +193,10 @@ static const struct wl_registry_listener registry_cbs =
*/
static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
if (cfg->type != VOUT_WINDOW_TYPE_INVALID
&& cfg->type != VOUT_WINDOW_TYPE_WAYLAND)
return VLC_EGENERIC;
vout_window_sys_t *sys = malloc(sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
......@@ -256,6 +260,7 @@ static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
wl_display_flush(display);
wnd->type = VOUT_WINDOW_TYPE_WAYLAND;
wnd->handle.wl = surface;
wnd->display.wl = display;
wnd->control = Control;
......
......@@ -202,6 +202,10 @@ static void CacheAtoms (vout_window_sys_t *p_sys)
*/
static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
if (cfg->type != VOUT_WINDOW_TYPE_INVALID
&& cfg->type != VOUT_WINDOW_TYPE_XID)
return VLC_EGENERIC;
xcb_generic_error_t *err;
xcb_void_cookie_t ck;
......@@ -259,6 +263,7 @@ static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg)
goto error;
}
wnd->type = VOUT_WINDOW_TYPE_XID;
wnd->handle.xid = window;
wnd->display.x11 = display;
wnd->control = Control;
......@@ -552,6 +557,10 @@ static void ReleaseDrawable (vlc_object_t *obj, xcb_window_t window)
*/
static int EmOpen (vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
if (cfg->type != VOUT_WINDOW_TYPE_INVALID
&& cfg->type != VOUT_WINDOW_TYPE_XID)
return VLC_EGENERIC;
xcb_window_t window = var_InheritInteger (wnd, "drawable-xid");
if (window == 0)
return VLC_EGENERIC;
......@@ -566,6 +575,7 @@ static int EmOpen (vout_window_t *wnd, const vout_window_cfg_t *cfg)
p_sys->embedded = true;
p_sys->keys = NULL;
wnd->type = VOUT_WINDOW_TYPE_XID;
wnd->display.x11 = NULL;
wnd->handle.xid = window;
wnd->control = Control;
......
......@@ -97,7 +97,7 @@ vout_window_t *vout_window_New(vlc_object_t *obj,
/* Hook for screensaver inhibition */
if (var_InheritBool(obj, "disable-screensaver") &&
cfg->type == VOUT_WINDOW_TYPE_XID) {
window->type == VOUT_WINDOW_TYPE_XID) {
w->inhibit = vlc_inhibit_Create(VLC_OBJECT (window));
if (w->inhibit != NULL)
vlc_inhibit_Set(w->inhibit, VLC_INHIBIT_VIDEO);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment