* 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.
(cherry picked from commit
db8f7ed7f652c114e606de423e5094b4cefe49e2)
@vindex android-pass-multimedia-buttons-to-system
@cindex volume/multimedia buttons, Android
- The volume keys are normally reserved by Emacs and used to provide
-the ability to quit Emacs without a physical keyboard
-(@pxref{On-Screen Keyboards}.) However, if you want them to adjust
-the volume instead, you can set the variable
+ The volume keys are normally reserved by Emacs and used to provide the
+ability to quit Emacs without a physical keyboard (@pxref{On-Screen
+Keyboards}). However, if you want them to adjust the volume instead,
+you can set the variable
@code{android-pass-multimedia-buttons-to-system} to a non-@code{nil}
value; note that you will no longer be able to quit Emacs using the
-volume buttons in that case.
+volume buttons in that case, and that it is generally easier to activate
+the notification shade or another interface that momentarily deprives
+Emacs of the keyboard focus while the volume buttons are being
+depressed.
@cindex dialog boxes, android
Emacs is unable to display dialog boxes (@pxref{Dialog Boxes}) while
the device induces a quit. @xref{Quitting}.
@vindex x-quit-keysym
- No such button is enabled on X, but one can be configured through
-the variable @code{x-quit-keysym}. On Android this button is always
-the volume down button.
+@vindex android-quit-keycode
+ No such button is enabled on X, but one can be configured through the
+variable @code{x-quit-keysym}, whereas the default key is the volume
+down button on Android, which is also configurable through a variable,
+@code{android-quit-keycode}.
@cindex text conversion, keyboards
Most input methods designed to work with virtual keyboards edit text
be prevented from reaching the system input method. */
public static native boolean shouldForwardCtrlSpace ();
+ /* Return the keycode repeated activation of which should signal
+ quit. */
+ public static native int getQuitKeycode ();
+
/* Initialize the current thread, by blocking signals that do not
interest it. */
public static native void setupSystemThread ();
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. */
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
time = event.getEventTime ();
- if (time - lastVolumeButtonRelease < 350)
+ if (time - lastQuitKeyRelease < 350)
EmacsNative.quit ();
- lastVolumeButtonRelease = time;
+ lastQuitKeyRelease = time;
}
}
return !android_pass_multimedia_buttons_to_system;
}
+JNIEXPORT jint JNICALL
+NATIVE_NAME (getQuitKeycode) (JNIEnv *env, jobject object)
+{
+ /* Likewise. */
+ return (jint) android_quit_keycode;
+}
+
JNIEXPORT jboolean JNICALL
NATIVE_NAME (shouldForwardCtrlSpace) (JNIEnv *env, jobject object)
{
If set to a non-float value, there will be no wait at all. */);
Vandroid_wait_for_event_timeout = make_float (0.1);
+ DEFVAR_INT ("android-quit-keycode", android_quit_keycode,
+ doc: /* Keycode that signals quit when typed twice in rapid succession.
+
+This is the key code of a key whose repeated activation should prompt
+Emacs to quit, enabling quitting on systems where a keyboard capable of
+typing C-g is unavailable, when set to a key that does exist on the
+device. Its value must be a keycode defined by the operating system,
+and defaults to 25 (KEYCODE_VOLUME_DOWN), though one of the following
+values might be desired on those devices where this default is also
+unavailable, or if another key must otherwise serve this function
+instead:
+
+ - 4 (KEYCODE_BACK)
+ - 24 (KEYCODE_VOLUME_UP) */);
+ android_quit_keycode = 25;
+
DEFVAR_BOOL ("x-use-underline-position-properties",
x_use_underline_position_properties,
doc: /* SKIP: real doc in xterm.c. */);