aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorPo Lu2024-05-23 17:46:48 +0800
committerPo Lu2024-05-23 17:46:48 +0800
commite96e4906c8cb2a8810f969579446f6d151954586 (patch)
treec652b22c7eab1daf3a3306790ef3fb061dc384da /java
parent64cced2c37a9926fe6ff1c6ad9b9540abd47e21c (diff)
downloademacs-e96e4906c8cb2a8810f969579446f6d151954586.tar.gz
emacs-e96e4906c8cb2a8810f969579446f6d151954586.zip
Work around one Android bug and document another
* etc/PROBLEMS (Runtime problems specific to Android): Document deficiency of "Android Keyboard (AOSP)." * java/org/gnu/emacs/EmacsView.java (showOnScreenKeyboard): Revert yesterday's change. * java/org/gnu/emacs/EmacsWindow.java (toggleOnScreenKeyboard): Sync with the UI thread after displaying the on-screen keyboard.
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsView.java9
-rw-r--r--java/org/gnu/emacs/EmacsWindow.java27
2 files changed, 23 insertions, 13 deletions
diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java
index db270b796e8..244a3a02166 100644
--- a/java/org/gnu/emacs/EmacsView.java
+++ b/java/org/gnu/emacs/EmacsView.java
@@ -777,15 +777,6 @@ public final class EmacsView extends ViewGroup
777 777
778 imManager.showSoftInput (this, 0); 778 imManager.showSoftInput (this, 0);
779 isCurrentlyTextEditor = true; 779 isCurrentlyTextEditor = true;
780
781 /* The OS text editing widget unconditionally reports the current
782 values of the selection to the input method after calls to
783 showSoftInput, which is redundant if inputConnection exists but
784 is now relied upon in such circumstances by the OS's default
785 input method, and must therefore be faithfully reproduced on our
786 part. */
787 if (inputConnection != null)
788 EmacsNative.requestSelectionUpdate (window.handle);
789 } 780 }
790 781
791 public void 782 public void
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java
index 483ba0dbced..5a4e04ae169 100644
--- a/java/org/gnu/emacs/EmacsWindow.java
+++ b/java/org/gnu/emacs/EmacsWindow.java
@@ -20,12 +20,16 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
20package org.gnu.emacs; 20package org.gnu.emacs;
21 21
22import java.lang.IllegalStateException; 22import java.lang.IllegalStateException;
23
23import java.util.ArrayList; 24import java.util.ArrayList;
25import java.util.LinkedHashMap;
24import java.util.List; 26import java.util.List;
25import java.util.ListIterator; 27import java.util.ListIterator;
26import java.util.LinkedHashMap;
27import java.util.Map; 28import java.util.Map;
28 29
30import java.util.concurrent.Callable;
31import java.util.concurrent.FutureTask;
32
29import android.app.Activity; 33import android.app.Activity;
30 34
31import android.content.ClipData; 35import android.content.ClipData;
@@ -1620,23 +1624,38 @@ public final class EmacsWindow extends EmacsHandleObject
1620 public void 1624 public void
1621 toggleOnScreenKeyboard (final boolean on) 1625 toggleOnScreenKeyboard (final boolean on)
1622 { 1626 {
1627 FutureTask<Void> task;
1628
1623 /* Even though InputMethodManager functions are thread safe, 1629 /* Even though InputMethodManager functions are thread safe,
1624 `showOnScreenKeyboard' etc must be called from the UI thread in 1630 `showOnScreenKeyboard' etc must be called from the UI thread in
1625 order to avoid deadlocks if the calls happen in tandem with a 1631 order to avoid deadlocks if the calls happen in tandem with a
1626 call to a synchronizing function within 1632 call to a synchronizing function within
1627 `onCreateInputConnection'. */ 1633 `onCreateInputConnection'. */
1628 1634
1629 EmacsService.SERVICE.runOnUiThread (new Runnable () { 1635 task = new FutureTask<Void> (new Callable<Void> () {
1630 @Override 1636 @Override
1631 public void 1637 public Void
1632 run () 1638 call ()
1633 { 1639 {
1634 if (on) 1640 if (on)
1635 view.showOnScreenKeyboard (); 1641 view.showOnScreenKeyboard ();
1636 else 1642 else
1637 view.hideOnScreenKeyboard (); 1643 view.hideOnScreenKeyboard ();
1644 return null;
1638 } 1645 }
1639 }); 1646 });
1647
1648 /* Block Lisp until this request to display the on-screen keyboard
1649 is registered by the UI thread, or updates arising from a
1650 redisplay that are reported between the two events will be liable
1651 to run afoul of the IMM's cache of selection positions and never
1652 reach the input method, if it is currently hidden, as input
1653 methods receive outdated selection information reported during
1654 the previous call to `onCreateInputConnection' when first
1655 displayed.
1656
1657 Chances are this is a long-standing bug in the system. */
1658 EmacsService.<Void>syncRunnable (task);
1640 } 1659 }
1641 1660
1642 public String 1661 public String