diff --git a/xwords4/common/board.c b/xwords4/common/board.c index b9a0fbd3b..b97d5f8eb 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -77,6 +77,7 @@ static XP_Bool getCellRect( BoardCtxt* board, XP_U16 col, XP_U16 row, static XP_Bool drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks ); static void figureBoardRect( BoardCtxt* board ); +static void forceRectToBoard( const BoardCtxt* board, XP_Rect* rect ); static void drawBoard( BoardCtxt* board ); static void invalCell( BoardCtxt* board, XP_U16 col, XP_U16 row ); @@ -100,7 +101,7 @@ static void makeMiniWindowForText( BoardCtxt* board, const XP_UCHAR* text, static void invalTradeWindow( BoardCtxt* board, XP_S16 turn, XP_Bool redraw ); static void invalSelTradeWindow( BoardCtxt* board ); static void setTimerIf( BoardCtxt* board ); -static void p_board_timerFired( void* closure, XWTimerReason why ); +static XP_Bool p_board_timerFired( void* closure, XWTimerReason why ); static XP_Bool replaceLastTile( BoardCtxt* board ); static XP_Bool setTrayVisState( BoardCtxt* board, XW_TrayVisState newState ); @@ -749,7 +750,8 @@ positionMiniWRect( BoardCtxt* board, XP_Rect* rect, XP_Bool center ) rect->left = XP_MAX( board->boardBounds.left + 1, rect->left ); rect->top = XP_MAX( board->boardBounds.top + 1, y - rect->height ); } -} /* positionBonusRect */ + forceRectToBoard( board, rect ); +} /*positionMiniWRect */ static void timerFiredForPen( BoardCtxt* board ) @@ -841,7 +843,7 @@ timerFiredForTimer( BoardCtxt* board ) setTimerIf( board ); } /* timerFiredForTimer */ -static void +static XP_Bool p_board_timerFired( void* closure, XWTimerReason why ) { BoardCtxt* board = (BoardCtxt*)closure; @@ -851,6 +853,7 @@ p_board_timerFired( void* closure, XWTimerReason why ) XP_ASSERT( why == TIMER_TIMERTICK ); timerFiredForTimer( board ); } + return XP_FALSE; } /* board_timerFired */ void diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 3da1ac828..65dd31efe 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -1309,7 +1309,7 @@ heartbeat_checks( CommsCtxt* comms ) #endif #if defined RELAY_HEARTBEAT || defined COMMS_HEARTBEAT -static void +static XP_Bool p_comms_timerFired( void* closure, XWTimerReason XP_UNUSED_DBG(why) ) { CommsCtxt* comms = (CommsCtxt*)closure; @@ -1328,6 +1328,7 @@ p_comms_timerFired( void* closure, XWTimerReason XP_UNUSED_DBG(why) ) heartbeat_checks( comms ); #endif } + return XP_FALSE; /* no need for redraw */ } /* p_comms_timerFired */ static void diff --git a/xwords4/common/dragdrpp.c b/xwords4/common/dragdrpp.c index ea501d950..7c3a33ea4 100644 --- a/xwords4/common/dragdrpp.c +++ b/xwords4/common/dragdrpp.c @@ -512,9 +512,10 @@ setLimitsFrom( const BoardCtxt* board, BdHintLimits* limits ) limits->bottom = XP_MAX( ds->start.u.board.row, ds->cur.u.board.row ); } -static void +static XP_Bool scrollTimerProc( void* closure, XWTimerReason why ) { + XP_Bool draw = XP_FALSE; BoardCtxt* board = (BoardCtxt*)closure; DragState* ds = &board->dragState; XP_ASSERT( why == TIMER_PENDOWN ); @@ -529,9 +530,11 @@ scrollTimerProc( void* closure, XWTimerReason why ) ds->cur.u.board.row ) ) { board_draw( board ); /* may fail, e.g. on wince */ startScrollTimerIf( board ); + draw = XP_TRUE; } } } + return draw; } /* scrollTimerProc */ static void diff --git a/xwords4/common/util.h b/xwords4/common/util.h index d987fb9c4..5cc1cb57c 100644 --- a/xwords4/common/util.h +++ b/xwords4/common/util.h @@ -91,7 +91,8 @@ typedef struct BadWordInfo { XP_UCHAR* words[MAX_TRAY_TILES+1]; /* can form in both directions */ } BadWordInfo; -typedef void (*XWTimerProc)( void* closure, XWTimerReason why ); +/* XWTimerProc returns true if redraw was necessitated by what the proc did */ +typedef XP_Bool (*XWTimerProc)( void* closure, XWTimerReason why ); /* Platform-specific utility functions that need to be */ diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index 2965bfa06..6f903aafd 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -1798,12 +1798,11 @@ ceFireTimer( CEAppGlobals* globals, XWTimerReason why ) if ( !!proc ) { globals->timerProcs[why] = NULL; closure = globals->timerClosures[why]; - (*proc)( closure, why ); + draw = (*proc)( closure, why ); /* Setting draw after firing timer allows scrolling to happen while pen is held down. This is a hack. Perhaps having the timer proc return whether drawing is needed would be more consistent. */ - draw = XP_TRUE; } else { XP_LOGF( "skipped timer; alread fired?" ); }