@@ -26,7 +26,7 @@ extern volatile int conn_fd; // The only variable from shared with X server code
26
26
27
27
static struct {
28
28
jclass self ;
29
- jmethodID getInstance , clientConnectedStateChanged ;
29
+ jmethodID getInstance , clientConnectedStateChanged , resetIme ;
30
30
} MainActivity = {0 };
31
31
32
32
static struct {
@@ -115,6 +115,7 @@ static void nativeInit(JNIEnv *env, jobject thiz) {
115
115
MainActivity .self = FindClassOrDie (env , "com/termux/x11/MainActivity" );
116
116
MainActivity .getInstance = FindMethodOrDie (env , MainActivity .self , "getInstance" , "()Lcom/termux/x11/MainActivity;" , JNI_TRUE );
117
117
MainActivity .clientConnectedStateChanged = FindMethodOrDie (env , MainActivity .self , "clientConnectedStateChanged" , "()V" , JNI_FALSE );
118
+ MainActivity .resetIme = FindMethodOrDie (env , (* env )-> GetObjectClass (env , thiz ), "resetIme" , "()V" , JNI_FALSE );
118
119
}
119
120
120
121
(* env )-> GetJavaVM (env , & vm );
@@ -205,6 +206,9 @@ static int xcallback(int fd, int events, __unused void* data) {
205
206
#endif
206
207
LorieBuffer_release (buffer );
207
208
}
209
+ case EVENT_WINDOW_FOCUS_CHANGED : {
210
+ (* env )-> CallVoidMethod (env , thiz , MainActivity .resetIme );
211
+ }
208
212
}
209
213
}
210
214
@@ -290,6 +294,8 @@ static void sendWindowChange(__unused JNIEnv* env, __unused jobject cls, jint wi
290
294
291
295
static void sendMouseEvent (__unused JNIEnv * env , __unused jobject cls , jfloat x , jfloat y , jint which_button , jboolean button_down , jboolean relative ) {
292
296
if (conn_fd != -1 ) {
297
+ if (which_button > 0 )
298
+ (* env )-> CallVoidMethod (env , globalThiz , MainActivity .resetIme );
293
299
lorieEvent e = { .mouse = { .t = EVENT_MOUSE , .x = x , .y = y , .detail = which_button , .down = button_down , .relative = relative } };
294
300
write (conn_fd , & e , sizeof (e ));
295
301
}
@@ -306,6 +312,7 @@ static void sendStylusEvent(__unused JNIEnv *env, __unused jobject thiz, jfloat
306
312
jint pressure , jint tilt_x , jint tilt_y ,
307
313
jint orientation , jint buttons , jboolean eraser , jboolean mouse ) {
308
314
if (conn_fd != -1 ) {
315
+ (* env )-> CallVoidMethod (env , globalThiz , MainActivity .resetIme );
309
316
lorieEvent e = { .stylus = { .t = EVENT_STYLUS , .x = x , .y = y , .pressure = pressure , .tilt_x = tilt_x , .tilt_y = tilt_y , .orientation = orientation , .buttons = buttons , .eraser = eraser , .mouse = mouse } };
310
317
write (conn_fd , & e , sizeof (e ));
311
318
}
@@ -358,7 +365,7 @@ static void sendTextEvent(JNIEnv *env, __unused jobject thiz, jbyteArray text) {
358
365
p += len ;
359
366
if (p - (char * ) str >= length )
360
367
break ;
361
- usleep (30000 );
368
+ usleep (2500 );
362
369
}
363
370
364
371
(* env )-> ReleaseByteArrayElements (env , text , str , JNI_ABORT );
@@ -396,7 +403,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
396
403
{"sendTouchEvent" , "(IIII)V" , (void * )& sendTouchEvent },
397
404
{"sendStylusEvent" , "(FFIIIIIZZ)V" , (void * )& sendStylusEvent },
398
405
{"requestStylusEnabled" , "(Z)V" , (void * )& requestStylusEnabled },
399
- {"sendKeyEvent" , "(IIZ )Z" , (void * )& sendKeyEvent },
406
+ {"sendKeyEvent" , "(IIZI )Z" , (void * )& sendKeyEvent },
400
407
{"sendTextEvent" , "([B)V" , (void * )& sendTextEvent },
401
408
{"requestConnection" , "()V" , (void * )& requestConnection },
402
409
};
0 commit comments