diff options
| author | Po Lu | 2023-07-18 10:12:40 +0800 |
|---|---|---|
| committer | Po Lu | 2023-07-18 10:12:40 +0800 |
| commit | 5ff31bf36cf00f9d5a378ce139fd5c2ae8d3f25e (patch) | |
| tree | 5f1d6659da915840edcb12ed1931a8c379cedfce /src | |
| parent | 46fd03a49617066fca87000378771caedfd150f3 (diff) | |
| download | emacs-5ff31bf36cf00f9d5a378ce139fd5c2ae8d3f25e.tar.gz emacs-5ff31bf36cf00f9d5a378ce139fd5c2ae8d3f25e.zip | |
Update Android port
* doc/lispref/commands.texi (Touchscreen Events): Describe
treatment of canceled touch sequences during touch event
translation.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Update JNI
prototypes.
* java/org/gnu/emacs/EmacsWindow.java (motionEvent): Set
cancelation flag in events sent where appropriate.
* lisp/touch-screen.el (touch-screen-handle-point-update):
Improve treatment of horizontal scrolling near window edges.
(touch-screen-handle-touch): Don't handle point up if the touch
sequence has been canceled.
* src/android.c (sendTouchDown, sendTouchUp, sendTouchMove): New
argument `flags'.
* src/androidgui.h (enum android_touch_event_flags): New enum.
(struct android_touch_event): New field `flags'.
* src/androidterm.c (handle_one_android_event): Report
cancelation in TOUCHSCREEN_END_EVENTs.
* src/keyboard.c (make_lispy_event): Fix botched merge.
Diffstat (limited to 'src')
| -rw-r--r-- | src/android.c | 12 | ||||
| -rw-r--r-- | src/androidgui.h | 10 | ||||
| -rw-r--r-- | src/androidterm.c | 5 | ||||
| -rw-r--r-- | src/keyboard.c | 103 |
4 files changed, 97 insertions, 33 deletions
diff --git a/src/android.c b/src/android.c index 90288737c77..f2e5e75d35e 100644 --- a/src/android.c +++ b/src/android.c | |||
| @@ -2870,7 +2870,8 @@ NATIVE_NAME (sendButtonRelease) (JNIEnv *env, jobject object, | |||
| 2870 | JNIEXPORT jlong JNICALL | 2870 | JNIEXPORT jlong JNICALL |
| 2871 | NATIVE_NAME (sendTouchDown) (JNIEnv *env, jobject object, | 2871 | NATIVE_NAME (sendTouchDown) (JNIEnv *env, jobject object, |
| 2872 | jshort window, jint x, jint y, | 2872 | jshort window, jint x, jint y, |
| 2873 | jlong time, jint pointer_id) | 2873 | jlong time, jint pointer_id, |
| 2874 | jint flags) | ||
| 2874 | { | 2875 | { |
| 2875 | JNI_STACK_ALIGNMENT_PROLOGUE; | 2876 | JNI_STACK_ALIGNMENT_PROLOGUE; |
| 2876 | 2877 | ||
| @@ -2883,6 +2884,7 @@ NATIVE_NAME (sendTouchDown) (JNIEnv *env, jobject object, | |||
| 2883 | event.touch.y = y; | 2884 | event.touch.y = y; |
| 2884 | event.touch.time = time; | 2885 | event.touch.time = time; |
| 2885 | event.touch.pointer_id = pointer_id; | 2886 | event.touch.pointer_id = pointer_id; |
| 2887 | event.touch.flags = flags; | ||
| 2886 | 2888 | ||
| 2887 | android_write_event (&event); | 2889 | android_write_event (&event); |
| 2888 | return event_serial; | 2890 | return event_serial; |
| @@ -2891,7 +2893,8 @@ NATIVE_NAME (sendTouchDown) (JNIEnv *env, jobject object, | |||
| 2891 | JNIEXPORT jlong JNICALL | 2893 | JNIEXPORT jlong JNICALL |
| 2892 | NATIVE_NAME (sendTouchUp) (JNIEnv *env, jobject object, | 2894 | NATIVE_NAME (sendTouchUp) (JNIEnv *env, jobject object, |
| 2893 | jshort window, jint x, jint y, | 2895 | jshort window, jint x, jint y, |
| 2894 | jlong time, jint pointer_id) | 2896 | jlong time, jint pointer_id, |
| 2897 | jint flags) | ||
| 2895 | { | 2898 | { |
| 2896 | JNI_STACK_ALIGNMENT_PROLOGUE; | 2899 | JNI_STACK_ALIGNMENT_PROLOGUE; |
| 2897 | 2900 | ||
| @@ -2904,6 +2907,7 @@ NATIVE_NAME (sendTouchUp) (JNIEnv *env, jobject object, | |||
| 2904 | event.touch.y = y; | 2907 | event.touch.y = y; |
| 2905 | event.touch.time = time; | 2908 | event.touch.time = time; |
| 2906 | event.touch.pointer_id = pointer_id; | 2909 | event.touch.pointer_id = pointer_id; |
| 2910 | event.touch.flags = flags; | ||
| 2907 | 2911 | ||
| 2908 | android_write_event (&event); | 2912 | android_write_event (&event); |
| 2909 | return event_serial; | 2913 | return event_serial; |
| @@ -2912,7 +2916,8 @@ NATIVE_NAME (sendTouchUp) (JNIEnv *env, jobject object, | |||
| 2912 | JNIEXPORT jlong JNICALL | 2916 | JNIEXPORT jlong JNICALL |
| 2913 | NATIVE_NAME (sendTouchMove) (JNIEnv *env, jobject object, | 2917 | NATIVE_NAME (sendTouchMove) (JNIEnv *env, jobject object, |
| 2914 | jshort window, jint x, jint y, | 2918 | jshort window, jint x, jint y, |
| 2915 | jlong time, jint pointer_id) | 2919 | jlong time, jint pointer_id, |
| 2920 | jint flags) | ||
| 2916 | { | 2921 | { |
| 2917 | JNI_STACK_ALIGNMENT_PROLOGUE; | 2922 | JNI_STACK_ALIGNMENT_PROLOGUE; |
| 2918 | 2923 | ||
| @@ -2925,6 +2930,7 @@ NATIVE_NAME (sendTouchMove) (JNIEnv *env, jobject object, | |||
| 2925 | event.touch.y = y; | 2930 | event.touch.y = y; |
| 2926 | event.touch.time = time; | 2931 | event.touch.time = time; |
| 2927 | event.touch.pointer_id = pointer_id; | 2932 | event.touch.pointer_id = pointer_id; |
| 2933 | event.touch.flags = flags; | ||
| 2928 | 2934 | ||
| 2929 | android_write_event (&event); | 2935 | android_write_event (&event); |
| 2930 | return event_serial; | 2936 | return event_serial; |
diff --git a/src/androidgui.h b/src/androidgui.h index 9e604cdcb8c..265ec29b678 100644 --- a/src/androidgui.h +++ b/src/androidgui.h | |||
| @@ -365,6 +365,13 @@ struct android_expose_event | |||
| 365 | int width, height; | 365 | int width, height; |
| 366 | }; | 366 | }; |
| 367 | 367 | ||
| 368 | enum android_touch_event_flags | ||
| 369 | { | ||
| 370 | /* This touch sequence has been intercepted by the WM (probably | ||
| 371 | for back gesture navigation or some such.) */ | ||
| 372 | ANDROID_TOUCH_SEQUENCE_CANCELED = 1, | ||
| 373 | }; | ||
| 374 | |||
| 368 | struct android_touch_event | 375 | struct android_touch_event |
| 369 | { | 376 | { |
| 370 | /* Type of the event. */ | 377 | /* Type of the event. */ |
| @@ -384,6 +391,9 @@ struct android_touch_event | |||
| 384 | 391 | ||
| 385 | /* Index of the pointer being tracked. */ | 392 | /* Index of the pointer being tracked. */ |
| 386 | unsigned int pointer_id; | 393 | unsigned int pointer_id; |
| 394 | |||
| 395 | /* Flags associated with this event. */ | ||
| 396 | int flags; | ||
| 387 | }; | 397 | }; |
| 388 | 398 | ||
| 389 | struct android_wheel_event | 399 | struct android_wheel_event |
diff --git a/src/androidterm.c b/src/androidterm.c index 27800a61864..bcb6cd6db45 100644 --- a/src/androidterm.c +++ b/src/androidterm.c | |||
| @@ -1511,6 +1511,11 @@ handle_one_android_event (struct android_display_info *dpyinfo, | |||
| 1511 | inev.ie.kind = TOUCHSCREEN_END_EVENT; | 1511 | inev.ie.kind = TOUCHSCREEN_END_EVENT; |
| 1512 | inev.ie.timestamp = event->touch.time; | 1512 | inev.ie.timestamp = event->touch.time; |
| 1513 | 1513 | ||
| 1514 | /* Report whether the sequence has been canceled. */ | ||
| 1515 | |||
| 1516 | if (event->touch.flags & ANDROID_TOUCH_SEQUENCE_CANCELED) | ||
| 1517 | inev.ie.modifiers = 1; | ||
| 1518 | |||
| 1514 | XSETFRAME (inev.ie.frame_or_window, any); | 1519 | XSETFRAME (inev.ie.frame_or_window, any); |
| 1515 | XSETINT (inev.ie.x, event->touch.x); | 1520 | XSETINT (inev.ie.x, event->touch.x); |
| 1516 | XSETINT (inev.ie.y, event->touch.y); | 1521 | XSETINT (inev.ie.y, event->touch.y); |
diff --git a/src/keyboard.c b/src/keyboard.c index bd7433e584a..73c4e3f2593 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -6560,11 +6560,10 @@ make_lispy_event (struct input_event *event) | |||
| 6560 | { | 6560 | { |
| 6561 | Lisp_Object x, y, id, position; | 6561 | Lisp_Object x, y, id, position; |
| 6562 | struct frame *f; | 6562 | struct frame *f; |
| 6563 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 6563 | int tab_bar_item; | 6564 | int tab_bar_item; |
| 6564 | bool close; | 6565 | bool close; |
| 6565 | #if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR | 6566 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 6566 | int column, row, dummy; | ||
| 6567 | #endif /* defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR */ | ||
| 6568 | 6567 | ||
| 6569 | f = XFRAME (event->frame_or_window); | 6568 | f = XFRAME (event->frame_or_window); |
| 6570 | id = event->arg; | 6569 | id = event->arg; |
| @@ -6572,16 +6571,82 @@ make_lispy_event (struct input_event *event) | |||
| 6572 | y = event->y; | 6571 | y = event->y; |
| 6573 | 6572 | ||
| 6574 | #if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR | 6573 | #if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR |
| 6575 | if (event->kind == TOUCHSCREEN_BEGIN_EVENT | 6574 | if (coords_in_menu_bar_window (f, XFIXNUM (x), XFIXNUM (y))) |
| 6576 | && coords_in_menu_bar_window (f, XFIXNUM (x), XFIXNUM (y))) | ||
| 6577 | { | 6575 | { |
| 6578 | /* If the tap began in the menu bar window, then save the | 6576 | /* If the tap began in the menu bar window, then save the |
| 6579 | id. */ | 6577 | id. */ |
| 6580 | menu_bar_touch_id = id; | 6578 | menu_bar_touch_id = id; |
| 6581 | return Qnil; | 6579 | return Qnil; |
| 6582 | } | 6580 | } |
| 6583 | else if (event->kind == TOUCHSCREEN_END_EVENT | 6581 | #endif /* defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR */ |
| 6584 | && EQ (menu_bar_touch_id, id)) | 6582 | |
| 6583 | position = make_lispy_position (f, x, y, event->timestamp); | ||
| 6584 | |||
| 6585 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 6586 | |||
| 6587 | /* Now check if POSITION lies on the tab bar. If so, look up | ||
| 6588 | the corresponding tab bar item's propertized string as the | ||
| 6589 | OBJECT. */ | ||
| 6590 | |||
| 6591 | if (coords_in_tab_bar_window (f, XFIXNUM (event->x), | ||
| 6592 | XFIXNUM (event->y)) | ||
| 6593 | /* `get_tab_bar_item_kbd' returns 0 if the item was | ||
| 6594 | previously highlighted, 1 otherwise, and -1 if there is | ||
| 6595 | no tab bar item. */ | ||
| 6596 | && get_tab_bar_item_kbd (f, XFIXNUM (event->x), | ||
| 6597 | XFIXNUM (event->y), &tab_bar_item, | ||
| 6598 | &close) >= 0) | ||
| 6599 | { | ||
| 6600 | /* First, obtain the propertized string. */ | ||
| 6601 | x = Fcopy_sequence (AREF (f->tab_bar_items, | ||
| 6602 | (tab_bar_item | ||
| 6603 | + TAB_BAR_ITEM_CAPTION))); | ||
| 6604 | |||
| 6605 | /* Next, add the key binding. */ | ||
| 6606 | AUTO_LIST2 (y, Qmenu_item, list3 (AREF (f->tab_bar_items, | ||
| 6607 | (tab_bar_item | ||
| 6608 | + TAB_BAR_ITEM_KEY)), | ||
| 6609 | AREF (f->tab_bar_items, | ||
| 6610 | (tab_bar_item | ||
| 6611 | + TAB_BAR_ITEM_BINDING)), | ||
| 6612 | close ? Qt : Qnil)); | ||
| 6613 | |||
| 6614 | /* And add the new properties to the propertized string. */ | ||
| 6615 | Fadd_text_properties (make_fixnum (0), | ||
| 6616 | make_fixnum (SCHARS (x)), | ||
| 6617 | y, x); | ||
| 6618 | |||
| 6619 | /* Set the position to 0. */ | ||
| 6620 | x = Fcons (x, make_fixnum (0)); | ||
| 6621 | |||
| 6622 | /* Finally, add the OBJECT. */ | ||
| 6623 | position = nconc2 (position, Fcons (x, Qnil)); | ||
| 6624 | } | ||
| 6625 | |||
| 6626 | #endif /* HAVE_WINDOW_SYSTEM */ | ||
| 6627 | |||
| 6628 | return list2 (Qtouchscreen_begin, | ||
| 6629 | Fcons (id, position)); | ||
| 6630 | } | ||
| 6631 | |||
| 6632 | case TOUCHSCREEN_END_EVENT: | ||
| 6633 | { | ||
| 6634 | Lisp_Object x, y, id, position; | ||
| 6635 | struct frame *f = XFRAME (event->frame_or_window); | ||
| 6636 | #if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR | ||
| 6637 | int column, row, dummy; | ||
| 6638 | #endif /* defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR */ | ||
| 6639 | #ifdef HAVE_WINDOW_SYSTEM | ||
| 6640 | int tab_bar_item; | ||
| 6641 | bool close; | ||
| 6642 | #endif /* HAVE_WINDOW_SYSTEM */ | ||
| 6643 | |||
| 6644 | id = event->arg; | ||
| 6645 | x = event->x; | ||
| 6646 | y = event->y; | ||
| 6647 | |||
| 6648 | #if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR | ||
| 6649 | if (EQ (menu_bar_touch_id, id)) | ||
| 6585 | { | 6650 | { |
| 6586 | /* This touch should activate the menu bar. Generate the | 6651 | /* This touch should activate the menu bar. Generate the |
| 6587 | menu bar event. */ | 6652 | menu bar event. */ |
| @@ -6631,8 +6696,6 @@ make_lispy_event (struct input_event *event) | |||
| 6631 | } | 6696 | } |
| 6632 | #endif /* defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR */ | 6697 | #endif /* defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR */ |
| 6633 | 6698 | ||
| 6634 | position = make_lispy_position (f, x, y, event->timestamp); | ||
| 6635 | |||
| 6636 | #ifdef HAVE_WINDOW_SYSTEM | 6699 | #ifdef HAVE_WINDOW_SYSTEM |
| 6637 | 6700 | ||
| 6638 | /* Now check if POSITION lies on the tab bar. If so, look up | 6701 | /* Now check if POSITION lies on the tab bar. If so, look up |
| @@ -6676,29 +6739,9 @@ make_lispy_event (struct input_event *event) | |||
| 6676 | 6739 | ||
| 6677 | #endif /* HAVE_WINDOW_SYSTEM */ | 6740 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 6678 | 6741 | ||
| 6679 | return list2 (((event->kind | ||
| 6680 | == TOUCHSCREEN_BEGIN_EVENT) | ||
| 6681 | ? Qtouchscreen_begin | ||
| 6682 | : Qtouchscreen_end), | ||
| 6683 | Fcons (id, position)); | ||
| 6684 | } | ||
| 6685 | |||
| 6686 | case TOUCHSCREEN_END_EVENT: | ||
| 6687 | { | ||
| 6688 | Lisp_Object x, y, id, position; | ||
| 6689 | struct frame *f = XFRAME (event->frame_or_window); | ||
| 6690 | |||
| 6691 | id = event->arg; | ||
| 6692 | x = event->x; | ||
| 6693 | y = event->y; | ||
| 6694 | |||
| 6695 | position = make_lispy_position (f, x, y, event->timestamp); | 6742 | position = make_lispy_position (f, x, y, event->timestamp); |
| 6696 | 6743 | ||
| 6697 | return list3 (((event->kind | 6744 | return list3 (Qtouchscreen_end, Fcons (id, position), |
| 6698 | == TOUCHSCREEN_BEGIN_EVENT) | ||
| 6699 | ? Qtouchscreen_begin | ||
| 6700 | : Qtouchscreen_end), | ||
| 6701 | Fcons (id, position), | ||
| 6702 | event->modifiers ? Qt : Qnil); | 6745 | event->modifiers ? Qt : Qnil); |
| 6703 | } | 6746 | } |
| 6704 | 6747 | ||