From a1a0f9934ab1a6b04b45a96dc502b544d8c3debc Mon Sep 17 00:00:00 2001 From: ehouse Date: Mon, 23 Apr 2007 03:20:37 +0000 Subject: [PATCH] Call HsNavDrawFocusRing on Treo600, FrmNavDrawFocusRing on later devices. Fixes crasher on devices that don't have the former. Up version. --- xwords4/palm/newgame.c | 4 ++-- xwords4/palm/pace_man.c | 32 ++++++++++++++++++++++++++++++++ xwords4/palm/palmmain.c | 12 ++++++++++-- xwords4/palm/palmmain.h | 5 +++++ xwords4/palm/palmutil.c | 35 +++++++++++++++++++++++++++++------ xwords4/palm/palmutil.h | 7 ++++--- xwords4/palm/prefsdlg.c | 4 ++-- xwords4/palm/xwords4defines.h | 2 +- 8 files changed, 85 insertions(+), 16 deletions(-) diff --git a/xwords4/palm/newgame.c b/xwords4/palm/newgame.c index 20c5b8491..8c66047f8 100644 --- a/xwords4/palm/newgame.c +++ b/xwords4/palm/newgame.c @@ -141,7 +141,7 @@ newGameHandleEvent( EventPtr event ) object */ case frmObjectFocusTakeEvent: case frmObjectFocusLostEvent: - result = considerGadgetFocus( event, XW_SOLO_GADGET_ID, + result = considerGadgetFocus( globals, event, XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID ); break; #endif @@ -345,7 +345,7 @@ drawConnectGadgets( PalmAppGlobals* globals ) drawGadgetsFromList( list, XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID, hiliteItem ); #ifdef XWFEATURE_FIVEWAY - drawFocusRingOnGadget( XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID ); + drawFocusRingOnGadget( globals, XW_SOLO_GADGET_ID, XW_CLIENT_GADGET_ID ); #endif } /* drawConnectGadgets */ diff --git a/xwords4/palm/pace_man.c b/xwords4/palm/pace_man.c index e89f7e341..5e3f0606d 100644 --- a/xwords4/palm/pace_man.c +++ b/xwords4/palm/pace_man.c @@ -168,6 +168,38 @@ HsNavDrawFocusRing (FormType* formP, UInt16 objectID, Int16 extraInfo, FUNC_TAIL(HsNavDrawFocusRing); return result; } + +Err +FrmNavDrawFocusRing(FormType* formP, UInt16 objectID, Int16 extraInfo, + RectangleType* rP, + HsNavFocusRingStyleEnum ringStyle, Boolean forceRestore) +{ + Err result; + FUNC_HEADER(FrmNavDrawFocusRing); + + RectangleType RectangleType_68K1; + SWAP_RECTANGLETYPE_ARM_TO_68K( &RectangleType_68K1, rP ); + { + PNOState* sp = GET_CALLBACK_STATE(); + STACK_START(unsigned char, stack, 18); + + ADD_TO_STACK2(stack, 0x0007, 0); + ADD_TO_STACK4(stack, formP, 2); + ADD_TO_STACK2(stack, objectID, 6); + ADD_TO_STACK2(stack, extraInfo, 8); + ADD_TO_STACK4(stack, &RectangleType_68K1, 10); + ADD_TO_STACK1(stack, ringStyle, 14); + ADD_TO_STACK1(stack, forceRestore, 16); + STACK_END(stack); + + result = (Err)(*sp->call68KFuncP)( sp->emulStateP, + PceNativeTrapNo(sysTrapNavSelector), + stack, 18 ); + sp->emulStateP->regA[7] -= 2; + } + FUNC_TAIL(FrmNavDrawFocusRing); + return result; +} #endif /* Need to parse the format string */ diff --git a/xwords4/palm/palmmain.c b/xwords4/palm/palmmain.c index 64ebf1fa0..277fdb480 100644 --- a/xwords4/palm/palmmain.c +++ b/xwords4/palm/palmmain.c @@ -968,12 +968,20 @@ initHighResGlobals( PalmAppGlobals* globals ) && (err == errNone) && (vers >= 5); #ifdef XWFEATURE_FIVEWAY +# ifndef hsFtrIDNavigationSupported +# define hsFtrIDNavigationSupported 14 +# endif err = FtrGet( sysFtrCreator, sysFtrNumUIHardwareFlags, &vers ); globals->generatesKeyUp = ( (err == errNone) && ((vers & sysFtrNumUIHardwareHasKbd) != 0) ) || globals->isZodiac; globals->hasTreoFiveWay = (err == errNone) && ((vers & sysFtrNumUIHardwareHas5Way) != 0) && !globals->isZodiac; + + err = FtrGet( hsFtrCreator, hsFtrIDNavigationSupported, &vers ); + XP_ASSERT( errNone == err ); + XP_ASSERT( vers == 1 || vers == 2 ); + globals->isTreo600 = (err == errNone) && (vers == 1); #endif #ifdef FEATURE_SILK @@ -1833,11 +1841,11 @@ drawFormButtons( PalmAppGlobals* globals ) setFormFocus( globals->mainForm, focusItem ); if ( !isBoardObject( focusItem ) && buttonIsUsable( getActiveObjectPtr(focusItem) ) ) { - drawFocusRingOnGadget( focusItem, focusItem ); + drawFocusRingOnGadget( globals, focusItem, focusItem ); } globals->gState.focusItem = -1; } else { - drawFocusRingOnGadget( XW_MAIN_DONE_BUTTON_ID, + drawFocusRingOnGadget( globals, XW_MAIN_DONE_BUTTON_ID, XW_MAIN_HIDE_BUTTON_ID ); } } diff --git a/xwords4/palm/palmmain.h b/xwords4/palm/palmmain.h index 66a8d94fb..1f0f14c99 100644 --- a/xwords4/palm/palmmain.h +++ b/xwords4/palm/palmmain.h @@ -275,6 +275,9 @@ struct PalmAppGlobals { Boolean menuIsDown; XP_Bool newGameIsNew; XP_Bool runningOnPOSE; /* Needed for NetLibSelect */ +#ifdef XWFEATURE_FIVEWAY + XP_Bool isTreo600; +#endif #ifdef XWFEATURE_BLUETOOTH XP_Bool userCancelledBT; #endif @@ -423,4 +426,6 @@ void checkAndDeliver( PalmAppGlobals* globals, const CommsAddrRec* addr, # define READ_UNALIGNED16(n) *(n) #endif +#define IS_T600(g) (g)->isTreo600 + #endif /* _PALMMAIN_H_ */ diff --git a/xwords4/palm/palmutil.c b/xwords4/palm/palmutil.c index 60ca80219..465383660 100644 --- a/xwords4/palm/palmutil.c +++ b/xwords4/palm/palmutil.c @@ -411,8 +411,23 @@ setFormFocus( FormPtr form, XP_U16 objectID ) FrmSetFocus( form, FrmGetObjectIndex( form, objectID ) ); } /* setFormFocus */ +#ifndef XW_TARGET_PNO +/* Warning: gross hack. HsNavDrawFocusRing doesn't work on newer Palms, + e.g. Tungsten T. It's been replaced by FrmNavDrawFocusRing. But that + requires the sdk-5r4 headers which require significant changes I don't want + to make right before shipping. So here's a hack: define FrmNavDrawFocusRing + based on info in the r4 header info without actually including any headers. +*/ +Err FrmNavDrawFocusRing( FormType* fp, UInt16 oid, Int16 ei, + RectangleType* birp, + HsNavFocusRingStyleEnum rs, Boolean fr ) + _SYSTEM_API(_CALL_WITH_UNPOPPED_16BIT_SELECTOR)(_SYSTEM_TABLE, + sysTrapNavSelector, + 0x07 ); +#endif + void -drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh ) +drawFocusRingOnGadget( PalmAppGlobals* globals, XP_U16 idLow, XP_U16 idHigh ) { FormPtr form; XP_S16 index; @@ -430,16 +445,24 @@ drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh ) getObjectBounds( focusID, &rect ); /* growing the rect didn't work to fix glitches in ring drawing. */ - err = HsNavDrawFocusRing( form, focusID, 0, &rect, - hsNavFocusRingStyleObjectTypeDefault, - false ); + if ( IS_T600(globals) ) { + XP_LOGF( "%s: calling HsNavDrawFocusRing", __func__ ); + err = HsNavDrawFocusRing( form, focusID, 0, &rect, + hsNavFocusRingStyleObjectTypeDefault, + false ); + } else { + XP_LOGF( "%s: calling FrmNavDrawFocusRing", __func__ ); + err = FrmNavDrawFocusRing( form, focusID, 0, &rect, + hsNavFocusRingStyleObjectTypeDefault, + false ); + } XP_ASSERT( err == errNone ); } } } /* drawFocusRingOnGadget */ XP_Bool -considerGadgetFocus( const EventType* event, XP_U16 idLow, XP_U16 idHigh ) +considerGadgetFocus( PalmAppGlobals* globals, const EventType* event, XP_U16 idLow, XP_U16 idHigh ) { XP_Bool handled; XP_U16 objectID; @@ -456,7 +479,7 @@ considerGadgetFocus( const EventType* event, XP_U16 idLow, XP_U16 idHigh ) if ( event->eType == frmObjectFocusTakeEvent ) { FormPtr form = FrmGetActiveForm(); setFormFocus( form, objectID ); - drawFocusRingOnGadget( idLow, idHigh ); + drawFocusRingOnGadget( globals, idLow, idHigh ); } } diff --git a/xwords4/palm/palmutil.h b/xwords4/palm/palmutil.h index ef7e816ad..82d3e464d 100644 --- a/xwords4/palm/palmutil.h +++ b/xwords4/palm/palmutil.h @@ -78,9 +78,10 @@ void drawOneGadget( UInt16 id, const char* text, Boolean hilite ); # ifdef XWFEATURE_FIVEWAY XP_S16 getFocusOwner( void ); void setFormFocus( FormPtr form, XP_U16 objectID ); -void drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh ); -XP_Bool considerGadgetFocus( const EventType* event, XP_U16 idLow, - XP_U16 idHigh ); +void drawFocusRingOnGadget( PalmAppGlobals* globals, XP_U16 idLow, + XP_U16 idHigh ); +XP_Bool considerGadgetFocus( PalmAppGlobals* globals, const EventType* event, + XP_U16 idLow, XP_U16 idHigh ); XP_Bool tryRockerKey( XP_U16 key, XP_U16 selGadget, XP_U16 idLow, XP_U16 idHigh ); diff --git a/xwords4/palm/prefsdlg.c b/xwords4/palm/prefsdlg.c index d6b4cf3f1..10836b120 100644 --- a/xwords4/palm/prefsdlg.c +++ b/xwords4/palm/prefsdlg.c @@ -101,7 +101,7 @@ PrefsFormHandleEvent( EventPtr event ) case frmObjectFocusTakeEvent: case frmObjectFocusLostEvent: - result = considerGadgetFocus( event, XW_PREFS_ALLGAMES_GADGET_ID, + result = considerGadgetFocus( globals, event, XW_PREFS_ALLGAMES_GADGET_ID, XW_PREFS_ONEGAME_GADGET_ID ); break; #endif @@ -353,7 +353,7 @@ drawPrefsTypeGadgets( PalmAppGlobals* globals ) drawGadgetsFromList( list, XW_PREFS_ALLGAMES_GADGET_ID, XW_PREFS_ONEGAME_GADGET_ID, active ); #ifdef XWFEATURE_FIVEWAY - drawFocusRingOnGadget( XW_PREFS_ALLGAMES_GADGET_ID, + drawFocusRingOnGadget( globals, XW_PREFS_ALLGAMES_GADGET_ID, XW_PREFS_ONEGAME_GADGET_ID ); #endif LOG_RETURN_VOID(); diff --git a/xwords4/palm/xwords4defines.h b/xwords4/palm/xwords4defines.h index af76b9095..36e2a0c18 100644 --- a/xwords4/palm/xwords4defines.h +++ b/xwords4/palm/xwords4defines.h @@ -436,7 +436,7 @@ #ifdef XWFEATURE_BLUETOOTH # define XW_PALM_VERSION_STRING "4.3a8" #else -# define XW_PALM_VERSION_STRING "4.2rc1" +# define XW_PALM_VERSION_STRING "4.2rc2" #endif #define CUR_PREFS_VERS 0x0405