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.
This commit is contained in:
Po Lu 2023-06-11 08:52:10 +08:00
parent f9cede52fa
commit 5abc977bbb
2 changed files with 12 additions and 15 deletions

View file

@ -590,7 +590,7 @@ else if (child.getVisibility () != GONE)
super.onAttachedToWindow ();
}
public void
public synchronized void
showOnScreenKeyboard ()
{
/* Specifying no flags at all tells the system the user asked for
@ -599,7 +599,7 @@ else if (child.getVisibility () != GONE)
isCurrentlyTextEditor = true;
}
public void
public synchronized void
hideOnScreenKeyboard ()
{
imManager.hideSoftInputFromWindow (this.getWindowToken (),
@ -686,7 +686,7 @@ else if (child.getVisibility () != GONE)
}
@Override
public boolean
public synchronized boolean
onCheckIsTextEditor ()
{
/* If value is true, then the system will display the on screen

View file

@ -1201,19 +1201,16 @@ else if (EmacsWindow.this.isMapped)
}
public void
toggleOnScreenKeyboard (final boolean on)
toggleOnScreenKeyboard (boolean on)
{
EmacsService.SERVICE.runOnUiThread (new Runnable () {
@Override
public void
run ()
{
if (on)
view.showOnScreenKeyboard ();
else
view.hideOnScreenKeyboard ();
}
});
/* InputMethodManager functions are thread safe. Call
`showOnScreenKeyboard' etc from the Emacs thread in order to
keep the calls in sync with updates to the input context. */
if (on)
view.showOnScreenKeyboard ();
else
view.hideOnScreenKeyboard ();
}
public String