aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-07-08 04:35:04 +0200
committerSven Gothel <[email protected]>2019-07-08 04:35:04 +0200
commit7fc01d666ae35bd789232b18f8d3f2df7146e4d3 (patch)
treecf4c208114cd9066af340da0f3932b58e66d5af8 /src/newt/native
parentf006cb6a0794c0d4fdfc59ded579fc3d91551d0b (diff)
NEWT WindowImpl.doPointerEvent: Use native short[] for pNames
and not int[], this avoid copying in case given pNames are normalized. This is benecifical for X11, Windows and the upcoming iOS touch/pointer support.
Diffstat (limited to 'src/newt/native')
-rw-r--r--src/newt/native/WindowsWindow.c14
-rw-r--r--src/newt/native/X11Display.c12
2 files changed, 13 insertions, 13 deletions
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 59e054516..2571a3e63 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -906,12 +906,12 @@ static BOOL SafeShowCursor(BOOL show) {
static void sendTouchScreenEvent(JNIEnv *env, jobject window,
short eventType, int modifiers, int actionIdx,
- int count, jint* pointerNames, jint* x, jint* y, jfloat* pressure, float maxPressure) {
- jintArray jNames = (*env)->NewIntArray(env, count);
+ int count, jshort* pointerNames, jint* x, jint* y, jfloat* pressure, float maxPressure) {
+ jshortArray jNames = (*env)->NewShortArray(env, count);
if (jNames == NULL) {
- NewtCommon_throwNewRuntimeException(env, "Could not allocate int array (names) of size %d", count);
+ NewtCommon_throwNewRuntimeException(env, "Could not allocate short array (names) of size %d", count);
}
- (*env)->SetIntArrayRegion(env, jNames, 0, count, pointerNames);
+ (*env)->SetShortArrayRegion(env, jNames, 0, count, pointerNames);
jintArray jX = (*env)->NewIntArray(env, count);
if (jX == NULL) {
@@ -1495,7 +1495,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
short eventType[cInputs];
jint modifiers = GetModifiers( 0 );
jint actionIdx = -1;
- jint pointerNames[cInputs];
+ jshort pointerNames[cInputs];
jint x[cInputs], y[cInputs];
jfloat pressure[cInputs];
jfloat maxPressure = 1.0F; // FIXME: n/a on windows ?
@@ -1525,7 +1525,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
}
#endif
- pointerNames[i] = (jint)pTi->dwID;
+ pointerNames[i] = (jshort)pTi->dwID;
eventPt.x = TOUCH_COORD_TO_PIXEL(pTi->x);
eventPt.y = TOUCH_COORD_TO_PIXEL(pTi->y);
ScreenToClient(wnd, &eventPt);
@@ -2132,7 +2132,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z");
windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V");
sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V");
- sendTouchScreenEventID = (*env)->GetMethodID(env, clazz, "sendTouchScreenEvent", "(SII[I[I[I[FF)V");
+ sendTouchScreenEventID = (*env)->GetMethodID(env, clazz, "sendTouchScreenEvent", "(SII[S[I[I[FF)V");
sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V");
requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V");
diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c
index 7c6741839..b16734e62 100644
--- a/src/newt/native/X11Display.c
+++ b/src/newt/native/X11Display.c
@@ -267,7 +267,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0
sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(SIIISF)V");
sendMouseEventRequestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEventRequestFocus", "(SIIISF)V");
visibleChangedSendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "visibleChangedSendMouseEvent", "(ZISIIISF)V");
- sendTouchScreenEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendTouchScreenEvent", "(SII[I[I[I[FF)V");
+ sendTouchScreenEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendTouchScreenEvent", "(SII[S[I[I[FF)V");
sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(SISSCLjava/lang/String;)V");
if (displayCompletedID == NULL ||
@@ -395,7 +395,7 @@ static void sendTouchScreenEvent(JNIEnv *env, JavaWindow *jw,
int modifiers, // 0!
int actionId) // index of multiple-pointer arrays representing the pointer which triggered the event
{
- jint pointerNames[XI_TOUCHCOORD_COUNT];
+ jshort pointerNames[XI_TOUCHCOORD_COUNT];
jint x[XI_TOUCHCOORD_COUNT];
jint y[XI_TOUCHCOORD_COUNT];
jfloat pressure[] = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};
@@ -406,7 +406,7 @@ static void sendTouchScreenEvent(JNIEnv *env, JavaWindow *jw,
if( -1 != jw->xiTouchCoords[i].id ) {
x[cnt] = jw->xiTouchCoords[i].x;
y[cnt] = jw->xiTouchCoords[i].y;
- pointerNames[cnt] = jw->xiTouchCoords[i].id;
+ pointerNames[cnt] = (jshort)jw->xiTouchCoords[i].id;
if (jw->xiTouchCoords[i].id == actionId) {
actionIdx = cnt;
}
@@ -420,11 +420,11 @@ static void sendTouchScreenEvent(JNIEnv *env, JavaWindow *jw,
DBG_PRINT( "X11: XI event - sendTouchScreenEvent: Window %p, action-touchid[%d] %d of %d ptr: %d/%d\n",
(void*)jw->window, actionIdx, actionId, cnt, x[actionIdx], y[actionIdx]);
- jintArray jNames = (*env)->NewIntArray(env, cnt);
+ jshortArray jNames = (*env)->NewShortArray(env, cnt);
if (jNames == NULL) {
- NewtCommon_throwNewRuntimeException(env, "Could not allocate int array (names) of size %d", cnt);
+ NewtCommon_throwNewRuntimeException(env, "Could not allocate short array (names) of size %d", cnt);
}
- (*env)->SetIntArrayRegion(env, jNames, 0, cnt, pointerNames);
+ (*env)->SetShortArrayRegion(env, jNames, 0, cnt, pointerNames);
jintArray jX = (*env)->NewIntArray(env, cnt);
if (jX == NULL) {