From 2dcce30290dc7782e9de3b4adf59f38b42408c98 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 16 Feb 2023 23:57:01 +0800 Subject: Update Android port * doc/emacs/android.texi (Android Fonts): * doc/emacs/input.texi (On-Screen Keyboards): * doc/lispref/commands.texi (Misc Events): Update documentation. * java/org/gnu/emacs/EmacsInputConnection.java (setSelection): New function. * java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView) (reconfigureFrontBuffer): Make bitmap references weak references. * java/org/gnu/emacs/EmacsView.java (handleDirtyBitmap): Don't clear surfaceView bitmap. * lisp/comint.el (comint-mode): * lisp/international/fontset.el (script-representative-chars) (setup-default-fontset): Improve detection of CJK fonts. * lisp/isearch.el (set-text-conversion-style): New variable. (isearch-mode, isearch-done): Save and restore the text conversion style. * lisp/minibuffer.el (minibuffer-mode): Set an appropriate text conversion style. * lisp/simple.el (analyze-text-conversion): Run post-self-insert-hook properly. * lisp/subr.el (read-char-from-minibuffer): Disable text conversion when reading character. * src/androidterm.c (show_back_buffer): Don't check that F is not garbaged. (android_update_selection, android_reset_conversion): Use the ephemeral last point and handle text conversion being disabled. * src/buffer.c (syms_of_buffer): Convert old style DEFVAR. * src/keyboard.c (kbd_buffer_get_event): Handle text conversion first. * src/lisp.h: Update prototypes. * src/lread.c (read_filtered_event): Temporarily disable text conversion. * src/sfnt.c (sfnt_decompose_glyph_1, sfnt_decompose_glyph_2): New functions. (sfnt_decompose_glyph, sfnt_decompose_instructed_outline): Refactor contour decomposition to those two functions. (main): Update tests. * src/sfntfont-android.c (system_font_directories): Add empty field. (Fandroid_enumerate_fonts, init_sfntfont_android): Enumerate fonts in a user fonts directory. * src/sfntfont.c (struct sfnt_font_desc): New field `num_glyphs'. (sfnt_enum_font_1): Set num_glyphs and avoid duplicate fonts. (sfntfont_glyph_valid): New function. (sfntfont_lookup_char, sfntfont_list_1): Make sure glyphs found are valid. * src/textconv.c (sync_overlay, really_commit_text) (really_set_composing_text, really_set_composing_region) (really_delete_surrounding_text, really_set_point_and_mark) (handle_pending_conversion_events_1) (handle_pending_conversion_events, conversion_disabled_p) (disable_text_conversion, resume_text_conversion) (Fset_text_conversion_style, syms_of_textconv): Update to respect new options. * src/textconv.h: * src/window.h (GCALIGNED_STRUCT): New field `ephemeral_last_point'. * src/xdisp.c (mark_window_display_accurate_1): Set it. --- java/org/gnu/emacs/EmacsInputConnection.java | 14 +++++++++++++- java/org/gnu/emacs/EmacsSurfaceView.java | 17 ++++++++++------- java/org/gnu/emacs/EmacsView.java | 8 +------- 3 files changed, 24 insertions(+), 15 deletions(-) (limited to 'java/org/gnu') diff --git a/java/org/gnu/emacs/EmacsInputConnection.java b/java/org/gnu/emacs/EmacsInputConnection.java index 5eb56d5aa71..e2a15894695 100644 --- a/java/org/gnu/emacs/EmacsInputConnection.java +++ b/java/org/gnu/emacs/EmacsInputConnection.java @@ -173,7 +173,8 @@ public class EmacsInputConnection extends BaseInputConnection setComposingText (CharSequence text, int newCursorPosition) { if (EmacsService.DEBUG_IC) - Log.d (TAG, "setComposingText: " + newCursorPosition); + Log.d (TAG, ("setComposingText: " + + text + " ## " + newCursorPosition)); EmacsNative.setComposingText (windowHandle, text.toString (), newCursorPosition); @@ -213,6 +214,17 @@ public class EmacsInputConnection extends BaseInputConnection flags); } + @Override + public boolean + setSelection (int start, int end) + { + if (EmacsService.DEBUG_IC) + Log.d (TAG, "setSelection: " + start + " " + end); + + EmacsNative.setSelection (windowHandle, start, end); + return true; + } + /* Override functions which are not implemented. */ diff --git a/java/org/gnu/emacs/EmacsSurfaceView.java b/java/org/gnu/emacs/EmacsSurfaceView.java index 2d80be0881a..62e927094e4 100644 --- a/java/org/gnu/emacs/EmacsSurfaceView.java +++ b/java/org/gnu/emacs/EmacsSurfaceView.java @@ -28,6 +28,8 @@ import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.Paint; +import java.lang.ref.WeakReference; + /* This originally extended SurfaceView. However, doing so proved to be too slow, and Android's surface view keeps up to three of its own back buffers, which use too much memory (up to 96 MB for a @@ -39,7 +41,7 @@ public class EmacsSurfaceView extends View private EmacsView view; private Bitmap frontBuffer; private Canvas bitmapCanvas; - private Bitmap bitmap; + private WeakReference bitmap; private Paint bitmapPaint; public @@ -49,10 +51,11 @@ public class EmacsSurfaceView extends View this.view = view; this.bitmapPaint = new Paint (); + this.bitmap = new WeakReference (null); } private void - copyToFrontBuffer (Rect damageRect) + copyToFrontBuffer (Bitmap bitmap, Rect damageRect) { if (damageRect != null) bitmapCanvas.drawBitmap (bitmap, damageRect, damageRect, @@ -73,7 +76,7 @@ public class EmacsSurfaceView extends View bitmapCanvas = null; } - this.bitmap = bitmap; + this.bitmap = new WeakReference (bitmap); /* Next, create the new front buffer if necessary. */ @@ -92,20 +95,20 @@ public class EmacsSurfaceView extends View bitmapCanvas = new Canvas (frontBuffer); /* And copy over the bitmap contents. */ - copyToFrontBuffer (null); + copyToFrontBuffer (bitmap, null); } else if (bitmap != null) /* Just copy over the bitmap contents. */ - copyToFrontBuffer (null); + copyToFrontBuffer (bitmap, null); } public synchronized void setBitmap (Bitmap bitmap, Rect damageRect) { - if (bitmap != this.bitmap) + if (bitmap != this.bitmap.get ()) reconfigureFrontBuffer (bitmap); else if (bitmap != null) - copyToFrontBuffer (damageRect); + copyToFrontBuffer (bitmap, damageRect); if (bitmap != null) { diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java index 52da6d41f7d..5ea8b0dcc0e 100644 --- a/java/org/gnu/emacs/EmacsView.java +++ b/java/org/gnu/emacs/EmacsView.java @@ -186,13 +186,7 @@ public class EmacsView extends ViewGroup /* Explicitly free the old bitmap's memory. */ if (oldBitmap != null) - { - oldBitmap.recycle (); - - /* Make sure to set the view's bitmap to the new bitmap, or - ugly flicker can result. */ - surfaceView.setBitmap (bitmap, null); - } + oldBitmap.recycle (); /* Some Android versions still don't free the bitmap until the next GC. */ -- cgit v1.2.1