1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-08 04:30:45 -08:00

Facilitate typing `C-SPC' on Android

* doc/emacs/android.texi (Android Windowing): Mention C-SPC
interception and how it may be disabled.

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

* java/org/gnu/emacs/EmacsView.java (onKeyPreIme): New function.
If the provided key code is SPC and the event's modifier key
mask contains ControlMask, relay it directly to onKeyDown.

* java/org/gnu/emacs/EmacsWindow.java (eventModifiers): Export
and make static.

* src/android.c (shouldForwardCtrlSpace): New function.

* src/androidfns.c (syms_of_androidfns)
<android_intercept_control_space>: New defvar.
This commit is contained in:
Po Lu 2023-08-30 10:07:49 +08:00
parent 2909ef8d3d
commit 297ccd967f
6 changed files with 57 additions and 1 deletions

View file

@ -196,6 +196,10 @@ public final class EmacsNative
KEYCODE_VOLUME_MUTE should be forwarded to Emacs. */
public static native boolean shouldForwardMultimediaButtons ();
/* Return whether KEYCODE_SPACE combined with META_CTRL_MASK should
be prevented from reaching the system input method. */
public static native boolean shouldForwardCtrlSpace ();
/* Initialize the current thread, by blocking signals that do not
interest it. */
public static native void setupSystemThread ();

View file

@ -470,6 +470,26 @@ public final class EmacsView extends ViewGroup
surfaceView.setBitmap (bitmap, damageRect);
}
@Override
public boolean
onKeyPreIme (int keyCode, KeyEvent event)
{
/* Several Android systems intercept key events representing
C-SPC. Avert this by detecting C-SPC events here and relaying
them directly to onKeyDown.
Make this optional though, since some input methods also
leverage C-SPC as a shortcut for switching languages. */
if ((keyCode == KeyEvent.KEYCODE_SPACE
&& (window.eventModifiers (event)
& KeyEvent.META_CTRL_MASK) != 0)
&& !EmacsNative.shouldForwardCtrlSpace ())
return onKeyDown (keyCode, event);
return super.onKeyPreIme (keyCode, event);
}
@Override
public boolean
onKeyDown (int keyCode, KeyEvent event)

View file

@ -576,7 +576,7 @@ public final class EmacsWindow extends EmacsHandleObject
input EVENT. Replace bits corresponding to Left or Right keys
with their corresponding general modifier bits. */
private int
public static int
eventModifiers (KeyEvent event)
{
int state;