From 82382a7cfa59ce587480a0629e588c3dd47cfcac Mon Sep 17 00:00:00 2001 From: ehouse Date: Mon, 25 Jan 2010 00:28:30 +0000 Subject: [PATCH] Pass results back via timers and call board_draw() when so indicates. Needed to test dragDropSetAdd. Candidate for merge to trunk. --- xwords4/linux/cursesmain.c | 6 ++++-- xwords4/linux/gtkmain.c | 16 ++++++++++++---- xwords4/linux/linuxmain.c | 10 ++++++---- xwords4/linux/linuxmain.h | 2 +- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index 7516d6741..09038fb06 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -969,8 +969,10 @@ fireCursesTimer( CursesAppGlobals* globals ) if ( !!smallestTip ) { XP_U32 now = util_getCurSeconds( globals->cGlobals.params->util ) ; if ( now >= smallestTip->when ) { - linuxFireTimer( &globals->cGlobals, - smallestTip - globals->cGlobals.timerInfo ); + if ( linuxFireTimer( &globals->cGlobals, + smallestTip - globals->cGlobals.timerInfo ) ){ + board_draw( globals->cGlobals.game.board ); + } } else { XP_LOGF( "skipping timer: now (%ld) < when (%ld)", now, smallestTip->when ); diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index a0ebe1ee5..9fb489dde 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -1336,7 +1336,9 @@ pentimer_idle_func( gpointer data ) gettimeofday( &tv, NULL ); if ( (tv.tv_usec - globals->penTv.tv_usec) >= globals->penTimerInterval) { - linuxFireTimer( &globals->cGlobals, TIMER_PENDOWN ); + if ( linuxFireTimer( &globals->cGlobals, TIMER_PENDOWN ) ) { + board_draw( globals->cGlobals.game.board ); + } callAgain = XP_FALSE; } @@ -1348,7 +1350,9 @@ score_timer_func( gpointer data ) { GtkAppGlobals* globals = (GtkAppGlobals*)data; - linuxFireTimer( &globals->cGlobals, TIMER_TIMERTICK ); + if ( linuxFireTimer( &globals->cGlobals, TIMER_TIMERTICK ) ) { + board_draw( globals->cGlobals.game.board ); + } return XP_FALSE; } /* score_timer_func */ @@ -1359,7 +1363,9 @@ comms_timer_func( gpointer data ) { GtkAppGlobals* globals = (GtkAppGlobals*)data; - linuxFireTimer( &globals->cGlobals, TIMER_COMMS ); + if ( linuxFireTimer( &globals->cGlobals, TIMER_COMMS ) ) { + board_draw( globals->cGlobals.game.board ); + } return (gint)0; } @@ -1371,7 +1377,9 @@ slowrob_timer_func( gpointer data ) { GtkAppGlobals* globals = (GtkAppGlobals*)data; - linuxFireTimer( &globals->cGlobals, TIMER_SLOWROBOT ); + if ( linuxFireTimer( &globals->cGlobals, TIMER_SLOWROBOT ) ) { + board_draw( globals->cGlobals.game.board ); + } return (gint)0; } diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index e13c30f87..5caadee6b 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -187,7 +187,7 @@ usage( char* appName, char* msg ) #endif #if defined PLATFORM_GTK "\t [-k] # ask for parameters via \"new games\" dlg\n" - "\t [-h numRowsHidded] \n" + "\t [-h numRowsHidden] \n" # ifdef XWFEATURE_SEARCHLIMIT "\t [-I] # don't support hint rect dragging\n" # endif @@ -585,21 +585,23 @@ linux_util_makeStreamFromAddr( XW_UtilCtxt* uctx, XP_U16 channelNo ) } /* linux_util_makeStreamFromAddr */ #endif -void +XP_Bool linuxFireTimer( CommonGlobals* cGlobals, XWTimerReason why ) { TimerInfo* tip = &cGlobals->timerInfo[why]; XWTimerProc proc = tip->proc; void* closure = tip->closure; + XP_Bool draw = false; tip->proc = NULL; if ( !!proc ) { - (*proc)( closure, why ); + draw = (*proc)( closure, why ); } else { XP_LOGF( "%s: skipping timer %d; cancelled?", __func__, why ); } -} /* fireTimer */ + return draw; +} /* linuxFireTimer */ #ifndef XWFEATURE_STANDALONE_ONLY static void diff --git a/xwords4/linux/linuxmain.h b/xwords4/linux/linuxmain.h index 9b2743ec7..f9e2ab517 100644 --- a/xwords4/linux/linuxmain.h +++ b/xwords4/linux/linuxmain.h @@ -49,7 +49,7 @@ void linux_reset( void* closure ); int linux_relay_receive( CommonGlobals* cGlobals, unsigned char* buf, int bufSize ); -void linuxFireTimer( CommonGlobals* cGlobals, XWTimerReason why ); +XP_Bool linuxFireTimer( CommonGlobals* cGlobals, XWTimerReason why ); XWStreamCtxt* stream_from_msgbuf( CommonGlobals* cGlobals,