[vlc-commits] skins2: cosmetics

Erwan Tulou git at videolan.org
Mon Jun 4 22:53:47 CEST 2018


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Mon Jun  4 17:28:42 2018 +0200| [5bf929ae00e1b01b0711573fddb0841ceef6a394] | committer: Erwan Tulou

skins2: cosmetics

- move the vout_window_t management into each OS implementation
(x11, win32 or os2) so that set up is done accordingly.
- keep all window handles within each OS implementation.

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

 modules/gui/skins2/os2/os2_factory.cpp     |  2 +-
 modules/gui/skins2/os2/os2_factory.hpp     |  2 +-
 modules/gui/skins2/os2/os2_window.cpp      |  9 ++++++---
 modules/gui/skins2/os2/os2_window.hpp      |  8 ++++++--
 modules/gui/skins2/src/generic_window.cpp  | 11 ++++++-----
 modules/gui/skins2/src/generic_window.hpp  |  8 +++++---
 modules/gui/skins2/src/os_factory.hpp      |  2 +-
 modules/gui/skins2/src/os_window.hpp       |  4 ++--
 modules/gui/skins2/src/skin_common.hpp     |  6 ------
 modules/gui/skins2/src/skin_main.cpp       | 17 ++++-------------
 modules/gui/skins2/src/vout_window.cpp     |  7 +------
 modules/gui/skins2/src/vout_window.hpp     |  2 +-
 modules/gui/skins2/win32/win32_factory.cpp |  5 +++--
 modules/gui/skins2/win32/win32_factory.hpp |  2 +-
 modules/gui/skins2/win32/win32_window.cpp  |  8 +++++---
 modules/gui/skins2/win32/win32_window.hpp  | 12 ++++++++----
 modules/gui/skins2/x11/x11_factory.cpp     |  5 +++--
 modules/gui/skins2/x11/x11_factory.hpp     |  2 +-
 modules/gui/skins2/x11/x11_window.cpp      | 10 ++++++----
 modules/gui/skins2/x11/x11_window.hpp      | 14 ++++++++------
 20 files changed, 69 insertions(+), 67 deletions(-)

diff --git a/modules/gui/skins2/os2/os2_factory.cpp b/modules/gui/skins2/os2/os2_factory.cpp
index bdd1fb515b..5d0e17101b 100644
--- a/modules/gui/skins2/os2/os2_factory.cpp
+++ b/modules/gui/skins2/os2/os2_factory.cpp
@@ -363,7 +363,7 @@ int OS2Factory::getScreenHeight() const
 }
 
 
