aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorPo Lu2024-04-27 10:47:12 +0800
committerPo Lu2024-04-27 10:47:12 +0800
commitdb8f7ed7f652c114e606de423e5094b4cefe49e2 (patch)
tree2ba2fd002786db7599f9efac0c8965b13f0c54e2 /java
parent763eaa5a324ff51dddad32d725ec8d416597d6d5 (diff)
downloademacs-db8f7ed7f652c114e606de423e5094b4cefe49e2.tar.gz
emacs-db8f7ed7f652c114e606de423e5094b4cefe49e2.zip
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.
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsNative.java4
-rw-r--r--java/org/gnu/emacs/EmacsWindow.java17
2 files changed, 11 insertions, 10 deletions
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java
index 9b3e60e1a84..acf9e4b204b 100644
--- a/java/org/gnu/emacs/EmacsNative.java
+++ b/java/org/gnu/emacs/EmacsNative.java
@@ -228,6 +228,10 @@ public final class EmacsNative
228 be prevented from reaching the system input method. */ 228 be prevented from reaching the system input method. */
229 public static native boolean shouldForwardCtrlSpace (); 229 public static native boolean shouldForwardCtrlSpace ();
230 230
231 /* Return the keycode repeated activation of which should signal
232 quit. */
233 public static native int getQuitKeycode ();
234
231 /* Initialize the current thread, by blocking signals that do not 235 /* Initialize the current thread, by blocking signals that do not
232 interest it. */ 236 interest it. */
233 public static native void setupSystemThread (); 237 public static native void setupSystemThread ();
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java
index 911e082144e..961292af527 100644
--- a/java/org/gnu/emacs/EmacsWindow.java
+++ b/java/org/gnu/emacs/EmacsWindow.java
@@ -136,10 +136,10 @@ public final class EmacsWindow extends EmacsHandleObject
136 there is no such window manager. */ 136 there is no such window manager. */
137 private WindowManager windowManager; 137 private WindowManager windowManager;
138 138
139 /* The time of the last KEYCODE_VOLUME_DOWN release. This is used 139 /* The time of the last release of the quit keycode, generally
140 to quit Emacs upon two rapid clicks of the volume down 140 KEYCODE_VOLUME_DOWN. This is used to signal quit upon two rapid
141 button. */ 141 presses of such key. */
142 private long lastVolumeButtonRelease; 142 private long lastQuitKeyRelease;
143 143
144 /* Linked list of character strings which were recently sent as 144 /* Linked list of character strings which were recently sent as
145 events. */ 145 events. */
@@ -790,15 +790,12 @@ public final class EmacsWindow extends EmacsHandleObject
790 790
791 if ((event.getFlags () & KeyEvent.FLAG_CANCELED) != 0) 791 if ((event.getFlags () & KeyEvent.FLAG_CANCELED) != 0)
792 return; 792 return;
793
794 EmacsNative.sendKeyPress (this.handle, event.getEventTime (),
795 state, keyCode, unicode_char);
796 } 793 }
797 794
798 EmacsNative.sendKeyRelease (this.handle, event.getEventTime (), 795 EmacsNative.sendKeyRelease (this.handle, event.getEventTime (),
799 state, keyCode, unicode_char); 796 state, keyCode, unicode_char);
800 797
801 if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) 798 if (keyCode == EmacsNative.getQuitKeycode ())
802 { 799 {
803 /* Check if this volume down press should quit Emacs. 800 /* Check if this volume down press should quit Emacs.
804 Most Android devices have no physical keyboard, so it 801 Most Android devices have no physical keyboard, so it
@@ -806,10 +803,10 @@ public final class EmacsWindow extends EmacsHandleObject
806 803
807 time = event.getEventTime (); 804 time = event.getEventTime ();
808 805
809 if (time - lastVolumeButtonRelease < 350) 806 if (time - lastQuitKeyRelease < 350)
810 EmacsNative.quit (); 807 EmacsNative.quit ();
811 808
812 lastVolumeButtonRelease = time; 809 lastQuitKeyRelease = time;
813 } 810 }
814 } 811 }
815 812