public DisplayMetrics metrics;
/* Flag that says whether or not to print verbose debugging
- information. */
+ information when responding to an input method. */
public static final boolean DEBUG_IC = false;
- /* Flag that says whether or not to perform extra checks on threads
- performing drawing calls. */
+ /* Flag that says whether or not to stringently check that only the
+ Emacs thread is performing drawing calls. */
private static final boolean DEBUG_THREADS = false;
/* Atomic integer used for synchronization between
}
}
+\f
+
+/* Forward declaration. */
+static void android_notify_conversion (unsigned long);
+
static int
handle_one_android_event (struct android_display_info *dpyinfo,
union android_event *event, int *finish,
case ANDROID_INPUT_METHOD:
if (!any)
- /* Free any text allocated for this event. */
- xfree (event->ime.text);
+ {
+ /* Free any text allocated for this event. */
+ xfree (event->ime.text);
+
+ /* If edits associated with this event haven't been
+ processed yet, signal their completion to avoid delays
+ the next time a call to `android_sync_edit' is made.
+
+ If events for a deleted frame are interleaved with events
+ for another frame, the edit counter may be prematurely
+ incremented before edits associated with the other frames
+ are processed. This is not a problem in practice. */
+
+ android_notify_conversion (event->ime.counter);
+ }
else
android_handle_ime_event (event, any);
android_sync_edit (void)
{
struct timespec start, end, rem;
+ unsigned long counter;
+
+ counter = __atomic_load_n (&last_edit_counter,
+ __ATOMIC_SEQ_CST);
- if (__atomic_load_n (&last_edit_counter,
- __ATOMIC_SEQ_CST)
- == edit_counter)
+ if (counter == edit_counter)
return;
start = current_timespec ();
event.ime.length = mode;
event.ime.position = 0;
event.ime.text = NULL;
- event.ime.counter = ++edit_counter;
+
+ /* Since this does not affect the state of the buffer text, there is
+ no need to apply synchronization to this event. */
+ event.ime.counter = 0;
android_write_event (&event);
}