-void OS2Factory::getMonitorInfo( const GenericWindow &rWindow,
+void OS2Factory::getMonitorInfo( OSWindow* pWindow,
                                  int* p_x, int* p_y,
                                  int* p_width, int* p_height ) const
 {
diff --git a/modules/gui/skins2/os2/os2_factory.hpp b/modules/gui/skins2/os2/os2_factory.hpp
index 531cf607b8..3f1923bca8 100644
--- a/modules/gui/skins2/os2/os2_factory.hpp
+++ b/modules/gui/skins2/os2/os2_factory.hpp
@@ -99,7 +99,7 @@ public:
     virtual int getScreenHeight() const;
 
     /// Get Monitor Information
-    virtual void getMonitorInfo( const GenericWindow &rWindow,
+    virtual void getMonitorInfo( OSWindow* pWindow,
                                  int* x, int* y,
                                  int* width, int* height ) const;
     virtual void getMonitorInfo( int numScreen,
diff --git a/modules/gui/skins2/os2/os2_window.cpp b/modules/gui/skins2/os2/os2_window.cpp
index 8bc44ef785..7fcfd2cb6b 100644
--- a/modules/gui/skins2/os2/os2_window.cpp
+++ b/modules/gui/skins2/os2/os2_window.cpp
@@ -83,7 +83,9 @@ OS2Window::OS2Window( intf_thread_t *pIntf, GenericWindow &rWindow,
         GenericWindow* pParent =
            (GenericWindow*)pVoutManager->getVoutMainWindow();
 
-        m_hWnd_parent = (HWND)pParent->getOSHandle();
+        OS2Window* pWin = (OS2Window*)pParent->getOSWindow();
+        m_hWnd_parent = pWin->getHandle();
+
 
         // top-level window
         m_hWnd = WinCreateStdWindow( HWND_DESKTOP,
@@ -152,9 +154,10 @@ OS2Window::~OS2Window()
 }
 
 
-void OS2Window::reparent( void* OSHandle, int x, int y, int w, int h )
+void OS2Window::reparent( OSWindow* parent, int x, int y, int w, int h )
 {
-    HWND hwndParent = ( HWND )OSHandle;
+    OS2Window *pParentWin = (OS2Window*)parent;
+    HWND hwndParent = pParentWin->getHandle();
 
     // Reparent the window
     if( !WinSetParent( m_hWnd, hwndParent, TRUE ) )
diff --git a/modules/gui/skins2/os2/os2_window.hpp b/modules/gui/skins2/os2/os2_window.hpp
index e0aed774d2..9c21243507 100644
--- a/modules/gui/skins2/os2/os2_window.hpp
+++ b/modules/gui/skins2/os2/os2_window.hpp
@@ -60,8 +60,12 @@ public:
     /// Getter for the window handle
     HWND getHandle() const { return m_hWndClient; }
 
-    /// Getter for the window handle
-    void* getOSHandle() const { return (void*) m_hWndClient; }
+    /// Set the window handler
+    void setOSHandle( vout_window_t *pWnd ) const {
+        pWnd->type = VOUT_WINDOW_TYPE_HWND;
+        pWnd->info.has_double_click = true;
+        pWnd->handle.hwnd = getHandle();
+    }
 
     /// reparent the window
     void reparent( void* OSHandle, int x, int y, int w, int h );
diff --git a/modules/gui/skins2/src/generic_window.cpp b/modules/gui/skins2/src/generic_window.cpp
index 49d9beef1f..55d1bdcc29 100644
--- a/modules/gui/skins2/src/generic_window.cpp
+++ b/modules/gui/skins2/src/generic_window.cpp
@@ -167,9 +167,10 @@ void GenericWindow::innerHide()
     }
 }
 
-vlc_wnd_type GenericWindow::getOSHandle() const
+
+void GenericWindow::updateWindowConfiguration( vout_window_t * pWnd ) const
 {
-    return m_pOsWindow->getOSHandle();
+    m_pOsWindow->setOSHandle( pWnd );
 }
 
 
@@ -181,8 +182,8 @@ void GenericWindow::setParent( GenericWindow* pParent, int x, int y, int w, int
     m_width  = ( w > 0 ) ? w : m_width;
     m_height = ( h > 0 ) ? h : m_height;
 
-    vlc_wnd_type handle = pParent ? pParent->getOSHandle() : 0;
-    m_pOsWindow->reparent( handle, m_left, m_top, m_width, m_height );
+    OSWindow *pParentOSWindow = pParent->m_pOsWindow;
+    m_pOsWindow->reparent( pParentOSWindow, m_left, m_top, m_width, m_height );
 }
 
 
@@ -204,5 +205,5 @@ void GenericWindow::invalidateRect( int left, int top, int width, int height )
 void GenericWindow::getMonitorInfo( int* x, int* y, int* width, int* height ) const
 {
     OSFactory *pOsFactory = OSFactory::instance( getIntf() );
-    pOsFactory->getMonitorInfo( *this, x, y, width, height );
+    pOsFactory->getMonitorInfo( m_pOsWindow, x, y, width, height );
 }
diff --git a/modules/gui/skins2/src/generic_window.hpp b/modules/gui/skins2/src/generic_window.hpp
index 86343e234e..5753b7162b 100644
--- a/modules/gui/skins2/src/generic_window.hpp
+++ b/modules/gui/skins2/src/generic_window.hpp
@@ -27,6 +27,7 @@
 
 #include "skin_common.hpp"
 #include "../utils/var_bool.hpp"
+#include "vlc_vout_window.h"
 
 class OSWindow;
 class EvtGeneric;
@@ -111,8 +112,8 @@ public:
     /// Window type, mainly useful when overloaded (for VoutWindow)
     virtual std::string getType() const { return "Generic"; }
 
-    /// windows handle
-    vlc_wnd_type getOSHandle() const;
+    /// window handle
+    void updateWindowConfiguration( vout_window_t *pWnd ) const;
 
     /// window type
     WindowType_t getType() { return m_type; }
@@ -121,10 +122,11 @@ public:
     void setParent( GenericWindow* pParent,
                     int x = 0, int y = 0, int w = -1, int h = -1 );
 
-protected:
     /// Get the OS window
     OSWindow *getOSWindow() const { return m_pOsWindow; }
 
+protected:
+
     /// These methods do not need to be public since they are accessed
     /// only by the window manager or by inheritant classes.
     //@{
diff --git a/modules/gui/skins2/src/os_factory.hpp b/modules/gui/skins2/src/os_factory.hpp
index 3aff7ba2c3..54eda30c9a 100644
--- a/modules/gui/skins2/src/os_factory.hpp
+++ b/modules/gui/skins2/src/os_factory.hpp
@@ -122,7 +122,7 @@ public:
     virtual int getScreenHeight() const = 0;
 
     /// Get Monitor Information for a given Window
-    virtual void getMonitorInfo( const GenericWindow &rWindow,
+    virtual void getMonitorInfo( OSWindow *pWindow,
                                  int* x, int* y,
                                  int* width, int* height ) const = 0;
 
diff --git a/modules/gui/skins2/src/os_window.hpp b/modules/gui/skins2/src/os_window.hpp
index ced1e3553e..e9f818f596 100644
--- a/modules/gui/skins2/src/os_window.hpp
+++ b/modules/gui/skins2/src/os_window.hpp
@@ -57,10 +57,10 @@ public:
     virtual void toggleOnTop( bool onTop ) const = 0;
 
     /// getter for handler
-    virtual vlc_wnd_type getOSHandle( ) const = 0;
+    virtual void setOSHandle( vout_window_t* pWnd ) const = 0;
 
     /// reparent the window
-    virtual void reparent( vlc_wnd_type OSHandle,
+    virtual void reparent( OSWindow *window,
                            int x, int y, int w, int h ) = 0;
 
     /// updateWindow (tell the OS we need to update the window)
diff --git a/modules/gui/skins2/src/skin_common.hpp b/modules/gui/skins2/src/skin_common.hpp
index d748e51283..13ac5470fe 100644
--- a/modules/gui/skins2/src/skin_common.hpp
+++ b/modules/gui/skins2/src/skin_common.hpp
@@ -60,12 +60,6 @@ class ThemeRepository;
 #pragma warning ( disable:4786 )
 #endif
 
-#ifdef X11_SKINS
-typedef uint32_t vlc_wnd_type;
-#else
-typedef void* vlc_wnd_type;
-#endif
-
 /// Wrapper around FromLocale, to avoid the need to call LocaleFree()
 static inline std::string sFromLocale( const std::string &rLocale )
 {
diff --git a/modules/gui/skins2/src/skin_main.cpp b/modules/gui/skins2/src/skin_main.cpp
index 36f66e344d..bd07df36fe 100644
--- a/modules/gui/skins2/src/skin_main.cpp
+++ b/modules/gui/skins2/src/skin_main.cpp
@@ -375,27 +375,18 @@ 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->info.has_double_click = true;
     pWnd->control = WindowControl;
 
+    pWnd->type = VOUT_WINDOW_TYPE_DUMMY;
+
     // force execution in the skins2 thread context
     CmdExecuteBlock* cmd = new CmdExecuteBlock( pIntf, VLC_OBJECT( pWnd ),
                                                 WindowOpenLocal );
     CmdExecuteBlock::executeWait( CmdGenericPtr( cmd ) );
 
-#ifdef X11_SKINS
-    pWnd->display.x11 = NULL;
-
-    if( !pWnd->handle.xid )
-#else
-    if( !pWnd->handle.hwnd )
-#endif
+    if( pWnd->type == VOUT_WINDOW_TYPE_DUMMY )
     {
+        msg_Dbg( pIntf, "Vout window creation failed" );
         free( sys );
         vlc_object_release( pIntf );
         return VLC_EGENERIC;
diff --git a/modules/gui/skins2/src/vout_window.cpp b/modules/gui/skins2/src/vout_window.cpp
index 77d0822be0..e912ebb8dc 100644
--- a/modules/gui/skins2/src/vout_window.cpp
+++ b/modules/gui/skins2/src/vout_window.cpp
@@ -51,12 +51,7 @@ VoutWindow::VoutWindow( intf_thread_t *pIntf, vout_window_t* pWnd,
     {
         vlc_object_hold( m_pWnd );
 
-#ifdef X11_SKINS
-        m_pWnd->handle.xid = getOSHandle();
-        m_pWnd->display.x11 = NULL;
-#else
-        m_pWnd->handle.hwnd = getOSHandle();
-#endif
+        updateWindowConfiguration( m_pWnd );
 
         m_pTimer = pOsFactory->createOSTimer( m_cmdHideMouse );
     }
diff --git a/modules/gui/skins2/src/vout_window.hpp b/modules/gui/skins2/src/vout_window.hpp
index 804c50915d..8303180374 100644
--- a/modules/gui/skins2/src/vout_window.hpp
+++ b/modules/gui/skins2/src/vout_window.hpp
@@ -49,7 +49,7 @@ public:
     using GenericWindow::hide;
     using GenericWindow::move;
     using GenericWindow::resize;
-    using GenericWindow::getOSHandle;
+    using GenericWindow::updateWindowConfiguration;
     using GenericWindow::getMonitorInfo;
     //@}
 
diff --git a/modules/gui/skins2/win32/win32_factory.cpp b/modules/gui/skins2/win32/win32_factory.cpp
index 49885ab729..f5a657fc7f 100644
--- a/modules/gui/skins2/win32/win32_factory.cpp
+++ b/modules/gui/skins2/win32/win32_factory.cpp
@@ -384,11 +384,12 @@ int Win32Factory::getScreenHeight() const
 }
 
 
-void Win32Factory::getMonitorInfo( const GenericWindow &rWindow,
+void Win32Factory::getMonitorInfo( OSWindow *pWindow,
                                    int* p_x, int* p_y,
                                    int* p_width, int* p_height ) const
 {
-    HWND wnd = (HWND)rWindow.getOSHandle();
+    Win32Window *pWin = (Win32Window*)pWindow;
+    HWND wnd = pWin->getHandle();
     HMONITOR hmon = MonitorFromWindow( wnd, MONITOR_DEFAULTTONEAREST );
     MONITORINFO mi;
     mi.cbSize = sizeof( MONITORINFO );
diff --git a/modules/gui/skins2/win32/win32_factory.hpp b/modules/gui/skins2/win32/win32_factory.hpp
index c5bf1b08de..cd016ff6a4 100644
--- a/modules/gui/skins2/win32/win32_factory.hpp
+++ b/modules/gui/skins2/win32/win32_factory.hpp
@@ -102,7 +102,7 @@ public:
     virtual int getScreenHeight() const;
 
     /// Get Monitor Information
-    virtual void getMonitorInfo( const GenericWindow &rWindow,
+    virtual void getMonitorInfo( OSWindow *pWindow,
                                  int* x, int* y,
                                  int* width, int* height ) const;
     virtual void getMonitorInfo( int numScreen,
diff --git a/modules/gui/skins2/win32/win32_window.cpp b/modules/gui/skins2/win32/win32_window.cpp
index adb939d864..cc5e1022ed 100644
--- a/modules/gui/skins2/win32/win32_window.cpp
+++ b/modules/gui/skins2/win32/win32_window.cpp
@@ -84,7 +84,8 @@ Win32Window::Win32Window( intf_thread_t *pIntf, GenericWindow &rWindow,
         GenericWindow* pParent =
            (GenericWindow*)pVoutManager->getVoutMainWindow();
 
-        m_hWnd_parent = (HWND)pParent->getOSHandle();
+        Win32Window *pWin = (Win32Window*)pParent->getOSWindow();
+        m_hWnd_parent = pWin->getHandle();
 
         // top-level window
         m_hWnd = CreateWindowEx( WS_EX_APPWINDOW, vlc_class, vlc_name,
@@ -145,10 +146,11 @@ Win32Window::~Win32Window()
 }
 
 
-void Win32Window::reparent( void* OSHandle, int x, int y, int w, int h )
+void Win32Window::reparent( OSWindow* parent, int x, int y, int w, int h )
 {
+    Win32Window *pParentWin = (Win32Window*)parent;
     // Reparent the window
-    if( !SetParent( m_hWnd, (HWND)OSHandle ) )
+    if( !SetParent( m_hWnd, pParentWin->getHandle() ) )
         msg_Err( getIntf(), "SetParent failed (%lu)", GetLastError() );
     MoveWindow( m_hWnd, x, y, w, h, TRUE );
 }
diff --git a/modules/gui/skins2/win32/win32_window.hpp b/modules/gui/skins2/win32/win32_window.hpp
index 55de6043df..47462675b7 100644
--- a/modules/gui/skins2/win32/win32_window.hpp
+++ b/modules/gui/skins2/win32/win32_window.hpp
@@ -59,14 +59,18 @@ public:
     /// Toggle the window on top
     virtual void toggleOnTop( bool onTop ) const;
 
-    /// Getter for the window handle
-    HWND getHandle() const { return m_hWnd; }
+    /// Set the window handler
+    void setOSHandle( vout_window_t *pWnd ) const {
+        pWnd->type = VOUT_WINDOW_TYPE_HWND;
+        pWnd->info.has_double_click = true;
+        pWnd->handle.hwnd = m_hWnd;
+    }
 
     /// Getter for the window handle
-    void* getOSHandle() const { return (void*) m_hWnd; }
+    HWND getHandle() const { return m_hWnd; }
 
     /// reparent the window
-    void reparent( void* OSHandle, int x, int y, int w, int h );
+    void reparent( OSWindow* parent, int x, int y, int w, int h );
 
     /// invalidate a window surface
     bool invalidateRect( int x, int y, int w, int h ) const;
diff --git a/modules/gui/skins2/x11/x11_factory.cpp b/modules/gui/skins2/x11/x11_factory.cpp
index d658ac3b83..8857a72d7b 100644
--- a/modules/gui/skins2/x11/x11_factory.cpp
+++ b/modules/gui/skins2/x11/x11_factory.cpp
@@ -204,10 +204,11 @@ int X11Factory::getScreenHeight() const
 }
 
 
-void X11Factory::getMonitorInfo( const GenericWindow &rWindow,
+void X11Factory::getMonitorInfo( OSWindow *pWindow,
                                  int* p_x, int* p_y,
                                  int* p_width, int* p_height ) const
 {
+    X11Window *pWin = (X11Window*)pWindow;
     // initialize to default geometry
     *p_x = 0;
     *p_y = 0;
@@ -217,7 +218,7 @@ void X11Factory::getMonitorInfo( const GenericWindow &rWindow,
     // Use Xinerama to determine the monitor where the video
     // mostly resides (biggest surface)
     Display *pDisplay = m_pDisplay->getDisplay();
-    Window wnd = (Window)rWindow.getOSHandle();
+    Window wnd = pWin->getDrawable();
     Window root = DefaultRootWindow( pDisplay );
     Window child_wnd;
 
diff --git a/modules/gui/skins2/x11/x11_factory.hpp b/modules/gui/skins2/x11/x11_factory.hpp
index c9094c8064..91c82777f2 100644
--- a/modules/gui/skins2/x11/x11_factory.hpp
+++ b/modules/gui/skins2/x11/x11_factory.hpp
@@ -129,7 +129,7 @@ public:
     virtual int getScreenHeight() const;
 
     /// Get Monitor Information
-    virtual void getMonitorInfo( const GenericWindow &rWindow,
+    virtual void getMonitorInfo( OSWindow *pWindow,
                                  int* x, int* y,
                                  int* width, int* height ) const;
     virtual void getMonitorInfo( int numScreen,
diff --git a/modules/gui/skins2/x11/x11_window.cpp b/modules/gui/skins2/x11/x11_window.cpp
index e469ed64cb..305f327e35 100644
--- a/modules/gui/skins2/x11/x11_window.cpp
+++ b/modules/gui/skins2/x11/x11_window.cpp
@@ -165,8 +165,9 @@ X11Window::X11Window( intf_thread_t *pIntf, GenericWindow &rWindow,
     {
         // Associate the fsc window to the fullscreen window
         VoutManager* pVoutManager = VoutManager::instance( getIntf() );
-        GenericWindow* pWin = pVoutManager->getVoutMainWindow();
-        Window wnd = (Window) pWin->getOSHandle();
+        GenericWindow* pGenericWin = pVoutManager->getVoutMainWindow();
+        X11Window *pWin = (X11Window*)pGenericWin->getOSWindow();
+        Window wnd = pWin->getDrawable();
         XSetTransientForHint( XDISPLAY, m_wnd, wnd );
     }
     else
@@ -242,11 +243,12 @@ X11Window::~X11Window()
     XSync( XDISPLAY, False );
 }
 
-void X11Window::reparent( uint32_t OSHandle, int x, int y, int w, int h )
+void X11Window::reparent( OSWindow *win, int x, int y, int w, int h )
 {
     // Reparent the window
+    X11Window *parent = (X11Window*)win;
     Window new_parent =
-           OSHandle ? (Window) OSHandle : DefaultRootWindow( XDISPLAY );
+           parent ? parent->m_wnd : DefaultRootWindow( XDISPLAY );
 
     XReparentWindow( XDISPLAY, m_wnd, new_parent, x, y);
     if( w && h )
diff --git a/modules/gui/skins2/x11/x11_window.hpp b/modules/gui/skins2/x11/x11_window.hpp
index c8ffa96e49..9ab9244125 100644
--- a/modules/gui/skins2/x11/x11_window.hpp
+++ b/modules/gui/skins2/x11/x11_window.hpp
@@ -67,14 +67,16 @@ public:
     /// Get the window ID
     Window getDrawable() const { return m_wnd; }
 
-    /// Getter for the handler
-    uint32_t getOSHandle() const { return m_wnd; }
-
-    /// Getter for the handler
-    uint32_t getParentOSHandle() const { return m_wnd_parent; }
+    /// Set the window handler
+    void setOSHandle( vout_window_t *pWnd ) const {
+        pWnd->type = VOUT_WINDOW_TYPE_XID;
+        pWnd->info.has_double_click = true;
+        pWnd->handle.xid = m_wnd;
+        pWnd->display.x11 = NULL;
+    }
 
     /// reparent the window
-    void reparent( uint32_t OSHandle, int x, int y, int w, int h );
+    void reparent( OSWindow *parent, int x, int y, int w, int h );
 
     /// invalidate a window surface
     bool invalidateRect( int x, int y, int w, int h ) const;



More information about the vlc-commits mailing list