Commit dee4e431 authored by Cyril Deguet's avatar Cyril Deguet

* src/theme_loader.cpp: use yyrestart() instead of yyin= (should fix

  issues after reading a bad theme)
* x11/.*: removed the hack of storing pointers as window properties
parent 7ae380a5
......@@ -7,5 +7,5 @@ sed -e 's/\([SE]Tag_.*\)(void)/\1(void*)/' \
-e 's/\/\* XML processor entry point. \*\//#define YY_DECL int yylex(void *pContext)/' skin.h > skin.h.new && mv -f skin.h.new skin.h
flex -oflex.c -BLs skin.l
flex -oflex.c -B -L skin.l
sed -e 's/\([SE]Tag_[^()]*\)()/\1(pContext)/g' flex.c > flex.c.new && mv -f flex.c.new flex.c
......@@ -2,7 +2,7 @@
* theme_loader.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: theme_loader.cpp,v 1.3 2004/01/11 00:21:22 asmax Exp $
* $Id: theme_loader.cpp,v 1.4 2004/01/18 00:25:02 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -57,6 +57,7 @@ extern "C"
{
extern FILE *yyin;
int yylex( void *pContext );
void yyrestart( FILE *input_file );
}
bool ThemeLoader::load( const string &fileName )
......@@ -164,17 +165,16 @@ void ThemeLoader::deleteTempFiles( const string &path )
bool ThemeLoader::parse( const string &xmlFile )
{
// Things to do before loading theme
// getIntf()->p_sys->p_theme->OnLoadTheme();
// Set the file to parse
yyin = fopen( xmlFile.c_str(), "r" );
if( yyin == NULL )
FILE *file = fopen( xmlFile.c_str(), "r" );
if( file == NULL )
{
// Skin cannot be opened
msg_Err( getIntf(), "Cannot open the specified skin file: %s",
xmlFile.c_str() );
return false;
}
yyrestart( file );
// File loaded
msg_Dbg( getIntf(), "Using skin file: %s", xmlFile.c_str() );
......@@ -195,7 +195,7 @@ bool ThemeLoader::parse( const string &xmlFile )
// Start the parser
ParserContext context( getIntf() );
int lex = yylex( &context );
fclose( yyin );
fclose( file );
if( lex )
{
......
......@@ -2,7 +2,7 @@
* x11_factory.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_factory.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: x11_factory.hpp,v 1.2 2004/01/18 00:25:02 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -31,6 +31,7 @@
#include <map>
class X11Display;
class X11DragDrop;
class X11TimerLoop;
......@@ -38,6 +39,11 @@ class X11TimerLoop;
class X11Factory: public OSFactory
{
public:
/// Map to find the GenericWindow associated to a X11Window
map<Window, GenericWindow*> m_windowMap;
/// Map to find the Dnd object associated to a X11Window
map<Window, X11DragDrop*> m_dndMap;
X11Factory( intf_thread_t *pIntf );
virtual ~X11Factory();
......@@ -82,9 +88,6 @@ class X11Factory: public OSFactory
/// Get the timer loop
X11TimerLoop *getTimerLoop() const { return m_pTimerLoop; }
/// Map to find the GenericWindow associated with a X11Window
map<Window, GenericWindow*> m_windowMap;
private:
/// X11 display
X11Display *m_pDisplay;
......
......@@ -2,7 +2,7 @@
* x11_loop.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_loop.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: x11_loop.cpp,v 1.2 2004/01/18 00:25:02 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -348,9 +348,8 @@ void X11Loop::handleX11Event()
// Get the message type
string type = XGetAtomName( XDISPLAY, event.xclient.message_type );
// Find the D&D object for this window
X11DragDrop *pDnd = (X11DragDrop*)
retrievePointer( event.xany.window, "DND_OBJECT" );
// Find the DnD object for this window
X11DragDrop *pDnd = pFactory->m_dndMap[event.xany.window];
if( !pDnd )
{
msg_Err( getIntf(), "No associated D&D object !!" );
......@@ -383,26 +382,4 @@ void X11Loop::handleX11Event()
}
}
void *X11Loop::retrievePointer( Window wnd, const char *pName )
{
Atom typeRet;
int fmtRet;
unsigned long nRet, bRet;
unsigned char *propRet;
void *ptr;
// Retrieve the pointer on the generic window, which was
// stored as a window property
Atom prop = XInternAtom( XDISPLAY, pName, False );
Atom type = XInternAtom( XDISPLAY, "POINTER", False );
XGetWindowProperty( XDISPLAY, wnd, prop, 0,
((sizeof(void*)+3)/4), False, type,
&typeRet, &fmtRet, &nRet, &bRet, &propRet );
memcpy( &ptr, propRet, sizeof(void*));
XFree( propRet );
return ptr;
}
#endif
......@@ -2,7 +2,7 @@
* x11_loop.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_loop.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: x11_loop.hpp,v 1.2 2004/01/18 00:25:02 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -66,16 +66,12 @@ class X11Loop: public OSLoop
/// internal vlc key codes
map<KeySym, int> keysymToVlcKey;
// Private because it's a singleton
X11Loop( intf_thread_t *pIntf, X11Display &rDisplay );
virtual ~X11Loop();
/// Handle the next X11 event
void handleX11Event();
/// Retrieve a pointer stored in the window as a property
void *retrievePointer( Window wnd, const char *pName );
};
#endif
......@@ -2,7 +2,7 @@
* x11_window.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_window.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: x11_window.cpp,v 1.2 2004/01/18 00:25:02 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -72,17 +72,18 @@ X11Window::X11Window( intf_thread_t *pIntf, GenericWindow &rWindow,
// Drag & drop
if( m_dragDrop )
{
// Register the window as a drop target
// Create a Dnd object for this window
m_pDropTarget = new X11DragDrop( getIntf(), m_rDisplay, m_wnd,
playOnDrop );
// Register the window as a drop target
Atom xdndAtom = XInternAtom( XDISPLAY, "XdndAware", False );
char xdndVersion = 4;
XChangeProperty( XDISPLAY, m_wnd, xdndAtom, XA_ATOM, 32,
PropModeReplace, (unsigned char *)&xdndVersion, 1 );
// Store a pointer on the D&D object as a window property.
storePointer( "DND_OBJECT", (void*)m_pDropTarget );
// Store a pointer to be used in X11Loop
pFactory->m_dndMap[m_wnd] = m_pDropTarget;
}
// Change the window title XXX
......@@ -94,6 +95,7 @@ X11Window::~X11Window()
{
X11Factory *pFactory = (X11Factory*)X11Factory::instance( getIntf() );
pFactory->m_windowMap[m_wnd] = NULL;
pFactory->m_dndMap[m_wnd] = NULL;
if( m_dragDrop )
{
......@@ -142,18 +144,4 @@ void X11Window::toggleOnTop( bool onTop )
// XXX TODO
}
void X11Window::storePointer( const char *pName, void *pPtr )
{
// We don't assume pointers are 32bits, so it's a bit tricky
unsigned char data[sizeof(void*)];
memcpy( data, &pPtr, sizeof(void*) );
// Store the pointer on the generic window as a window property.
Atom prop = XInternAtom( XDISPLAY, pName, False );
Atom type = XInternAtom( XDISPLAY, "POINTER", False );
XChangeProperty( XDISPLAY, m_wnd, prop, type, 8, PropModeReplace, data,
sizeof(GenericWindow*) );
}
#endif
......@@ -2,7 +2,7 @@
* x11_window.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_window.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
* $Id: x11_window.hpp,v 1.2 2004/01/18 00:25:02 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -72,9 +72,6 @@ class X11Window: public OSWindow
bool m_dragDrop;
/// Drop target
X11DragDrop *m_pDropTarget;
/// Store a pointer in the window as a property
void storePointer( const char *pName, void *pPtr );
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment