diff options
| author | Po Lu | 2023-03-12 19:36:09 +0800 |
|---|---|---|
| committer | Po Lu | 2023-03-12 19:36:09 +0800 |
| commit | 776f1ca3e3551b98569ab7daa58cd6921048881e (patch) | |
| tree | 641b5e5790ebffc1f9caf313caee4a0443d5e92e /src/androidterm.c | |
| parent | 82b4b9e8692c349a45d319fe05c9fbfed4ab203d (diff) | |
| download | emacs-776f1ca3e3551b98569ab7daa58cd6921048881e.tar.gz emacs-776f1ca3e3551b98569ab7daa58cd6921048881e.zip | |
Update Android port
* src/android.c (android_check_if_event):
* src/androidgui.h: New function.
* src/androidterm.c (android_event_is_for_frame): New function.
(android_reset_conversion): Free and unqueue all text conversion
events for the given frame.
Diffstat (limited to 'src/androidterm.c')
| -rw-r--r-- | src/androidterm.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/androidterm.c b/src/androidterm.c index ed375ef53fe..72d81744128 100644 --- a/src/androidterm.c +++ b/src/androidterm.c | |||
| @@ -5474,6 +5474,19 @@ android_update_selection (struct frame *f, struct window *w) | |||
| 5474 | } | 5474 | } |
| 5475 | } | 5475 | } |
| 5476 | 5476 | ||
| 5477 | /* Return whether or not EVENT is an input method event destined for | ||
| 5478 | the frame (struct frame *) ARG. */ | ||
| 5479 | |||
| 5480 | static bool | ||
| 5481 | android_event_is_for_frame (union android_event *event, void *arg) | ||
| 5482 | { | ||
| 5483 | struct frame *f; | ||
| 5484 | |||
| 5485 | f = arg; | ||
| 5486 | return (event->type == ANDROID_INPUT_METHOD | ||
| 5487 | && event->ime.window == FRAME_ANDROID_WINDOW (f)); | ||
| 5488 | } | ||
| 5489 | |||
| 5477 | /* Notice that the input method connection to F should be reset as a | 5490 | /* Notice that the input method connection to F should be reset as a |
| 5478 | result of a change to its contents. */ | 5491 | result of a change to its contents. */ |
| 5479 | 5492 | ||
| @@ -5484,6 +5497,7 @@ android_reset_conversion (struct frame *f) | |||
| 5484 | struct window *w; | 5497 | struct window *w; |
| 5485 | struct buffer *buffer; | 5498 | struct buffer *buffer; |
| 5486 | Lisp_Object style; | 5499 | Lisp_Object style; |
| 5500 | union android_event event; | ||
| 5487 | 5501 | ||
| 5488 | /* Reset the input method. | 5502 | /* Reset the input method. |
| 5489 | 5503 | ||
| @@ -5507,6 +5521,27 @@ android_reset_conversion (struct frame *f) | |||
| 5507 | else | 5521 | else |
| 5508 | mode = ANDROID_IC_MODE_TEXT; | 5522 | mode = ANDROID_IC_MODE_TEXT; |
| 5509 | 5523 | ||
| 5524 | /* Remove any existing input method events that apply to FRAME from | ||
| 5525 | the event queue. | ||
| 5526 | |||
| 5527 | There's a small window between this and the call to | ||
| 5528 | android_reset_ic between which more events can be generated. */ | ||
| 5529 | |||
| 5530 | while (android_check_if_event (&event, android_event_is_for_frame, f)) | ||
| 5531 | { | ||
| 5532 | switch (event.ime.operation) | ||
| 5533 | { | ||
| 5534 | case ANDROID_IME_COMMIT_TEXT: | ||
| 5535 | case ANDROID_IME_FINISH_COMPOSING_TEXT: | ||
| 5536 | case ANDROID_IME_SET_COMPOSING_TEXT: | ||
| 5537 | xfree (event.ime.text); | ||
| 5538 | break; | ||
| 5539 | |||
| 5540 | default: | ||
| 5541 | break; | ||
| 5542 | } | ||
| 5543 | } | ||
| 5544 | |||
| 5510 | android_reset_ic (FRAME_ANDROID_WINDOW (f), mode); | 5545 | android_reset_ic (FRAME_ANDROID_WINDOW (f), mode); |
| 5511 | 5546 | ||
| 5512 | /* Clear extracted text flags. Since the IM has been reinitialised, | 5547 | /* Clear extracted text flags. Since the IM has been reinitialised, |