diff options
| author | Po Lu | 2023-06-11 08:52:10 +0800 |
|---|---|---|
| committer | Po Lu | 2023-06-11 08:52:10 +0800 |
| commit | 5abc977bbb2d38f3c607f1575e02aa7a6c483db0 (patch) | |
| tree | dbea7818623dc1a6092b7ebf91b35a23f396c7c8 /java | |
| parent | f9cede52faf790dcf925e409e7a9588509f076a2 (diff) | |
| download | emacs-5abc977bbb2d38f3c607f1575e02aa7a6c483db0.tar.gz emacs-5abc977bbb2d38f3c607f1575e02aa7a6c483db0.zip | |
Avoid extraneous calls to the UI thread
* java/org/gnu/emacs/EmacsView.java (EmacsView)
(showOnScreenKeyboard, hideOnScreenKeyboard)
(onCheckIsTextEditor): Make synchronized.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
(toggleOnScreenKeyboard): Don't post to the main thread.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsView.java | 6 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsWindow.java | 21 |
2 files changed, 12 insertions, 15 deletions
diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java index d432162132d..7fd672233f2 100644 --- a/java/org/gnu/emacs/EmacsView.java +++ b/java/org/gnu/emacs/EmacsView.java | |||
| @@ -590,7 +590,7 @@ public final class EmacsView extends ViewGroup | |||
| 590 | super.onAttachedToWindow (); | 590 | super.onAttachedToWindow (); |
| 591 | } | 591 | } |
| 592 | 592 | ||
| 593 | public void | 593 | public synchronized 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 |
| @@ -599,7 +599,7 @@ public final class EmacsView extends ViewGroup | |||
| 599 | isCurrentlyTextEditor = true; | 599 | isCurrentlyTextEditor = true; |
| 600 | } | 600 | } |
| 601 | 601 | ||
| 602 | public void | 602 | public synchronized void |
| 603 | hideOnScreenKeyboard () | 603 | hideOnScreenKeyboard () |
| 604 | { | 604 | { |
| 605 | imManager.hideSoftInputFromWindow (this.getWindowToken (), | 605 | imManager.hideSoftInputFromWindow (this.getWindowToken (), |
| @@ -686,7 +686,7 @@ public final class EmacsView extends ViewGroup | |||
| 686 | } | 686 | } |
| 687 | 687 | ||
| 688 | @Override | 688 | @Override |
| 689 | public boolean | 689 | public synchronized boolean |
| 690 | onCheckIsTextEditor () | 690 | onCheckIsTextEditor () |
| 691 | { | 691 | { |
| 692 | /* If value is true, then the system will display the on screen | 692 | /* If value is true, then the system will display the on screen |
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index c14bf16b96e..f5e40e9a2d9 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java | |||
| @@ -1201,19 +1201,16 @@ public final class EmacsWindow extends EmacsHandleObject | |||
| 1201 | } | 1201 | } |
| 1202 | 1202 | ||
| 1203 | public void | 1203 | public void |
| 1204 | toggleOnScreenKeyboard (final boolean on) | 1204 | toggleOnScreenKeyboard (boolean on) |
| 1205 | { | 1205 | { |
| 1206 | EmacsService.SERVICE.runOnUiThread (new Runnable () { | 1206 | /* InputMethodManager functions are thread safe. Call |
| 1207 | @Override | 1207 | `showOnScreenKeyboard' etc from the Emacs thread in order to |
| 1208 | public void | 1208 | keep the calls in sync with updates to the input context. */ |
| 1209 | run () | 1209 | |
| 1210 | { | 1210 | if (on) |
| 1211 | if (on) | 1211 | view.showOnScreenKeyboard (); |
| 1212 | view.showOnScreenKeyboard (); | 1212 | else |
| 1213 | else | 1213 | view.hideOnScreenKeyboard (); |
| 1214 | view.hideOnScreenKeyboard (); | ||
| 1215 | } | ||
| 1216 | }); | ||
| 1217 | } | 1214 | } |
| 1218 | 1215 | ||
| 1219 | public String | 1216 | public String |