mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
changes to use glib main loop were incomplete, didn't include timers.
Fix that. Now discon_ok2.sh test works with the USE_GLIBLOOP turned on.
This commit is contained in:
parent
c2e2bdf3c5
commit
7e0252713c
3 changed files with 28 additions and 10 deletions
|
@ -373,21 +373,37 @@ curses_util_engineProgressCallback( XW_UtilCtxt* XP_UNUSED(uc) )
|
|||
return XP_TRUE;
|
||||
} /* curses_util_engineProgressCallback */
|
||||
|
||||
#ifdef USE_GLIBLOOP
|
||||
static gboolean
|
||||
timerFired( gpointer data )
|
||||
{
|
||||
TimerInfo* ti = (TimerInfo*)data;
|
||||
CommonGlobals* globals = ti->globals;
|
||||
XWTimerReason why = ti - globals->timerInfo;
|
||||
if ( linuxFireTimer( globals, why ) ) {
|
||||
board_draw( globals->game.board );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
curses_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
|
||||
XWTimerProc proc, void* closure )
|
||||
{
|
||||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||
XP_U32 nextTimer;
|
||||
TimerInfo* ti = &globals->cGlobals.timerInfo[why];
|
||||
|
||||
globals->cGlobals.timerInfo[why].proc = proc;
|
||||
globals->cGlobals.timerInfo[why].closure = closure;
|
||||
ti->proc = proc;
|
||||
ti->closure = closure;
|
||||
|
||||
nextTimer = util_getCurSeconds(uc) + when;
|
||||
globals->cGlobals.timerInfo[why].when = nextTimer;
|
||||
if ( globals->nextTimer > nextTimer ) {
|
||||
globals->nextTimer = nextTimer;
|
||||
}
|
||||
#ifdef USE_GLIBLOOP
|
||||
ti->globals = &globals->cGlobals;
|
||||
(void)g_timeout_add_seconds( when, timerFired, ti );
|
||||
#else
|
||||
ti->when = util_getCurSeconds(uc) + when;
|
||||
#endif
|
||||
} /* curses_util_setTimer */
|
||||
|
||||
static void
|
||||
|
|
|
@ -92,8 +92,6 @@ struct CursesAppGlobals {
|
|||
struct pollfd fdArray[FD_MAX]; /* one for stdio, one for listening socket */
|
||||
int timepipe[2]; /* for reading/writing "user events" */
|
||||
#endif
|
||||
|
||||
XP_U32 nextTimer;
|
||||
};
|
||||
|
||||
#ifdef USE_GLIBLOOP
|
||||
|
|
|
@ -138,7 +138,11 @@ typedef struct LinSMSData LinSMSData;
|
|||
typedef struct _TimerInfo {
|
||||
XWTimerProc proc;
|
||||
void* closure;
|
||||
#ifdef USE_GLIBLOOP
|
||||
struct CommonGlobals* globals;
|
||||
#else
|
||||
XP_U32 when; /* used only for ncurses */
|
||||
#endif
|
||||
} TimerInfo;
|
||||
|
||||
struct CommonGlobals {
|
||||
|
|
Loading…
Add table
Reference in a new issue