]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/x11/x11_factory.cpp
--no-xlib: prevent use of XInitThreads() and hence Xlib
[vlc] / modules / gui / skins2 / x11 / x11_factory.cpp
index d4672372dffbd78431b3692431c48bdccc3119a0..5d09402ba99324738a2d375d9f344e79d46103b0 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef X11_SKINS
@@ -38,6 +38,7 @@
 #include "x11_window.hpp"
 #include "x11_tooltip.hpp"
 
+#include "../src/generic_window.hpp"
 
 X11Factory::X11Factory( intf_thread_t *pIntf ): OSFactory( pIntf ),
     m_pDisplay( NULL ), m_pTimerLoop( NULL ), m_dirSep( "/" )
@@ -55,6 +56,13 @@ X11Factory::~X11Factory()
 
 bool X11Factory::init()
 {
+    // make sure xlib is safe-thread
+    if( !var_InheritBool( getIntf(), "xlib" ) || !XInitThreads() )
+    {
+        msg_Err( getIntf(), "initializing xlib for multi-threading failed" );
+        return false;
+    }
+
     // Create the X11 display
     m_pDisplay = new X11Display( getIntf() );
 
@@ -71,10 +79,13 @@ bool X11Factory::init()
                                      ConnectionNumber( pDisplay ) );
 
     // Initialize the resource path
-    m_resourcePath.push_back( (string)getIntf()->p_vlc->psz_homedir +
-        m_dirSep + CONFIG_DIR + "/skins2" );
+    char *datadir = config_GetUserDir( VLC_DATA_DIR );
+    m_resourcePath.push_back( (string)datadir + "/skins2" );
+    free( datadir );
     m_resourcePath.push_back( (string)"share/skins2" );
-    m_resourcePath.push_back( (string)DATA_PATH + "/skins2" );
+    datadir = config_GetDataDir( getIntf() );
+    m_resourcePath.push_back( (string)datadir + "/skins2" );
+    free( datadir );
 
     return true;
 }
@@ -103,6 +114,31 @@ void X11Factory::minimize()
                     DefaultScreen( m_pDisplay->getDisplay() ) );
 }
 
+void X11Factory::restore()
+{
+    // TODO
+}
+
+void X11Factory::addInTray()
+{
+    // TODO
+}
+
+void X11Factory::removeFromTray()
+{
+    // TODO
+}
+
+void X11Factory::addInTaskBar()
+{
+    // TODO
+}
+
+void X11Factory::removeFromTaskBar()
+{
+    // TODO
+}
+
 OSTimer *X11Factory::createOSTimer( CmdGeneric &rCmd )
 {
     return new X11Timer( getIntf(), rCmd );
@@ -110,10 +146,11 @@ OSTimer *X11Factory::createOSTimer( CmdGeneric &rCmd )
 
 
 OSWindow *X11Factory::createOSWindow( GenericWindow &rWindow, bool dragDrop,
-                                      bool playOnDrop, OSWindow *pParent )
+                                      bool playOnDrop, OSWindow *pParent,
+                                      GenericWindow::WindowType_t type )
 {
     return new X11Window( getIntf(), rWindow, *m_pDisplay, dragDrop,
-                          playOnDrop, (X11Window*)pParent );
+                          playOnDrop, (X11Window*)pParent, type );
 }
 
 
@@ -145,10 +182,10 @@ int X11Factory::getScreenHeight() const
 }
 
 
-Rect X11Factory::getWorkArea() const
+SkinsRect X11Factory::getWorkArea() const
 {
     // XXX
-    return Rect( 0, 0, getScreenWidth(), getScreenHeight() );
+    return SkinsRect( 0, 0, getScreenWidth(), getScreenHeight() );
 }
 
 
@@ -167,6 +204,11 @@ void X11Factory::getMousePos( int &rXPos, int &rYPos ) const
 
 void X11Factory::rmDir( const string &rPath )
 {
+    struct
+    {
+        struct dirent ent;
+        char buf[NAME_MAX + 1];
+    } buf;
     struct dirent *file;
     DIR *dir;
 
@@ -174,7 +216,7 @@ void X11Factory::rmDir( const string &rPath )
     if( !dir ) return;
 
     // Parse the directory and remove everything it contains
-    while( (file = readdir( dir )) )
+    while( readdir_r( dir, &buf.ent, &file ) == 0 && file != NULL )
     {
         struct stat statbuf;
         string filename = file->d_name;
@@ -187,7 +229,7 @@ void X11Factory::rmDir( const string &rPath )
 
         filename = rPath + "/" + filename;
 
-        if( !stat( filename.c_str(), &statbuf ) && statbuf.st_mode & S_IFDIR )
+        if( !stat( filename.c_str(), &statbuf ) && S_ISDIR(statbuf.st_mode) )
         {
             rmDir( filename );
         }