From: Po Lu Date: Tue, 14 Mar 2023 05:19:01 +0000 (+0800) Subject: Update Android port X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d6bddca26c7cf827e098ae783e865fcbcdd48799;p=emacs.git Update Android port * java/org/gnu/emacs/EmacsWindow.java (figureChange): Detect mice on up events as well. (onSomeKindOfMotionEvent): Work past framework bug. * src/androidterm.c (android_perform_conversion_query): * src/textconv.c (textconv_query): * src/textconv.h (TEXTCONV_SKIP_ACTIVE_REGION): Remove unused code. --- diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index d786c104153..a8d1beedef7 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java @@ -755,6 +755,14 @@ public final class EmacsWindow extends EmacsHandleObject break; case MotionEvent.ACTION_UP: + + /* Detect mice. If this is a mouse event, give it to + onSomeKindOfMotionEvent. */ + if ((Build.VERSION.SDK_INT + >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + && event.getToolType (0) == MotionEvent.TOOL_TYPE_MOUSE) + return -2; + /* Primary pointer released with index 0. */ pointerID = event.getPointerId (0); pointerMap.remove (pointerID); @@ -916,6 +924,7 @@ public final class EmacsWindow extends EmacsHandleObject EmacsNative.sendLeaveNotify (this.handle, (int) event.getX (), (int) event.getY (), event.getEventTime ()); + return true; case MotionEvent.ACTION_BUTTON_PRESS: @@ -949,13 +958,35 @@ public final class EmacsWindow extends EmacsHandleObject return true; case MotionEvent.ACTION_DOWN: - case MotionEvent.ACTION_UP: /* Emacs must return true even though touch events are not handled here, because the value of this function is used by the system to decide whether or not Emacs gets ACTION_MOVE events. */ return true; + case MotionEvent.ACTION_UP: + /* However, if ACTION_UP reports a different button state from + the last known state, look up which button was released and + send a ButtonRelease event; this is to work around a bug in + the framework where real ACTION_BUTTON_RELEASE events are + not delivered. */ + + if (Build.VERSION.SDK_INT + < Build.VERSION_CODES.ICE_CREAM_SANDWICH) + return true; + + if (event.getButtonState () == 0 && lastButtonState != 0) + { + EmacsNative.sendButtonRelease (this.handle, (int) event.getX (), + (int) event.getY (), + event.getEventTime (), + lastModifiers, + whatButtonWasIt (event, false)); + lastButtonState = event.getButtonState (); + } + + return true; + case MotionEvent.ACTION_SCROLL: /* Send a scroll event with the specified deltas. */ EmacsNative.sendWheel (this.handle, (int) event.getX (), diff --git a/src/androidterm.c b/src/androidterm.c index 72d81744128..0110c4b6dd8 100644 --- a/src/androidterm.c +++ b/src/androidterm.c @@ -4685,8 +4685,6 @@ struct android_conversion_query_context /* Obtain the text from the frame whose window is that specified in DATA using the text conversion query specified there. - Adjust the query position to skip over any active composing region. - Set ((struct android_conversion_query_context *) DATA)->success on success. */ @@ -4704,7 +4702,7 @@ android_perform_conversion_query (void *data) if (!f) return; - textconv_query (f, &context->query, TEXTCONV_SKIP_ACTIVE_REGION); + textconv_query (f, &context->query, 0); /* context->query.text will have been set even if textconv_query returns 1. */ diff --git a/src/textconv.c b/src/textconv.c index 900277016f2..91f6e861c60 100644 --- a/src/textconv.c +++ b/src/textconv.c @@ -147,9 +147,6 @@ select_window (Lisp_Object window, Lisp_Object norecord) If FLAGS & TEXTCONV_SKIP_CONVERSION_REGION, then first move PT past the conversion region in the specified direction if it is inside. - If FLAGS & TEXTCONV_SKIP_ACTIVE_REGION, then also move PT past the - region if the mark is active. - Value is 0 if QUERY->operation was not TEXTCONV_SUBSTITUTION or if deleting the text was successful, and 1 otherwise. */ @@ -234,37 +231,6 @@ textconv_query (struct frame *f, struct textconv_callback_struct *query, } } - /* Likewise for the region if the mark is active. */ - - if (flags & TEXTCONV_SKIP_ACTIVE_REGION) - { - temp = mark; - - if (temp == -1) - goto escape; - - start = min (temp, PT); - end = max (temp, PT); - - if (pos >= start && pos < end) - { - switch (query->direction) - { - case TEXTCONV_FORWARD_CHAR: - case TEXTCONV_FORWARD_WORD: - case TEXTCONV_CARET_DOWN: - case TEXTCONV_NEXT_LINE: - case TEXTCONV_LINE_START: - pos = end; - break; - - default: - pos = max (BEGV, start); - break; - } - } - } - escape: /* If pos is outside the accessible part of the buffer or if it diff --git a/src/textconv.h b/src/textconv.h index 9bc9e7d9bd1..6abca97bc52 100644 --- a/src/textconv.h +++ b/src/textconv.h @@ -119,7 +119,6 @@ struct textconv_callback_struct }; #define TEXTCONV_SKIP_CONVERSION_REGION (1 << 0) -#define TEXTCONV_SKIP_ACTIVE_REGION (1 << 1) extern int textconv_query (struct frame *, struct textconv_callback_struct *, int);