00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef X11_SKINS
00026
00027 #include <unistd.h>
00028 #include <dirent.h>
00029 #include <sys/stat.h>
00030 #include <X11/Xlib.h>
00031
00032 #include "x11_factory.hpp"
00033 #include "x11_display.hpp"
00034 #include "x11_graphics.hpp"
00035 #include "x11_loop.hpp"
00036 #include "x11_timer.hpp"
00037 #include "x11_window.hpp"
00038 #include "x11_tooltip.hpp"
00039
00040
00041 X11Factory::X11Factory( intf_thread_t *pIntf ): OSFactory( pIntf ),
00042 m_pDisplay( NULL ), m_pTimerLoop( NULL ), m_dirSep( "/" )
00043 {
00044
00045 }
00046
00047
00048 X11Factory::~X11Factory()
00049 {
00050 delete m_pTimerLoop;
00051 delete m_pDisplay;
00052 }
00053
00054
00055 bool X11Factory::init()
00056 {
00057
00058 m_pDisplay = new X11Display( getIntf() );
00059
00060
00061 Display *pDisplay = m_pDisplay->getDisplay();
00062 if( pDisplay == NULL )
00063 {
00064
00065 return false;
00066 }
00067
00068
00069 m_pTimerLoop = new X11TimerLoop( getIntf(),
00070 ConnectionNumber( pDisplay ) );
00071
00072
00073 m_resourcePath.push_back( (string)getIntf()->p_vlc->psz_homedir +
00074 m_dirSep + CONFIG_DIR + "/skins2" );
00075 m_resourcePath.push_back( (string)"share/skins2" );
00076 m_resourcePath.push_back( (string)DATA_PATH + "/skins2" );
00077
00078 return true;
00079 }
00080
00081
00082 OSGraphics *X11Factory::createOSGraphics( int width, int height )
00083 {
00084 return new X11Graphics( getIntf(), *m_pDisplay, width, height );
00085 }
00086
00087
00088 OSLoop *X11Factory::getOSLoop()
00089 {
00090 return X11Loop::instance( getIntf(), *m_pDisplay );
00091 }
00092
00093
00094 void X11Factory::destroyOSLoop()
00095 {
00096 X11Loop::destroy( getIntf() );
00097 }
00098
00099 void X11Factory::minimize()
00100 {
00101 XIconifyWindow( m_pDisplay->getDisplay(), m_pDisplay->getMainWindow(),
00102 DefaultScreen( m_pDisplay->getDisplay() ) );
00103 }
00104
00105 OSTimer *X11Factory::createOSTimer( CmdGeneric &rCmd )
00106 {
00107 return new X11Timer( getIntf(), rCmd );
00108 }
00109
00110
00111 OSWindow *X11Factory::createOSWindow( GenericWindow &rWindow, bool dragDrop,
00112 bool playOnDrop, OSWindow *pParent )
00113 {
00114 return new X11Window( getIntf(), rWindow, *m_pDisplay, dragDrop,
00115 playOnDrop, (X11Window*)pParent );
00116 }
00117
00118
00119 OSTooltip *X11Factory::createOSTooltip()
00120 {
00121 return new X11Tooltip( getIntf(), *m_pDisplay );
00122 }
00123
00124
00125 int X11Factory::getScreenWidth() const
00126 {
00127 Display *pDisplay = m_pDisplay->getDisplay();
00128 int screen = DefaultScreen( pDisplay );
00129 return DisplayWidth( pDisplay, screen );
00130 }
00131
00132
00133 int X11Factory::getScreenHeight() const
00134 {
00135 Display *pDisplay = m_pDisplay->getDisplay();
00136 int screen = DefaultScreen( pDisplay );
00137 return DisplayHeight( pDisplay, screen );
00138 }
00139
00140
00141 Rect X11Factory::getWorkArea() const
00142 {
00143
00144 return Rect( 0, 0, getScreenWidth(), getScreenHeight() );
00145 }
00146
00147
00148 void X11Factory::getMousePos( int &rXPos, int &rYPos ) const
00149 {
00150 Window rootReturn, childReturn;
00151 int winx, winy;
00152 unsigned int xmask;
00153
00154 Display *pDisplay = m_pDisplay->getDisplay();
00155 Window root = DefaultRootWindow( pDisplay );
00156 XQueryPointer( pDisplay, root, &rootReturn, &childReturn,
00157 &rXPos, &rYPos, &winx, &winy, &xmask );
00158 }
00159
00160
00161 void X11Factory::rmDir( const string &rPath )
00162 {
00163 struct dirent *file;
00164 DIR *dir;
00165
00166 dir = opendir( rPath.c_str() );
00167 if( !dir ) return;
00168
00169
00170 while( (file = readdir( dir )) )
00171 {
00172 struct stat statbuf;
00173 string filename = file->d_name;
00174
00175
00176 if( filename == "." || filename == ".." )
00177 {
00178 continue;
00179 }
00180
00181 filename = rPath + "/" + filename;
00182
00183 if( !stat( filename.c_str(), &statbuf ) && statbuf.st_mode & S_IFDIR )
00184 {
00185 rmDir( filename );
00186 }
00187 else
00188 {
00189 unlink( filename.c_str() );
00190 }
00191 }
00192
00193
00194 closedir( dir );
00195
00196
00197 rmdir( rPath.c_str() );
00198 }
00199
00200
00201 #endif