diff options
| author | Po Lu | 2024-03-02 14:04:56 +0800 |
|---|---|---|
| committer | Po Lu | 2024-03-02 14:04:56 +0800 |
| commit | 5e20b114ef32d504f4429fd35ecd0d5dcf3bd8db (patch) | |
| tree | 83215f4df69308e61c490172f4a68ff0fea63452 /src/androidterm.c | |
| parent | 8b96503b6e8514f1f9f92895a0707c78b1bbd1fd (diff) | |
| download | emacs-5e20b114ef32d504f4429fd35ecd0d5dcf3bd8db.tar.gz emacs-5e20b114ef32d504f4429fd35ecd0d5dcf3bd8db.zip | |
Implement dead key combination on Android
* src/android.c (android_init_key_character_map)
(android_get_dead_char): New functions.
(android_wc_lookup_string): New argument COMPOSE_STATE. Ignore
key events with the COMBINING_ACCENT flag set while recording
their character values there, and combine such characters with
the key event when processing a subsequent key event.
* src/androidgui.h (struct android_compose_status): New
structure.
* src/androidterm.c (handle_one_android_event): Port dead key
combination code from X. (bug#69321)
Diffstat (limited to 'src/androidterm.c')
| -rw-r--r-- | src/androidterm.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/androidterm.c b/src/androidterm.c index 2bd2b45743d..baf26abe322 100644 --- a/src/androidterm.c +++ b/src/androidterm.c | |||
| @@ -811,6 +811,7 @@ handle_one_android_event (struct android_display_info *dpyinfo, | |||
| 811 | int keysym; | 811 | int keysym; |
| 812 | ptrdiff_t nchars, i; | 812 | ptrdiff_t nchars, i; |
| 813 | struct window *w; | 813 | struct window *w; |
| 814 | static struct android_compose_status compose_status; | ||
| 814 | 815 | ||
| 815 | /* It is okay for this to not resemble handle_one_xevent so much. | 816 | /* It is okay for this to not resemble handle_one_xevent so much. |
| 816 | Differences in event handling code are much less nasty than | 817 | Differences in event handling code are much less nasty than |
| @@ -947,6 +948,14 @@ handle_one_android_event (struct android_display_info *dpyinfo, | |||
| 947 | extra_keyboard_modifiers); | 948 | extra_keyboard_modifiers); |
| 948 | modifiers = event->xkey.state; | 949 | modifiers = event->xkey.state; |
| 949 | 950 | ||
| 951 | /* In case Meta is ComposeCharacter, clear its status. According | ||
| 952 | to Markus Ehrnsperger | ||
| 953 | Markus.Ehrnsperger@lehrstuhl-bross.physik.uni-muenchen.de this | ||
| 954 | enables ComposeCharacter to work whether or not it is combined | ||
| 955 | with Meta. */ | ||
| 956 | if (modifiers & ANDROID_ALT_MASK) | ||
| 957 | memset (&compose_status, 0, sizeof (compose_status)); | ||
| 958 | |||
| 950 | /* Common for all keysym input events. */ | 959 | /* Common for all keysym input events. */ |
| 951 | XSETFRAME (inev.ie.frame_or_window, any); | 960 | XSETFRAME (inev.ie.frame_or_window, any); |
| 952 | inev.ie.modifiers | 961 | inev.ie.modifiers |
| @@ -960,7 +969,8 @@ handle_one_android_event (struct android_display_info *dpyinfo, | |||
| 960 | 969 | ||
| 961 | nchars = android_wc_lookup_string (&event->xkey, copy_bufptr, | 970 | nchars = android_wc_lookup_string (&event->xkey, copy_bufptr, |
| 962 | copy_bufsiz, &keysym, | 971 | copy_bufsiz, &keysym, |
| 963 | &status_return); | 972 | &status_return, |
| 973 | &compose_status); | ||
| 964 | 974 | ||
| 965 | /* android_lookup_string can't be called twice, so there's no | 975 | /* android_lookup_string can't be called twice, so there's no |
| 966 | way to recover from buffer overflow. */ | 976 | way to recover from buffer overflow. */ |
| @@ -1000,6 +1010,13 @@ handle_one_android_event (struct android_display_info *dpyinfo, | |||
| 1000 | } | 1010 | } |
| 1001 | } | 1011 | } |
| 1002 | 1012 | ||
| 1013 | /* If a compose sequence is in progress, we break here. | ||
| 1014 | Otherwise, chars_matched is always 0. */ | ||
| 1015 | if (compose_status.chars_matched > 0 && nchars == 0) | ||
| 1016 | break; | ||
| 1017 | |||
| 1018 | memset (&compose_status, 0, sizeof (compose_status)); | ||
| 1019 | |||
| 1003 | if (nchars == 1 && copy_bufptr[0] >= 32) | 1020 | if (nchars == 1 && copy_bufptr[0] >= 32) |
| 1004 | { | 1021 | { |
| 1005 | /* Deal with characters. */ | 1022 | /* Deal with characters. */ |