diff options
| author | Po Lu | 2023-06-12 14:19:01 +0800 |
|---|---|---|
| committer | Po Lu | 2023-06-12 14:19:01 +0800 |
| commit | 3b08bb1318cd0bf6bc1811b520f9c6934b1aa3bd (patch) | |
| tree | b7effb4669608cb3329923a7c7a8a1387dbea412 /java | |
| parent | e3196835ed08a1d1a675b933a53d1a397defd561 (diff) | |
| download | emacs-3b08bb1318cd0bf6bc1811b520f9c6934b1aa3bd.tar.gz emacs-3b08bb1318cd0bf6bc1811b520f9c6934b1aa3bd.zip | |
Fix deadlocks
* java/org/gnu/emacs/EmacsView.java (EmacsView)
(showOnScreenKeyboard, hideOnScreenKeyboard): Don't synchronize.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
(toggleOnScreenKeyboard): Revert to calling IMM functions from
the main thread.
* src/android.c (struct android_event_container)
(android_pselect_nfds, android_pselect_readfds)
(android_pselect_writefds, android_pselect_exceptfds)
(android_pselect_timeout): Don't make volatile.
(android_wait_event): Run queries if necessary.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsView.java | 5 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsWindow.java | 25 |
2 files changed, 20 insertions, 10 deletions
diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java index 7fd672233f2..278c6025902 100644 --- a/java/org/gnu/emacs/EmacsView.java +++ b/java/org/gnu/emacs/EmacsView.java | |||
| @@ -590,16 +590,17 @@ public final class EmacsView extends ViewGroup | |||
| 590 | super.onAttachedToWindow (); | 590 | super.onAttachedToWindow (); |
| 591 | } | 591 | } |
| 592 | 592 | ||
| 593 | public synchronized void | 593 | public void |
| 594 | showOnScreenKeyboard () | 594 | showOnScreenKeyboard () |
| 595 | { | 595 | { |
| 596 | /* Specifying no flags at all tells the system the user asked for | 596 | /* Specifying no flags at all tells the system the user asked for |
| 597 | the input method to be displayed. */ | 597 | the input method to be displayed. */ |
| 598 | |||
| 598 | imManager.showSoftInput (this, 0); | 599 | imManager.showSoftInput (this, 0); |
| 599 | isCurrentlyTextEditor = true; | 600 | isCurrentlyTextEditor = true; |
| 600 | } | 601 | } |
| 601 | 602 | ||
| 602 | public synchronized void | 603 | public void |
| 603 | hideOnScreenKeyboard () | 604 | hideOnScreenKeyboard () |
| 604 | { | 605 | { |
| 605 | imManager.hideSoftInputFromWindow (this.getWindowToken (), | 606 | imManager.hideSoftInputFromWindow (this.getWindowToken (), |
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index f5e40e9a2d9..68a18ec2aa7 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java | |||
| @@ -1201,16 +1201,25 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 1201 | } | 1201 | } |
| 1202 | 1202 | ||
| 1203 | public void | 1203 | public void |
| 1204 | toggleOnScreenKeyboard (boolean on) | 1204 | toggleOnScreenKeyboard (final boolean on) |
| 1205 | { | 1205 | { |
| 1206 | /* InputMethodManager functions are thread safe. Call | 1206 | /* Even though InputMethodManager functions are thread safe, |
| 1207 | `showOnScreenKeyboard' etc from the Emacs thread in order to | 1207 | `showOnScreenKeyboard' etc must be called from the UI thread in |
| 1208 | keep the calls in sync with updates to the input context. */ | 1208 | order to avoid deadlocks if the calls happen in tandem with a |
| 1209 | call to a synchronizing function within | ||
| 1210 | `onCreateInputConnection'. */ | ||
| 1209 | 1211 | ||
| 1210 | if (on) | 1212 | EmacsService.SERVICE.runOnUiThread (new Runnable () { |
| 1211 | view.showOnScreenKeyboard (); | 1213 | @Override |
| 1212 | else | 1214 | public void |
| 1213 | view.hideOnScreenKeyboard (); | 1215 | run () |
| 1216 | { | ||
| 1217 | if (on) | ||
| 1218 | view.showOnScreenKeyboard (); | ||
| 1219 | else | ||
| 1220 | view.hideOnScreenKeyboard (); | ||
| 1221 | } | ||
| 1222 | }); | ||
| 1214 | } | 1223 | } |
| 1215 | 1224 | ||
| 1216 | public String | 1225 | public String |