From 3b24aab8c3f103b267e16b8aa4c02240f09a7bdf Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 15 Aug 2016 17:26:10 -0700 Subject: [PATCH] add new jni call board_containsPt() for use debugging layouts/orientation changes later --- xwords4/android/XWords4/jni/xwjni.c | 13 +++++++++++++ .../src/org/eehouse/android/xw4/BoardView.java | 7 ++++++- .../src/org/eehouse/android/xw4/jni/XwJNI.java | 2 ++ xwords4/common/board.c | 11 ++++++++++- xwords4/common/board.h | 1 + xwords4/common/boardp.h | 2 +- 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 07e958b48..7037383ad 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1119,6 +1119,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1getActiveRect } #endif +#ifdef POINTER_SUPPORT JNIEXPORT jboolean JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenDown (JNIEnv *env, jclass C, GamePtrType gamePtr, jint xx, jint yy, jbooleanArray barray ) @@ -1153,6 +1154,18 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenUp return result; } +JNIEXPORT jboolean JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_board_1containsPt +( JNIEnv* env, jclass C, GamePtrType gamePtr, jint xx, jint yy ) +{ + jboolean result; + XWJNI_START(); + result = board_containsPt( state->game.board, xx, yy ); + XWJNI_END(); + return result; +} +#endif + JNIEXPORT jboolean JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_board_1juggleTray (JNIEnv* env, jclass C, GamePtrType gamePtr ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index fec605dcd..7e7c429a5 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -102,12 +102,17 @@ public class BoardView extends View implements BoardHandler, SyncedDraw { switch ( action ) { case MotionEvent.ACTION_DOWN: m_lastSpacing = MULTI_INACTIVE; - if ( !ConnStatusHandler.handleDown( xx, yy ) ) { + if ( ConnStatusHandler.handleDown( xx, yy ) ) { + // do nothing + } else if ( XwJNI.board_containsPt( m_jniGamePtr, xx, yy ) ) { handle( JNIThread.JNICmd.CMD_PEN_DOWN, xx, yy ); + } else { + DbgUtils.logdf( "onTouchEvent(): in white space" ); } break; case MotionEvent.ACTION_MOVE: if ( ConnStatusHandler.handleMove( xx, yy ) ) { + // do nothing } else if ( MULTI_INACTIVE == m_lastSpacing ) { handle( JNIThread.JNICmd.CMD_PEN_MOVE, xx, yy ); } else { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java index 36c5021ea..bccfb4e7e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java @@ -289,6 +289,8 @@ public class XwJNI { int xx, int yy ); public static native boolean board_handlePenUp( GamePtr gamePtr, int xx, int yy ); + public static native boolean board_containsPt( GamePtr gamePtr, + int xx, int yy ); public static native boolean board_juggleTray( GamePtr gamePtr ); public static native int board_getTrayVisState( GamePtr gamePtr ); diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 7992160ca..cbb659f0b 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -2378,7 +2378,8 @@ invalCell( BoardCtxt* board, XP_U16 col, XP_U16 row ) #if defined POINTER_SUPPORT || defined KEYBOARD_NAV XP_Bool -pointOnSomething( BoardCtxt* board, XP_U16 xx, XP_U16 yy, BoardObjectType* wp ) +pointOnSomething( const BoardCtxt* board, XP_U16 xx, XP_U16 yy, + BoardObjectType* wp ) { XP_Bool result = XP_TRUE; @@ -2950,6 +2951,14 @@ board_handlePenUp( BoardCtxt* board, XP_U16 x, XP_U16 y ) { return handlePenUpInternal( board, x, y, XP_TRUE ); } + +XP_Bool +board_containsPt( const BoardCtxt* board, XP_U16 xx, XP_U16 yy ) +{ + BoardObjectType wp; + return pointOnSomething( board, xx, yy, &wp ); +} + #endif /* #ifdef POINTER_SUPPORT */ #ifdef KEYBOARD_NAV diff --git a/xwords4/common/board.h b/xwords4/common/board.h index e65b0c7c9..01cafa741 100644 --- a/xwords4/common/board.h +++ b/xwords4/common/board.h @@ -183,6 +183,7 @@ XP_Bool board_handlePenDown( BoardCtxt* board, XP_U16 x, XP_U16 y, XP_Bool* handled ); XP_Bool board_handlePenMove( BoardCtxt* board, XP_U16 x, XP_U16 y ); XP_Bool board_handlePenUp( BoardCtxt* board, XP_U16 x, XP_U16 y ); +XP_Bool board_containsPt( const BoardCtxt* board, XP_U16 xx, XP_U16 yy ); #endif #ifdef KEY_SUPPORT diff --git a/xwords4/common/boardp.h b/xwords4/common/boardp.h index ede2dc4d2..3de5852ac 100644 --- a/xwords4/common/boardp.h +++ b/xwords4/common/boardp.h @@ -257,7 +257,7 @@ XP_S16 pointToTileIndex( BoardCtxt* board, XP_U16 x, XP_U16 y, void board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer, XP_Bool canPeek ); void flipIf( const BoardCtxt* board, XP_U16 col, XP_U16 row, XP_U16* fCol, XP_U16* fRow ); -XP_Bool pointOnSomething( BoardCtxt* board, XP_U16 x, XP_U16 y, +XP_Bool pointOnSomething( const BoardCtxt* board, XP_U16 xx, XP_U16 yy, BoardObjectType* wp ); XP_Bool coordToCell( const BoardCtxt* board, XP_S16 xx, XP_S16 yy, XP_U16* colP, XP_U16* rowP );