[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android 6c3369abe5d 2/3: Make it easier to quit on Android
From: |
Po Lu |
Subject: |
feature/android 6c3369abe5d 2/3: Make it easier to quit on Android |
Date: |
Mon, 1 May 2023 02:17:23 -0400 (EDT) |
branch: feature/android
commit 6c3369abe5de22a86645793fb6be00b234d4cc87
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Make it easier to quit on Android
* src/android.c (android_write_event):
(JNICALL): Raise SIGIO on key press and window action events.
---
src/android.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/android.c b/src/android.c
index 0244113285b..129ad6b5767 100644
--- a/src/android.c
+++ b/src/android.c
@@ -669,9 +669,23 @@ android_write_event (union android_event *event)
pthread_cond_broadcast (&event_queue.read_var);
pthread_mutex_unlock (&event_queue.mutex);
- /* Now set pending_signals to true. This allows C-g to be handled
- immediately even without SIGIO. */
+ /* Now set pending_signals to true, and raise SIGIO to interrupt any
+ ongoing reads if the event is important. */
pending_signals = true;
+
+ switch (event->type)
+ {
+ /* Key press and window action events are considered important,
+ as they either end up quitting or asking for responses to the
+ IME. */
+ case ANDROID_KEY_PRESS:
+ case ANDROID_WINDOW_ACTION:
+ raise (SIGIO);
+ break;
+
+ default:
+ break;
+ }
}
int
@@ -2480,7 +2494,10 @@ NATIVE_NAME (quit) (JNIEnv *env, jobject object)
{
JNI_STACK_ALIGNMENT_PROLOGUE;
+ /* Raise sigio to interrupt anything that could be reading
+ input. */
Vquit_flag = Qt;
+ raise (SIGIO);
}
JNIEXPORT jlong JNICALL