[vlc-commits] window: check and set window type in all plugins

Rémi Denis-Courmont git at videolan.org
Thu Oct 16 19:25:54 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Oct  9 19:34:14 2014 +0300| [681329fa1225591488f3cf17f583ce45324278bc] | committer: Rémi Denis-Courmont

window: check and set window type in all plugins

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=681329fa1225591488f3cf17f583ce45324278bc
---

 modules/gui/macosx/intf.m                    |    5 +++++
 modules/gui/minimal_macosx/intf.m            |    5 +++++
 modules/gui/qt4/qt4.cpp                      |   13 ++++++++++---
 modules/gui/skins2/src/skin_main.cpp         |   15 +++++++++++++++
 modules/video_output/android/nativewindow.c  |    5 +++++
 modules/video_output/drawable.c              |    6 +++++-
 modules/video_output/wayland/shell_surface.c |    5 +++++
 modules/video_output/xcb/window.c            |   10 ++++++++++
 src/video_output/window.c                    |    2 +-
 9 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 75ba46c..cd93cec 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -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];
diff --git a/modules/gui/minimal_macosx/intf.m b/modules/gui/minimal_macosx/intf.m
index b2fab4f..6c7cc5f 100644
--- a/modules/gui/minimal_macosx/intf.m
+++ b/modules/gui/minimal_macosx/intf.m
@@ -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];
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index fa77a4a..5f6b7a1 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -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;
diff --git a/modules/gui/skins2/src/skin_main.cpp b/modules/gui/skins2/src/skin_main.cpp
index 47c604e..ed67153 100644
--- a/modules/gui/skins2/src/skin_main.cpp
+++ b/modules/gui/skins2/src/skin_main.cpp
@@ -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
diff --git a/modules/video_output/android/nativewindow.c b/modules/video_output/android/nativewindow.c
index d3f308e..7f1f965 100644
--- a/modules/video_output/android/nativewindow.c
+++ b/modules/video_output/android/nativewindow.c
@@ -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;
diff --git a/modules/video_output/drawable.c b/modules/video_output/drawable.c
index fa157e3..3fe3e5d 100644
--- a/modules/video_output/drawable.c
+++ b/modules/video_output/drawable.c
@@ -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;
diff --git a/modules/video_output/wayland/shell_surface.c b/modules/video_output/wayland/shell_surface.c
index 34ad8ea..473897f 100644
--- a/modules/video_output/wayland/shell_surface.c
+++ b/modules/video_output/wayland/shell_surface.c
@@ -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;
diff --git a/modules/video_output/xcb/window.c b/modules/video_output/xcb/window.c
index 6637e07..460054f 100644
--- a/modules/video_output/xcb/window.c
+++ b/modules/video_output/xcb/window.c
@@ -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;
diff --git a/src/video_output/window.c b/src/video_output/window.c
index 7b8a715..3ff0add 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -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);



More information about the vlc-commits mailing list