aboutsummaryrefslogtreecommitdiffstats
path: root/java/org/gnu
diff options
context:
space:
mode:
Diffstat (limited to 'java/org/gnu')
-rw-r--r--java/org/gnu/emacs/EmacsNative.java4
-rw-r--r--java/org/gnu/emacs/EmacsWindow.java19
2 files changed, 23 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java
index 7bf8b5f6081..4e91a7be322 100644
--- a/java/org/gnu/emacs/EmacsNative.java
+++ b/java/org/gnu/emacs/EmacsNative.java
@@ -74,6 +74,10 @@ public class EmacsNative
74 /* Abort and generate a native core dump. */ 74 /* Abort and generate a native core dump. */
75 public static native void emacsAbort (); 75 public static native void emacsAbort ();
76 76
77 /* Set Vquit_flag to t, resulting in Emacs quitting as soon as
78 possible. */
79 public static native void quit ();
80
77 /* Send an ANDROID_CONFIGURE_NOTIFY event. The values of all the 81 /* Send an ANDROID_CONFIGURE_NOTIFY event. The values of all the
78 functions below are the serials of the events sent. */ 82 functions below are the serials of the events sent. */
79 public static native long sendConfigureNotify (short window, long time, 83 public static native long sendConfigureNotify (short window, long time,
diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java
index 8511af9193e..39eaf2fff80 100644
--- a/java/org/gnu/emacs/EmacsWindow.java
+++ b/java/org/gnu/emacs/EmacsWindow.java
@@ -124,6 +124,10 @@ public class EmacsWindow extends EmacsHandleObject
124 there is no such window manager. */ 124 there is no such window manager. */
125 private WindowManager windowManager; 125 private WindowManager windowManager;
126 126
127 /* The time of the last KEYCODE_VOLUME_DOWN press. This is used to
128 quit Emacs. */
129 private long lastVolumeButtonPress;
130
127 public 131 public
128 EmacsWindow (short handle, final EmacsWindow parent, int x, int y, 132 EmacsWindow (short handle, final EmacsWindow parent, int x, int y,
129 int width, int height, boolean overrideRedirect) 133 int width, int height, boolean overrideRedirect)
@@ -513,6 +517,7 @@ public class EmacsWindow extends EmacsHandleObject
513 onKeyDown (int keyCode, KeyEvent event) 517 onKeyDown (int keyCode, KeyEvent event)
514 { 518 {
515 int state, state_1; 519 int state, state_1;
520 long time;
516 521
517 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) 522 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
518 state = event.getModifiers (); 523 state = event.getModifiers ();
@@ -544,6 +549,20 @@ public class EmacsWindow extends EmacsHandleObject
544 state, keyCode, 549 state, keyCode,
545 event.getUnicodeChar (state_1)); 550 event.getUnicodeChar (state_1));
546 lastModifiers = state; 551 lastModifiers = state;
552
553 if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
554 {
555 /* Check if this volume down press should quit Emacs.
556 Most Android devices have no physical keyboard, so it
557 is unreasonably hard to press C-g. */
558
559 time = event.getEventTime ();
560
561 if (lastVolumeButtonPress - time < 350)
562 EmacsNative.quit ();
563
564 lastVolumeButtonPress = time;
565 }
547 } 566 }
548 567
549 public void 568 public void