modules/gui/skins/x11/x11_run.cpp \
modules/gui/skins/x11/x11_theme.cpp \
modules/gui/skins/x11/x11_theme.h \
+ modules/gui/skins/x11/x11_timer.cpp \
+ modules/gui/skins/x11/x11_timer.h \
modules/gui/skins/x11/x11_window.cpp \
modules/gui/skins/x11/x11_window.h
* text.cpp: Text control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: text.cpp,v 1.9 2003/04/28 14:12:32 asmax Exp $
+ * $Id: text.cpp,v 1.10 2003/06/05 22:16:15 asmax Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
+ * Cyril Deguet <asmax@videolan.org>
*
* 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
#include "../os_window.h"
#include "../src/skin_common.h"
+#ifdef X11_SKINS
+#include "../x11/x11_timer.h"
+extern intf_thread_t *g_pIntf;
+#endif
+
//---------------------------------------------------------------------------
//-----------------------------------------------------------------------
// X11 methods
- //-----------------------------------------------------------------------
+ //-----------------------------------------------------------------------
+ void ScrollingTextTimer( void *data )
+ {
+ if( (ControlText *)data != NULL
+ && !( (ControlText *)data )->GetSelected() )
+ {
+ ( (ControlText *)data )->DoScroll();
+ }
+ }
+
//-----------------------------------------------------------------------
void ControlText::StartScrolling()
{
+ X11Timer *timer = new X11Timer( g_pIntf, 100000, ScrollingTextTimer,
+ (void*)this );
+ X11TimerManager *timerManager = X11TimerManager::Instance( g_pIntf );
+ timerManager->addTimer( timer );
}
//-----------------------------------------------------------------------
void ControlText::StopScrolling()
* x11_run.cpp:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: x11_run.cpp,v 1.14 2003/06/03 22:18:58 gbazin Exp $
+ * $Id: x11_run.cpp,v 1.15 2003/06/05 22:16:15 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
#include "../os_theme.h"
#include "../src/skin_common.h"
#include "../src/vlcproc.h"
+#include "x11_timer.h"
+
//---------------------------------------------------------------------------
// Specific method
return 0;
}
+
+void RefreshCallback( void *data )
+{
+ SkinManage( (intf_thread_t*)data );
+}
+
+
//---------------------------------------------------------------------------
// X11 interface
//---------------------------------------------------------------------------
Display *display = ((OSTheme *)p_intf->p_sys->p_theme)->GetDisplay();
+
+ // Timer for SkinManage
+ X11Timer *refreshTimer = new X11Timer( p_intf, 100000, RefreshCallback,
+ (void*)p_intf );
+ X11TimerManager *timerManager = X11TimerManager::Instance( p_intf );
+ timerManager->addTimer( refreshTimer );
+
// Main event loop
int close = 0;
- int count = 0;
while( !close )
{
XEvent event;
nPending = XPending( display );
XUNLOCK;
}
-
msleep( 1000 );
- if( ++count == 100 )
- {
- count = 0;
- SkinManage( p_intf ); // Call every 100 ms
- }
}
+
+ timerManager->Destroy();
+ delete refreshTimer;
+
}
//---------------------------------------------------------------------------
bool IsVLCEvent( unsigned int msg )
--- /dev/null
+/*****************************************************************************
+ * x11_timer.cpp: helper class to implement timers
+ *****************************************************************************
+ * Copyright (C) 2003 VideoLAN
+ * $Id: x11_timer.cpp,v 1.1 2003/06/05 22:16:15 asmax Exp $
+ *
+ * Authors: Cyril Deguet <asmax@videolan.org>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ *****************************************************************************/
+
+#ifdef X11_SKINS
+
+//--- VLC -------------------------------------------------------------------
+#include <vlc/intf.h>
+#include <mtime.h>
+
+//--- SKIN ------------------------------------------------------------------
+#include "x11_timer.h"
+
+
+//---------------------------------------------------------------------------
+
+X11Timer::X11Timer( intf_thread_t *p_intf, mtime_t interval, callback_t func,
+ void *data )
+{
+ _p_intf = p_intf;
+ _interval = interval;
+ _callback = func;
+ _data = data;
+}
+
+
+X11Timer::~X11Timer()
+{
+}
+
+
+mtime_t X11Timer::getNextDate( mtime_t current )
+{
+ return (current / _interval + 1) * _interval;
+}
+
+
+void X11Timer::Execute()
+{
+ (*_callback)( _data );
+}
+
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+
+X11TimerManager *X11TimerManager::_instance = NULL;
+
+
+X11TimerManager::X11TimerManager( intf_thread_t *p_intf )
+{
+ _p_intf = p_intf;
+
+ // Create the timer thread
+ _p_timer = (timer_thread_t*)vlc_object_create( _p_intf,
+ sizeof( timer_thread_t ) );
+ _p_timer->die = 0;
+}
+
+
+X11TimerManager::~X11TimerManager()
+{
+ _p_timer->die = 1;
+ vlc_thread_join( _p_timer );
+}
+
+
+// Return the instance of X11TimerManager (design pattern singleton)
+X11TimerManager *X11TimerManager::Instance( intf_thread_t *p_intf )
+{
+ if( _instance == NULL )
+ {
+ _instance = new X11TimerManager( p_intf );
+ // Run the timer thread
+ vlc_thread_create( _instance->_p_timer, "Skins timer thread",
+ &Thread, 0, VLC_TRUE );
+ }
+ return _instance;
+}
+
+
+// Destroy the instance, if any
+void X11TimerManager::Destroy()
+{
+ if( _instance != NULL )
+ {
+ delete _instance;
+ }
+}
+
+
+// Main timer loop
+void *X11TimerManager::Thread( void *p_timer )
+{
+ vlc_thread_ready( (vlc_object_t*) p_timer );
+ while( !((timer_thread_t*)p_timer)->die )
+ {
+ list<X11Timer*>::iterator timer;
+ // FIXME temporary
+ for( timer = _instance->_timers.begin();
+ timer != _instance->_timers.end(); timer++ )
+ {
+ (*timer)->Execute();
+ }
+ msleep( 100000 );
+ }
+
+}
+
+#endif
--- /dev/null
+/*****************************************************************************
+ * x11_timer.h: helper class to implement timers
+ *****************************************************************************
+ * Copyright (C) 2003 VideoLAN
+ * $Id: x11_timer.h,v 1.1 2003/06/05 22:16:15 asmax Exp $
+ *
+ * Authors: Cyril Deguet <asmax@videolan.org>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ *****************************************************************************/
+
+
+#ifndef VLC_SKIN_X11_TIMER
+#define VLC_SKIN_X11_TIMER
+
+#include <list.h>
+
+typedef struct
+{
+ VLC_COMMON_MEMBERS
+ int die;
+} timer_thread_t;
+
+class X11Timer; // forward declaration
+
+typedef void(*callback_t)( void* );
+
+//---------------------------------------------------------------------------
+class X11Timer
+{
+ private:
+ intf_thread_t *_p_intf;
+ mtime_t _interval;
+ callback_t _callback;
+ void *_data;
+
+ public:
+ X11Timer( intf_thread_t *p_intf, mtime_t interval, callback_t func,
+ void *data );
+ ~X11Timer();
+
+ mtime_t getNextDate( mtime_t current );
+ void Execute();
+};
+//---------------------------------------------------------------------------
+class X11TimerManager
+{
+ private:
+ static X11TimerManager *_instance;
+ intf_thread_t *_p_intf;
+ timer_thread_t *_p_timer;
+ list<X11Timer*> _timers;
+
+ X11TimerManager( intf_thread_t *p_intf );
+ ~X11TimerManager();
+
+ static void *Thread( void *p_timer );
+
+ public:
+ static X11TimerManager *Instance( intf_thread_t *p_intf );
+ void Destroy();
+
+ void addTimer( X11Timer *timer ) { _timers.push_back( timer ); }
+
+};
+//---------------------------------------------------------------------------
+#endif