mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +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;
|
return XP_TRUE;
|
||||||
} /* curses_util_engineProgressCallback */
|
} /* 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
|
static void
|
||||||
curses_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
|
curses_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
|
||||||
XWTimerProc proc, void* closure )
|
XWTimerProc proc, void* closure )
|
||||||
{
|
{
|
||||||
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
|
||||||
XP_U32 nextTimer;
|
TimerInfo* ti = &globals->cGlobals.timerInfo[why];
|
||||||
|
|
||||||
globals->cGlobals.timerInfo[why].proc = proc;
|
ti->proc = proc;
|
||||||
globals->cGlobals.timerInfo[why].closure = closure;
|
ti->closure = closure;
|
||||||
|
|
||||||
nextTimer = util_getCurSeconds(uc) + when;
|
#ifdef USE_GLIBLOOP
|
||||||
globals->cGlobals.timerInfo[why].when = nextTimer;
|
ti->globals = &globals->cGlobals;
|
||||||
if ( globals->nextTimer > nextTimer ) {
|
(void)g_timeout_add_seconds( when, timerFired, ti );
|
||||||
globals->nextTimer = nextTimer;
|
#else
|
||||||
}
|
ti->when = util_getCurSeconds(uc) + when;
|
||||||
|
#endif
|
||||||
} /* curses_util_setTimer */
|
} /* curses_util_setTimer */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -92,8 +92,6 @@ struct CursesAppGlobals {
|
||||||
struct pollfd fdArray[FD_MAX]; /* one for stdio, one for listening socket */
|
struct pollfd fdArray[FD_MAX]; /* one for stdio, one for listening socket */
|
||||||
int timepipe[2]; /* for reading/writing "user events" */
|
int timepipe[2]; /* for reading/writing "user events" */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XP_U32 nextTimer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_GLIBLOOP
|
#ifdef USE_GLIBLOOP
|
||||||
|
|
|
@ -138,7 +138,11 @@ typedef struct LinSMSData LinSMSData;
|
||||||
typedef struct _TimerInfo {
|
typedef struct _TimerInfo {
|
||||||
XWTimerProc proc;
|
XWTimerProc proc;
|
||||||
void* closure;
|
void* closure;
|
||||||
|
#ifdef USE_GLIBLOOP
|
||||||
|
struct CommonGlobals* globals;
|
||||||
|
#else
|
||||||
XP_U32 when; /* used only for ncurses */
|
XP_U32 when; /* used only for ncurses */
|
||||||
|
#endif
|
||||||
} TimerInfo;
|
} TimerInfo;
|
||||||
|
|
||||||
struct CommonGlobals {
|
struct CommonGlobals {
|
||||||
|
|
Loading…
Add table
Reference in a new issue