mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-03-10 00:42:17 -07:00
Correctly display popup dialogs from Emacsclient
* java/org/gnu/emacs/EmacsContextMenu.java (EmacsContextMenu): Make subclasses final. * java/org/gnu/emacs/EmacsDialog.java (display1): Check if an instance of EmacsOpenActivity is open; if it is, try using it to display the pop up dialog. * java/org/gnu/emacs/EmacsDialogButtonLayout.java (EmacsDialogButtonLayout): Make final. * java/org/gnu/emacs/EmacsHolder.java (EmacsHolder<T>): Likewise. * java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity): New field `currentActivity'. (onCreate, onDestroy, onWindowFocusChanged, onPause): Set that field as appropriate.
This commit is contained in:
parent
b1bd40dce1
commit
1661762784
5 changed files with 85 additions and 8 deletions
|
|
@ -72,8 +72,17 @@ public final class EmacsOpenActivity extends Activity
|
|||
DialogInterface.OnCancelListener
|
||||
{
|
||||
private static final String TAG = "EmacsOpenActivity";
|
||||
|
||||
/* The name of any file that should be opened as EmacsThread starts
|
||||
Emacs. This is never cleared, even if EmacsOpenActivity is
|
||||
started a second time, as EmacsThread only starts once. */
|
||||
public static String fileToOpen;
|
||||
|
||||
/* Any currently focused EmacsOpenActivity. Used to show pop ups
|
||||
while the activity is active and Emacs doesn't have permission to
|
||||
display over other programs. */
|
||||
public static EmacsOpenActivity currentActivity;
|
||||
|
||||
private class EmacsClientThread extends Thread
|
||||
{
|
||||
private ProcessBuilder builder;
|
||||
|
|
@ -362,6 +371,15 @@ public final class EmacsOpenActivity extends Activity
|
|||
thread.start ();
|
||||
}
|
||||
|
||||
/* Run emacsclient to open the file specified in the Intent that
|
||||
caused this activity to start.
|
||||
|
||||
Determine the name of the file corresponding to the URI specified
|
||||
in that intent; then, run emacsclient and wait for it to finish.
|
||||
|
||||
Finally, display any error message, transfer the focus to an
|
||||
Emacs frame, and finish the activity. */
|
||||
|
||||
@Override
|
||||
public void
|
||||
onCreate (Bundle savedInstanceState)
|
||||
|
|
@ -463,10 +481,60 @@ public final class EmacsOpenActivity extends Activity
|
|||
}
|
||||
}
|
||||
|
||||
/* And start emacsclient. */
|
||||
/* And start emacsclient. Set `currentActivity' to this now.
|
||||
Presumably, it will shortly become capable of displaying
|
||||
dialogs. */
|
||||
currentActivity = this;
|
||||
startEmacsClient (fileName);
|
||||
}
|
||||
else
|
||||
finish ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void
|
||||
onDestroy ()
|
||||
{
|
||||
Log.d (TAG, "onDestroy: " + this);
|
||||
|
||||
/* Clear `currentActivity' if it refers to the activity being
|
||||
destroyed. */
|
||||
|
||||
if (currentActivity == this)
|
||||
this.currentActivity = null;
|
||||
|
||||
super.onDestroy ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void
|
||||
onWindowFocusChanged (boolean isFocused)
|
||||
{
|
||||
Log.d (TAG, "onWindowFocusChanged: " + this + ", is now focused: "
|
||||
+ isFocused);
|
||||
|
||||
if (isFocused)
|
||||
currentActivity = this;
|
||||
else if (currentActivity == this)
|
||||
currentActivity = null;
|
||||
|
||||
super.onWindowFocusChanged (isFocused);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void
|
||||
onPause ()
|
||||
{
|
||||
Log.d (TAG, "onPause: " + this);
|
||||
|
||||
/* XXX: clear currentActivity here as well; I don't know whether
|
||||
or not onWindowFocusChanged is always called prior to this. */
|
||||
|
||||
if (currentActivity == this)
|
||||
currentActivity = null;
|
||||
|
||||
super.onPause ();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue