1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-09 15:50:40 -08:00

Enable customization of the quit key on Android

* doc/emacs/android.texi (Android Windowing):

* doc/emacs/input.texi (On-Screen Keyboards): Document various
tidbits related to the quit key.

* java/org/gnu/emacs/EmacsNative.java (getQuitKeycode): New
function.

* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): Rename
`lastVolumeButtonRelease' to `lastQuitKeyRelease'.
(onKeyUp): Treat value returned by getQuitKeycode as the quit
key rather than mandate KEYCODE_VOLUME_DOWN.

* src/android.c (getQuitKeycode): Implement new function.

* src/androidterm.c (syms_of_androidterm)
<android_quit_keycode>: New variable.
This commit is contained in:
Po Lu 2024-04-27 10:47:12 +08:00
parent 763eaa5a32
commit db8f7ed7f6
6 changed files with 47 additions and 18 deletions

View file

@ -136,10 +136,10 @@ public final class EmacsWindow extends EmacsHandleObject
there is no such window manager. */
private WindowManager windowManager;
/* The time of the last KEYCODE_VOLUME_DOWN release. This is used
to quit Emacs upon two rapid clicks of the volume down
button. */
private long lastVolumeButtonRelease;
/* The time of the last release of the quit keycode, generally
KEYCODE_VOLUME_DOWN. This is used to signal quit upon two rapid
presses of such key. */
private long lastQuitKeyRelease;
/* Linked list of character strings which were recently sent as
events. */
@ -790,15 +790,12 @@ public final class EmacsWindow extends EmacsHandleObject
if ((event.getFlags () & KeyEvent.FLAG_CANCELED) != 0)
return;
EmacsNative.sendKeyPress (this.handle, event.getEventTime (),
state, keyCode, unicode_char);
}
EmacsNative.sendKeyRelease (this.handle, event.getEventTime (),
state, keyCode, unicode_char);
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
if (keyCode == EmacsNative.getQuitKeycode ())
{
/* Check if this volume down press should quit Emacs.
Most Android devices have no physical keyboard, so it
@ -806,10 +803,10 @@ public final class EmacsWindow extends EmacsHandleObject
time = event.getEventTime ();
if (time - lastVolumeButtonRelease < 350)
if (time - lastQuitKeyRelease < 350)
EmacsNative.quit ();
lastVolumeButtonRelease = time;
lastQuitKeyRelease = time;
}
}