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
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 ();
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)
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;
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,
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.