[vlc-devel] [PATCH 1/2] Qt: check embedded video window type at run-time

Rémi Denis-Courmont remi at remlab.net
Wed Jul 4 20:28:36 CEST 2012


With Qt5, the window type must be checked at run-time: the windowing
system is always defined as Q_WS_QPA.
Unfortunately, running this patch yields a warning that paintEngine()
should not be used. I do not know how else to get the window type.
---
 modules/gui/qt4/qt4.cpp |   72 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 51 insertions(+), 21 deletions(-)

diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 988dbec..842bd36d 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -29,6 +29,7 @@
 #include <QApplication>
 #include <QDate>
 #include <QMutex>
+#include <QPaintEngine>
 
 #include "qt4.hpp"
 
@@ -295,15 +296,20 @@ vlc_module_begin ()
 
         set_callbacks( OpenDialogs, Close )
 
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC)  || defined(Q_WS_PM)
+#if defined (Q_WS_X11) || (defined (Q_WS_QPA) && defined (__unix__))
     add_submodule ()
-#if defined(Q_WS_X11)
         set_capability( "vout window xid", 0 )
-#elif defined(Q_WS_WIN) || defined(Q_WS_PM)
+        set_callbacks( WindowOpen, WindowClose )
+#endif
+#if defined (Q_WS_WIN) || (defined (Q_WS_QPA) && defined (WIN32)) \
+ || defined (Q_WS_PM)  || (defined (Q_WS_QPA) && defined (__OS2__))
+    add_submodule ()
         set_capability( "vout window hwnd", 0 )
-#elif defined(Q_WS_MAC)
-        set_capability( "vout window nsobject", 0 )
+        set_callbacks( WindowOpen, WindowClose )
 #endif
+#if defined (Q_WS_MAC) || (defined (Q_WS_QPA) && defined (__APPLE__))
+    add_submodule ()
+        set_capability( "vout window nsobject", 0 )
         set_callbacks( WindowOpen, WindowClose )
 #endif
 
@@ -595,13 +601,8 @@ static int WindowControl( vout_window_t *, int i_query, va_list );
 
 static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
 {
-    /* */
     if( cfg->is_standalone )
         return VLC_EGENERIC;
-#if defined (Q_WS_X11)
-    if( var_InheritBool( p_wnd, "video-wallpaper" ) )
-        return VLC_EGENERIC;
-#endif
 
     intf_thread_t *p_intf =
         (intf_thread_t *)var_InheritAddress( p_wnd, "qt4-iface" );
@@ -616,7 +617,31 @@ static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
         return VLC_EGENERIC;
 
     MainInterface *p_mi = p_intf->p_sys->p_mi;
-    msg_Dbg( p_wnd, "requesting video..." );
+    msg_Dbg( p_wnd, "requesting video window..." );
+
+    enum QPaintEngine::Type type;
+    switch( cfg->type )
+    {
+        case VOUT_WINDOW_TYPE_XID:
+            if( var_InheritBool( p_wnd, "video-wallpaper" ) )
+                return VLC_EGENERIC;
+            type = QPaintEngine::X11;
+            break;
+        case VOUT_WINDOW_TYPE_HWND:
+            type = QPaintEngine::Windows;
+            break;
+        case VOUT_WINDOW_TYPE_NSOBJECT:
+            type = QPaintEngine::CoreGraphics;
+            break;
+        default:
+            msg_Dbg( p_wnd, "unimplemented window type" );
+            return VLC_EGENERIC;
+    }
+    if( p_mi->paintEngine()->type() != type )
+    {
+        msg_Dbg( p_wnd, "incompatible window type" );
+        return VLC_EGENERIC;
+    }
 
     int i_x = cfg->x;
     int i_y = cfg->y;
@@ -626,16 +651,21 @@ static int WindowOpen( vout_window_t *p_wnd, const vout_window_cfg_t *cfg )
     WId wid = p_mi->getVideo( &i_x, &i_y, &i_width, &i_height );
     if( !wid )
         return VLC_EGENERIC;
-#if defined (Q_WS_X11)
-    p_wnd->handle.xid = wid;
-    p_wnd->display.x11 = NULL;
-#elif defined (Q_WS_WIN) || defined (Q_WS_PM)
-    p_wnd->handle.hwnd = (void *)wid;
-#elif defined (Q_WS_MAC)
-    p_wnd->handle.nsobject = (void *)wid;
-#else
-# error FIXME
-#endif
+
+    switch( cfg->type )
+    {
+        case VOUT_WINDOW_TYPE_XID:
+            p_wnd->handle.xid = wid;
+            p_wnd->display.x11 = NULL;
+            break;
+        case VOUT_WINDOW_TYPE_HWND:
+            p_wnd->handle.hwnd = (void *)wid;
+            break;
+        case VOUT_WINDOW_TYPE_NSOBJECT:
+            p_wnd->handle.nsobject = (void *)wid;
+            break;
+    }
+
     p_wnd->control = WindowControl;
     p_wnd->sys = (vout_window_sys_t*)p_mi;
     return VLC_SUCCESS;
-- 
1.7.10.4




More information about the vlc-devel mailing list