diff options
| author | Po Lu | 2023-07-08 10:15:38 +0800 |
|---|---|---|
| committer | Po Lu | 2023-07-08 10:15:38 +0800 |
| commit | c843f3e23b48dcf65e72db0eefa6a5a74c815ff6 (patch) | |
| tree | 28098de9e220b8f1aaa3c7f9f6a8e8b5e8e1250e /src/androidterm.c | |
| parent | da27837d99fe2dd4c3825598b465107550a06a9d (diff) | |
| download | emacs-c843f3e23b48dcf65e72db0eefa6a5a74c815ff6.tar.gz emacs-c843f3e23b48dcf65e72db0eefa6a5a74c815ff6.zip | |
Update Android port
* java/org/gnu/emacs/EmacsService.java (DEBUG_IC)
(DEBUG_THREADS): Improve commentary.
* src/androidterm.c (handle_one_android_event): Signal
completion of IME events that have lost their frames.
(requestCursorUpdates): Don't set an edit counter as this event
won't be passed to the text conversion machinery.
Diffstat (limited to 'src/androidterm.c')
| -rw-r--r-- | src/androidterm.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/androidterm.c b/src/androidterm.c index 20a8860a913..466a99a1e28 100644 --- a/src/androidterm.c +++ b/src/androidterm.c | |||
| @@ -774,6 +774,11 @@ android_handle_ime_event (union android_event *event, struct frame *f) | |||
| 774 | } | 774 | } |
| 775 | } | 775 | } |
| 776 | 776 | ||
| 777 | |||
| 778 | |||
| 779 | /* Forward declaration. */ | ||
| 780 | static void android_notify_conversion (unsigned long); | ||
| 781 | |||
| 777 | static int | 782 | static int |
| 778 | handle_one_android_event (struct android_display_info *dpyinfo, | 783 | handle_one_android_event (struct android_display_info *dpyinfo, |
| 779 | union android_event *event, int *finish, | 784 | union android_event *event, int *finish, |
| @@ -1659,8 +1664,21 @@ handle_one_android_event (struct android_display_info *dpyinfo, | |||
| 1659 | case ANDROID_INPUT_METHOD: | 1664 | case ANDROID_INPUT_METHOD: |
| 1660 | 1665 | ||
| 1661 | if (!any) | 1666 | if (!any) |
| 1662 | /* Free any text allocated for this event. */ | 1667 | { |
| 1663 | xfree (event->ime.text); | 1668 | /* Free any text allocated for this event. */ |
| 1669 | xfree (event->ime.text); | ||
| 1670 | |||
| 1671 | /* If edits associated with this event haven't been | ||
| 1672 | processed yet, signal their completion to avoid delays | ||
| 1673 | the next time a call to `android_sync_edit' is made. | ||
| 1674 | |||
| 1675 | If events for a deleted frame are interleaved with events | ||
| 1676 | for another frame, the edit counter may be prematurely | ||
| 1677 | incremented before edits associated with the other frames | ||
| 1678 | are processed. This is not a problem in practice. */ | ||
| 1679 | |||
| 1680 | android_notify_conversion (event->ime.counter); | ||
| 1681 | } | ||
| 1664 | else | 1682 | else |
| 1665 | android_handle_ime_event (event, any); | 1683 | android_handle_ime_event (event, any); |
| 1666 | 1684 | ||
| @@ -4585,10 +4603,12 @@ static void | |||
| 4585 | android_sync_edit (void) | 4603 | android_sync_edit (void) |
| 4586 | { | 4604 | { |
| 4587 | struct timespec start, end, rem; | 4605 | struct timespec start, end, rem; |
| 4606 | unsigned long counter; | ||
| 4607 | |||
| 4608 | counter = __atomic_load_n (&last_edit_counter, | ||
| 4609 | __ATOMIC_SEQ_CST); | ||
| 4588 | 4610 | ||
| 4589 | if (__atomic_load_n (&last_edit_counter, | 4611 | if (counter == edit_counter) |
| 4590 | __ATOMIC_SEQ_CST) | ||
| 4591 | == edit_counter) | ||
| 4592 | return; | 4612 | return; |
| 4593 | 4613 | ||
| 4594 | start = current_timespec (); | 4614 | start = current_timespec (); |
| @@ -5618,7 +5638,10 @@ NATIVE_NAME (requestCursorUpdates) (JNIEnv *env, jobject object, | |||
| 5618 | event.ime.length = mode; | 5638 | event.ime.length = mode; |
| 5619 | event.ime.position = 0; | 5639 | event.ime.position = 0; |
| 5620 | event.ime.text = NULL; | 5640 | event.ime.text = NULL; |
| 5621 | event.ime.counter = ++edit_counter; | 5641 | |
| 5642 | /* Since this does not affect the state of the buffer text, there is | ||
| 5643 | no need to apply synchronization to this event. */ | ||
| 5644 | event.ime.counter = 0; | ||
| 5622 | 5645 | ||
| 5623 | android_write_event (&event); | 5646 | android_write_event (&event); |
| 5624 | } | 5647 | } |