diff options
| author | Po Lu | 2023-05-07 11:09:56 +0800 |
|---|---|---|
| committer | Po Lu | 2023-05-07 11:09:56 +0800 |
| commit | 889b61b99918d1c6313d4f884de2e2cb3ab466c9 (patch) | |
| tree | 963ea5823611ecc74a62098c1d37a378e2bfd83d /java | |
| parent | c0a52c6cef77b8bc83e9d373ac0d0899c93f7a37 (diff) | |
| download | emacs-889b61b99918d1c6313d4f884de2e2cb3ab466c9.tar.gz emacs-889b61b99918d1c6313d4f884de2e2cb3ab466c9.zip | |
Update Android port
* java/org/gnu/emacs/EmacsInputConnection.java
(requestCursorUpdates):
* java/org/gnu/emacs/EmacsNative.java (requestCursorUpdates):
* java/org/gnu/emacs/EmacsService.java (updateCursorAnchorInfo):
New functions.
* src/android.c (struct android_emacs_service)
(android_init_emacs_service): Add new method.
(android_update_cursor_anchor_info): New function.
* src/androidfns.c (android_set_preeditarea): New function.
* src/androidgui.h (enum android_ime_operation): New operation
`REQUEST_CURSOR_UPDATES'.
(struct android_ime_event): Document new meaning of `length'.
* src/androidterm.c (android_request_cursor_updates): New
function.
(android_handle_ime_event): Handle new operations.
(handle_one_android_event, android_draw_window_cursor): Update
the preedit area if needed, like on X.
(requestCursorUpdates): New function.
* src/androidterm.h (struct android_output): New field
`need_cursor_updates'.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsInputConnection.java | 11 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsNative.java | 1 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 32 |
3 files changed, 44 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsInputConnection.java b/java/org/gnu/emacs/EmacsInputConnection.java index d13b48288ce..21bbaca5d07 100644 --- a/java/org/gnu/emacs/EmacsInputConnection.java +++ b/java/org/gnu/emacs/EmacsInputConnection.java | |||
| @@ -324,6 +324,17 @@ public final class EmacsInputConnection extends BaseInputConnection | |||
| 324 | return this.deleteSurroundingText (beforeLength, afterLength); | 324 | return this.deleteSurroundingText (beforeLength, afterLength); |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | @Override | ||
| 328 | public boolean | ||
| 329 | requestCursorUpdates (int cursorUpdateMode) | ||
| 330 | { | ||
| 331 | if (EmacsService.DEBUG_IC) | ||
| 332 | Log.d (TAG, "requestCursorUpdates: " + cursorUpdateMode); | ||
| 333 | |||
| 334 | EmacsNative.requestCursorUpdates (windowHandle, cursorUpdateMode); | ||
| 335 | return true; | ||
| 336 | } | ||
| 337 | |||
| 327 | 338 | ||
| 328 | /* Override functions which are not implemented. */ | 339 | /* Override functions which are not implemented. */ |
| 329 | 340 | ||
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java index 7d13ff99abb..e699dda9ad4 100644 --- a/java/org/gnu/emacs/EmacsNative.java +++ b/java/org/gnu/emacs/EmacsNative.java | |||
| @@ -209,6 +209,7 @@ public final class EmacsNative | |||
| 209 | ExtractedTextRequest req, | 209 | ExtractedTextRequest req, |
| 210 | int flags); | 210 | int flags); |
| 211 | public static native void requestSelectionUpdate (short window); | 211 | public static native void requestSelectionUpdate (short window); |
| 212 | public static native void requestCursorUpdates (short window, int mode); | ||
| 212 | 213 | ||
| 213 | 214 | ||
| 214 | /* Return the current value of the selection, or -1 upon | 215 | /* Return the current value of the selection, or -1 upon |
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 33436892caa..30ef71540a9 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java | |||
| @@ -25,10 +25,12 @@ import java.io.UnsupportedEncodingException; | |||
| 25 | 25 | ||
| 26 | import java.util.List; | 26 | import java.util.List; |
| 27 | 27 | ||
| 28 | import android.graphics.Matrix; | ||
| 28 | import android.graphics.Point; | 29 | import android.graphics.Point; |
| 29 | 30 | ||
| 30 | import android.view.InputDevice; | 31 | import android.view.InputDevice; |
| 31 | import android.view.KeyEvent; | 32 | import android.view.KeyEvent; |
| 33 | import android.view.inputmethod.CursorAnchorInfo; | ||
| 32 | import android.view.inputmethod.ExtractedText; | 34 | import android.view.inputmethod.ExtractedText; |
| 33 | 35 | ||
| 34 | import android.app.Notification; | 36 | import android.app.Notification; |
| @@ -635,6 +637,36 @@ public final class EmacsService extends Service | |||
| 635 | window.view.imManager.restartInput (window.view); | 637 | window.view.imManager.restartInput (window.view); |
| 636 | } | 638 | } |
| 637 | 639 | ||
| 640 | public void | ||
| 641 | updateCursorAnchorInfo (EmacsWindow window, float x, | ||
| 642 | float y, float yBaseline, | ||
| 643 | float yBottom) | ||
| 644 | { | ||
| 645 | CursorAnchorInfo info; | ||
| 646 | CursorAnchorInfo.Builder builder; | ||
| 647 | Matrix matrix; | ||
| 648 | int[] offsets; | ||
| 649 | |||
| 650 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) | ||
| 651 | return; | ||
| 652 | |||
| 653 | offsets = new int[2]; | ||
| 654 | builder = new CursorAnchorInfo.Builder (); | ||
| 655 | matrix = new Matrix (window.view.getMatrix ()); | ||
| 656 | window.view.getLocationOnScreen (offsets); | ||
| 657 | matrix.postTranslate (offsets[0], offsets[1]); | ||
| 658 | builder.setMatrix (matrix); | ||
| 659 | builder.setInsertionMarkerLocation (x, y, yBaseline, yBottom, | ||
| 660 | 0); | ||
| 661 | info = builder.build (); | ||
| 662 | |||
| 663 | if (DEBUG_IC) | ||
| 664 | Log.d (TAG, ("updateCursorAnchorInfo: " + x + " " + y | ||
| 665 | + " " + yBaseline + "-" + yBottom)); | ||
| 666 | |||
| 667 | window.view.imManager.updateCursorAnchorInfo (window.view, info); | ||
| 668 | } | ||
| 669 | |||
| 638 | /* Open a content URI described by the bytes BYTES, a non-terminated | 670 | /* Open a content URI described by the bytes BYTES, a non-terminated |
| 639 | string; make it writable if WRITABLE, and readable if READABLE. | 671 | string; make it writable if WRITABLE, and readable if READABLE. |
| 640 | Truncate the file if TRUNCATE. | 672 | Truncate the file if TRUNCATE. |