cherry-pick three revisions from toolbar branch (d1c7d4097c, f848473c1a and 6484a2fb9b) and manually fix conflicts.

This commit is contained in:
Andy2 2010-07-12 18:48:03 -07:00
parent 19ea138f8e
commit de32e514ab
10 changed files with 39 additions and 86 deletions

View file

@ -16,8 +16,6 @@ local_DEFINES += \
-DXWFEATURE_RELAY \
-DXWFEATURE_TURNCHANGENOTIFY \
-DXWFEATURE_CROSSHAIRS \
-DKEYBOARD_NAV \
-DPERIMETER_FOCUS \
-DKEY_SUPPORT \
-DPOINTER_SUPPORT \
-DSCROLL_DRAG_THRESHHOLD=1 \

View file

@ -1000,6 +1000,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1server_1prefsChanged
return result;
}
#ifdef KEYBOARD_NAV
JNIEXPORT jint JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_board_1getFocusOwner
( JNIEnv* env, jclass C, jint gamePtr )
@ -1021,6 +1022,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1focusChanged
XWJNI_END();
return result;
}
#endif
JNIEXPORT jboolean JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_board_1handleKey

View file

@ -88,7 +88,6 @@ public class JNIThread extends Thread {
private Handler m_handler;
private SyncedDraw m_drawer;
private static final int kMinDivWidth = 10;
private boolean m_keyDown = false;
private Rect m_connsIconRect;
private int m_connsIconID = 0;
private boolean m_inBack = false;
@ -196,54 +195,6 @@ public class JNIThread extends Thread {
boolean[] barr )
{
boolean draw = false;
boolean handled = false;
boolean goingUp = JNICmd.CMD_KEYUP == cmd;
if ( m_keyDown && !goingUp ) {
// ignore duplicate downs for now
} else {
// sometimes ups come without prior downs. Fake a down in
// that case.
if ( goingUp && !m_keyDown ) {
draw = XwJNI.board_handleKey( m_jniGamePtr, xpKey, false, barr );
handled = barr[0];
}
if ( XwJNI.board_handleKey( m_jniGamePtr, xpKey, goingUp, barr ) ) {
handled = barr[0] || handled;
draw = true;
}
m_keyDown = !goingUp;
if ( goingUp && !handled ) {
int[] order = { DrawCtx.OBJ_SCORE,
DrawCtx.OBJ_BOARD,
DrawCtx.OBJ_TRAY };
int curType = XwJNI.board_getFocusOwner( m_jniGamePtr );
int cur = 0;
if ( DrawCtx.OBJ_NONE != curType ) {
for ( cur = 0; cur < order.length; ++cur ) {
if ( order[cur] == curType ) {
break;
}
}
}
cur += order.length;
switch( xpKey ) {
case XP_CURSOR_KEY_DOWN:
case XP_CURSOR_KEY_RIGHT:
++cur;
break;
case XP_CURSOR_KEY_UP:
case XP_CURSOR_KEY_LEFT:
--cur;
break;
}
cur %= order.length;
draw = XwJNI.board_focusChanged( m_jniGamePtr, order[cur] )
|| draw;
}
}
return draw;
}

View file

@ -144,8 +144,6 @@ public class XwJNI {
public static native boolean board_beginTrade( int gamePtr );
public static native String board_formatRemainingTiles( int gamePtr );
public static native int board_getFocusOwner( int gamePtr );
public static native boolean board_focusChanged( int gamePtr, int typ );
public enum XP_Key {
XP_KEY_NONE,

View file

@ -126,7 +126,7 @@ static XP_Bool board_moveCursor( BoardCtxt* board, XP_Key cursorKey,
XP_Bool preflightOnly, XP_Bool* up );
static XP_Bool invalFocusOwner( BoardCtxt* board );
#else
# define invalFocusOwner(board)
# define invalFocusOwner(board) 0
#endif
#ifdef XWFEATURE_SEARCHLIMIT
static void clearCurHintRect( BoardCtxt* board );
@ -1392,7 +1392,10 @@ trayOnTop( const BoardCtxt* board )
it has non-dived focus. */
return (board->trayVisState != TRAY_HIDDEN)
|| ( (board->focussed == OBJ_TRAY)
&& (board->focusHasDived == XP_FALSE));
#ifdef KEYBOARD_NAV
&& (board->focusHasDived == XP_FALSE)
#endif
);
} /* trayOnTop */
XW_TrayVisState
@ -2572,7 +2575,9 @@ unhideFocus( BoardCtxt* board )
#ifdef KEY_SUPPORT
XP_Bool
board_handleKeyDown( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
board_handleKeyDown( BoardCtxt* XP_UNUSED_KEYBOARD_NAV(board),
XP_Key XP_UNUSED_KEYBOARD_NAV(key),
XP_Bool* XP_UNUSED_KEYBOARD_NAV(pHandled) )
{
XP_Bool draw = XP_FALSE;
#ifdef KEYBOARD_NAV
@ -2819,19 +2824,6 @@ board_focusChanged( BoardCtxt* board, BoardObjectType typ, XP_Bool gained )
return draw;
} /* board_focusChanged */
XP_Bool
board_toggle_arrowDir( BoardCtxt* board )
{
BoardArrow* arrow = &board->selInfo->boardArrow;
if ( arrow->visible ) {
arrow->vert = !arrow->vert;
invalArrowCell( board );
return XP_TRUE;
} else {
return XP_FALSE;
}
} /* board_toggle_cursorDir */
#endif /* KEYBOARD_NAV */
static XP_Bool

View file

@ -130,13 +130,12 @@ XP_Bool board_handlePenUp( BoardCtxt* board, XP_U16 x, XP_U16 y );
#ifdef KEY_SUPPORT
XP_Bool board_handleKey( BoardCtxt* board, XP_Key key, XP_Bool* handled );
# ifdef KEYBOARD_NAV
XP_Bool board_handleKeyUp( BoardCtxt* board, XP_Key key, XP_Bool* handled );
XP_Bool board_handleKeyDown( BoardCtxt* board, XP_Key key, XP_Bool* handled );
XP_Bool board_handleKeyRepeat( BoardCtxt* board, XP_Key key, XP_Bool* handled );
# ifdef KEYBOARD_NAV
XP_Bool board_focusChanged( BoardCtxt* board, BoardObjectType typ,
XP_Bool gained );
XP_Bool board_toggle_arrowDir( BoardCtxt* board );
# endif
#endif

View file

@ -73,7 +73,9 @@ static XP_Bool drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row,
XP_Bool skipBlanks );
static void drawBoard( BoardCtxt* board );
static void scrollIfCan( BoardCtxt* board );
#ifdef KEYBOARD_NAV
static XP_Bool cellFocused( const BoardCtxt* board, XP_U16 col, XP_U16 row );
#endif
static void drawTradeWindowIf( BoardCtxt* board );
@ -551,7 +553,7 @@ scrollIfCan( BoardCtxt* board )
XP_Bool scrolled;
XP_S16 dist;
#ifdef PERIMETER_FOCUS
#if defined KEYBOARD_NAV && defined PERIMETER_FOCUS
if ( (board->focussed == OBJ_BOARD)
&& !board->focusHasDived
&& !board->hideFocus ) {

View file

@ -76,13 +76,13 @@ drawScoreBoard( BoardCtxt* board )
DrawScoreData datum[MAX_NUM_PLAYERS];
ScoresArray scores;
XP_Bool isVertical = !board->scoreSplitHor;
XP_Bool skipCurTurn; /* skip the guy whose turn it is this pass? */
XP_Bool remFocussed = XP_FALSE;
XP_Bool focusAll = XP_FALSE;
#ifdef KEYBOARD_NAV
XP_Rect cursorRect;
XP_Rect* cursorRectP = NULL;
XP_Bool focusAll = XP_FALSE;
XP_Bool remFocussed = XP_FALSE;
XP_S16 cursorIndex = -1;
XP_Bool skipCurTurn; /* skip the guy whose turn it is this pass? */
if ( (board->focussed == OBJ_SCORE) && !board->hideFocus ) {
focusAll = !board->focusHasDived;
@ -203,9 +203,9 @@ drawScoreBoard( BoardCtxt* board )
centerIn( &innerRect, &scoreRect, remWidth, remHeight );
draw_drawRemText( board->draw, &innerRect, &scoreRect,
nTilesInPool, focusAll || remFocussed );
board->remRect = scoreRect;
*adjustPt += remDim;
#ifdef KEYBOARD_NAV
board->remRect = scoreRect;
/* Hack: don't let the cursor disappear if Rem: goes
away */
} else if ( board->scoreCursorLoc == CURSOR_LOC_REM ) {

View file

@ -96,14 +96,15 @@ typedef struct MenuList {
static XP_Bool handleQuit( CursesAppGlobals* globals );
static XP_Bool handleResend( CursesAppGlobals* globals );
static XP_Bool handleRight( CursesAppGlobals* globals );
static XP_Bool handleSpace( CursesAppGlobals* globals );
static XP_Bool handleRet( CursesAppGlobals* globals );
static XP_Bool handleHint( CursesAppGlobals* globals );
#ifdef KEYBOARD_NAV
static XP_Bool handleLeft( CursesAppGlobals* globals );
static XP_Bool handleRight( CursesAppGlobals* globals );
static XP_Bool handleUp( CursesAppGlobals* globals );
static XP_Bool handleDown( CursesAppGlobals* globals );
#endif
static XP_Bool handleCommit( CursesAppGlobals* globals );
static XP_Bool handleFlip( CursesAppGlobals* globals );
static XP_Bool handleToggleValues( CursesAppGlobals* globals );
@ -125,7 +126,6 @@ static XP_Bool handleRootKeyHide( CursesAppGlobals* globals );
const MenuList g_sharedMenuList[] = {
{ handleQuit, "Quit", "Q", 'Q' },
{ handleResend, "Resend", "R", 'R' },
{ handleRight, "Tab right", "<tab>", '\t' },
{ handleSpace, "Raise focus", "<spc>", ' ' },
{ handleRet, "Click/tap", "<ret>", '\r' },
{ handleHint, "Hint", "?", '?' },
@ -186,6 +186,7 @@ const MenuList g_rootMenuListHide[] = {
static CursesAppGlobals g_globals; /* must be global b/c of SIGWINCH_handler */
#ifdef KEYBOARD_NAV
static void changeMenuForFocus( CursesAppGlobals* globals,
BoardObjectType obj );
static XP_Bool handleLeft( CursesAppGlobals* globals );
@ -193,6 +194,9 @@ static XP_Bool handleRight( CursesAppGlobals* globals );
static XP_Bool handleUp( CursesAppGlobals* globals );
static XP_Bool handleDown( CursesAppGlobals* globals );
static XP_Bool handleFocusKey( CursesAppGlobals* globals, XP_Key key );
#else
# define handleFocusKey( g, k ) XP_FALSE
#endif
static void countMenuLines( const MenuList** menuLists, int maxX, int padding,
int* nLinesP, int* nColsP );
static void drawMenuFromList( WINDOW* win, const MenuList** menuLists,
@ -500,6 +504,7 @@ handleResend( CursesAppGlobals* globals )
return XP_TRUE;
}
#ifdef KEYBOARD_NAV
static void
checkAssignFocus( BoardCtxt* board )
{
@ -507,6 +512,9 @@ checkAssignFocus( BoardCtxt* board )
board_focusChanged( board, OBJ_BOARD, XP_TRUE );
}
}
#else
# define checkAssignFocus(b)
#endif
static XP_Bool
handleSpace( CursesAppGlobals* globals )
@ -634,25 +642,25 @@ handleRootKeyHide( CursesAppGlobals* globals )
#endif
static XP_Bool
handleAltLeft( CursesAppGlobals* globals )
handleAltLeft( CursesAppGlobals* XP_UNUSED_KEYBOARD_NAV(globals) )
{
return handleFocusKey( globals, XP_CURSOR_KEY_ALTLEFT );
}
static XP_Bool
handleAltRight( CursesAppGlobals* globals )
handleAltRight( CursesAppGlobals* XP_UNUSED_KEYBOARD_NAV(globals) )
{
return handleFocusKey( globals, XP_CURSOR_KEY_ALTRIGHT );
}
static XP_Bool
handleAltUp( CursesAppGlobals* globals )
handleAltUp( CursesAppGlobals* XP_UNUSED_KEYBOARD_NAV(globals) )
{
return handleFocusKey( globals, XP_CURSOR_KEY_ALTUP );
}
static XP_Bool
handleAltDown( CursesAppGlobals* globals )
handleAltDown( CursesAppGlobals* XP_UNUSED_KEYBOARD_NAV(globals) )
{
return handleFocusKey( globals, XP_CURSOR_KEY_ALTDOWN );
}
@ -715,7 +723,7 @@ handleFocusKey( CursesAppGlobals* globals, XP_Key key )
globals->doDraw = draw || globals->doDraw;
return XP_TRUE;
}
} /* handleFocusKey */
static XP_Bool
handleLeft( CursesAppGlobals* globals )
@ -1180,10 +1188,10 @@ drawMenuLargeOrSmall( CursesAppGlobals* globals, const MenuList* menuList )
wrefresh( globals->menuWin );
}
#ifdef KEYBOARD_NAV
static void
changeMenuForFocus( CursesAppGlobals* globals, BoardObjectType focussed )
{
#ifdef KEYBOARD_NAV
if ( focussed == OBJ_TRAY ) {
globals->menuList = g_trayMenuList;
} else if ( focussed == OBJ_BOARD ) {
@ -1194,8 +1202,8 @@ changeMenuForFocus( CursesAppGlobals* globals, BoardObjectType focussed )
XP_ASSERT(0);
}
drawMenuLargeOrSmall( globals, globals->menuList );
#endif
} /* changeMenuForFocus */
#endif
#if 0
static void

View file

@ -281,9 +281,12 @@ key_release_event( GtkWidget* XP_UNUSED(widget), GdkEventKey* event,
}
/* XP_ASSERT( globals->keyDown ); */
#ifdef KEYBOARD_NAV
globals->keyDown = XP_FALSE;
#endif
return handled? 1 : 0; /* gtk will do something with the key if 0 returned */
return handled? 1 : 0; /* gtk will do something with the key if 0
returned */
} /* key_release_event */
#endif