mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-28 07:45:00 +00: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:
parent
2909ef8d3d
commit
297ccd967f
@ -663,6 +663,19 @@ in Emacs.
|
||||
modifier: it is referred to as @key{SYM} on Android keyboards and
|
||||
within the Settings keymap menu.
|
||||
|
||||
@vindex android-intercept-control-space
|
||||
@cindex @kbd{C-SPC} interception, android
|
||||
Android input methods have a penchant for irritating users by
|
||||
silently discarding key sequences containing @kbd{C-SPC} during the
|
||||
event filtering process, that they normally have no real application
|
||||
for such key sequences notwithstanding. By default, Emacs intercepts
|
||||
these key sequences before they can be filtered by the input method.
|
||||
|
||||
If this proves unwanted (for instance, if the input method treats
|
||||
@kbd{C-SPC} as a shortcut key for switching languages), it can be
|
||||
disabled by setting the variable
|
||||
@code{android-intercept-control-space} to @code{nil}.
|
||||
|
||||
@node Android Fonts
|
||||
@section Font Backends and Selection under Android
|
||||
@cindex fonts, android
|
||||
|
@ -196,6 +196,10 @@ public static native long sendExpose (short window, int x, int y,
|
||||
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 ();
|
||||
|
@ -470,6 +470,26 @@ else if (child.getVisibility () != GONE)
|
||||
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)
|
||||
|
@ -576,7 +576,7 @@ private static class Coordinate
|
||||
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;
|
||||
|
@ -2267,6 +2267,12 @@ NATIVE_NAME (shouldForwardMultimediaButtons) (JNIEnv *env,
|
||||
return !android_pass_multimedia_buttons_to_system;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
NATIVE_NAME (shouldForwardCtrlSpace) (JNIEnv *env, jobject object)
|
||||
{
|
||||
return !android_intercept_control_space;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
NATIVE_NAME (blitRect) (JNIEnv *env, jobject object,
|
||||
jobject src, jobject dest,
|
||||
|
@ -3205,6 +3205,19 @@ Note that if you set this, you will no longer be able to quit Emacs
|
||||
using the volume down button. */);
|
||||
android_pass_multimedia_buttons_to_system = false;
|
||||
|
||||
DEFVAR_BOOL ("android-intercept-control-space",
|
||||
android_intercept_control_space,
|
||||
doc: /* Whether Emacs should intercept C-SPC.
|
||||
When this variable is set, Emacs intercepts C-SPC events as they are
|
||||
delivered to a frame before they are registered and filtered by the
|
||||
input method.
|
||||
|
||||
For no apparent purpose, Android input methods customarily discard SPC
|
||||
events with the Ctrl modifier set without delivering them to Emacs
|
||||
afterwards, which is an impediment to typing key sequences
|
||||
incorporating such keys. */);
|
||||
android_intercept_control_space = true;
|
||||
|
||||
DEFVAR_BOOL ("android-use-exec-loader", android_use_exec_loader,
|
||||
doc: /* Whether or not to bypass system restrictions on program execution.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user