mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Additional changes to processing of Num Lock on Android
* java/org/gnu/emacs/EmacsView.java (onKeyDown, onKeyMultiple) (onKeyDown): Disregard Num and Scroll Lock keys, and return value of window functions to the system. * java/org/gnu/emacs/EmacsWindow.java (eventModifiers): Return normalized meta state, not only those bits the system considers modifiers. (onKeyDown, onKeyUp): Ignore numpad keys to which no base characters are assigned, so that the system may generate the proper action keys instead.
This commit is contained in:
parent
af6df8e045
commit
ea98a6af2f
2 changed files with 57 additions and 31 deletions
|
|
@ -505,42 +505,45 @@ public final class EmacsView extends ViewGroup
|
||||||
public boolean
|
public boolean
|
||||||
onKeyDown (int keyCode, KeyEvent event)
|
onKeyDown (int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
if (((keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
||||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|
||||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_MUTE)
|
|| keyCode == KeyEvent.KEYCODE_VOLUME_MUTE)
|
||||||
&& !EmacsNative.shouldForwardMultimediaButtons ())
|
&& !EmacsNative.shouldForwardMultimediaButtons ())
|
||||||
return false;
|
|| keyCode == KeyEvent.KEYCODE_SCROLL_LOCK
|
||||||
|
|| keyCode == KeyEvent.KEYCODE_NUM_LOCK)
|
||||||
|
return super.onKeyDown (keyCode, event);
|
||||||
|
|
||||||
window.onKeyDown (keyCode, event);
|
return window.onKeyDown (keyCode, event);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean
|
public boolean
|
||||||
onKeyMultiple (int keyCode, int repeatCount, KeyEvent event)
|
onKeyMultiple (int keyCode, int repeatCount, KeyEvent event)
|
||||||
{
|
{
|
||||||
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
if (((keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
||||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|
||||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_MUTE)
|
|| keyCode == KeyEvent.KEYCODE_VOLUME_MUTE)
|
||||||
&& !EmacsNative.shouldForwardMultimediaButtons ())
|
&& !EmacsNative.shouldForwardMultimediaButtons ())
|
||||||
return false;
|
|| keyCode == KeyEvent.KEYCODE_SCROLL_LOCK
|
||||||
|
|| keyCode == KeyEvent.KEYCODE_NUM_LOCK)
|
||||||
|
return super.onKeyMultiple (keyCode, repeatCount, event);
|
||||||
|
|
||||||
window.onKeyDown (keyCode, event);
|
return window.onKeyDown (keyCode, event);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean
|
public boolean
|
||||||
onKeyUp (int keyCode, KeyEvent event)
|
onKeyUp (int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
if (((keyCode == KeyEvent.KEYCODE_VOLUME_UP
|
||||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|
|| keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
|
||||||
|| keyCode == KeyEvent.KEYCODE_VOLUME_MUTE)
|
|| keyCode == KeyEvent.KEYCODE_VOLUME_MUTE)
|
||||||
&& !EmacsNative.shouldForwardMultimediaButtons ())
|
&& !EmacsNative.shouldForwardMultimediaButtons ())
|
||||||
return false;
|
|| keyCode == KeyEvent.KEYCODE_SCROLL_LOCK
|
||||||
|
|| keyCode == KeyEvent.KEYCODE_NUM_LOCK)
|
||||||
|
return super.onKeyUp (keyCode, event);
|
||||||
|
|
||||||
window.onKeyUp (keyCode, event);
|
return window.onKeyUp (keyCode, event);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -633,8 +633,8 @@ public final class EmacsWindow extends EmacsHandleObject
|
||||||
|
|
||||||
|
|
||||||
/* Return the modifier mask associated with the specified keyboard
|
/* Return the modifier mask associated with the specified keyboard
|
||||||
input EVENT. Replace bits corresponding to Left or Right keys
|
input EVENT. Replace bits representing Left or Right keys with
|
||||||
with their corresponding general modifier bits. */
|
their corresponding general modifier bits. */
|
||||||
|
|
||||||
public static int
|
public static int
|
||||||
eventModifiers (KeyEvent event)
|
eventModifiers (KeyEvent event)
|
||||||
|
|
@ -642,7 +642,7 @@ public final class EmacsWindow extends EmacsHandleObject
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||||
state = event.getModifiers ();
|
state = KeyEvent.normalizeMetaState (event.getMetaState ());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Replace this with getMetaState and manual
|
/* Replace this with getMetaState and manual
|
||||||
|
|
@ -667,10 +667,10 @@ public final class EmacsWindow extends EmacsHandleObject
|
||||||
/* event.getCharacters is used because older input methods still
|
/* event.getCharacters is used because older input methods still
|
||||||
require it. */
|
require it. */
|
||||||
@SuppressWarnings ("deprecation")
|
@SuppressWarnings ("deprecation")
|
||||||
public void
|
public boolean
|
||||||
onKeyDown (int keyCode, KeyEvent event)
|
onKeyDown (int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
int state, state_1, extra_ignored;
|
int state, state_1, extra_ignored, unicode_char;
|
||||||
long serial;
|
long serial;
|
||||||
String characters;
|
String characters;
|
||||||
|
|
||||||
|
|
@ -686,7 +686,7 @@ public final class EmacsWindow extends EmacsHandleObject
|
||||||
Deliver onKeyDown events in onKeyUp instead, so as not to
|
Deliver onKeyDown events in onKeyUp instead, so as not to
|
||||||
navigate backwards during gesture navigation. */
|
navigate backwards during gesture navigation. */
|
||||||
|
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
state = eventModifiers (event);
|
state = eventModifiers (event);
|
||||||
|
|
@ -720,23 +720,36 @@ public final class EmacsWindow extends EmacsHandleObject
|
||||||
state &= ~KeyEvent.META_ALT_MASK;
|
state &= ~KeyEvent.META_ALT_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unicode_char = getEventUnicodeChar (event, state_1);
|
||||||
|
|
||||||
|
/* If a NUMPAD_ key is detected for which no character is returned,
|
||||||
|
return false without sending the key event, as this will prompt
|
||||||
|
the system to send an event with the corresponding action
|
||||||
|
key. */
|
||||||
|
|
||||||
|
if (keyCode >= KeyEvent.KEYCODE_NUMPAD_0
|
||||||
|
&& keyCode <= KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN
|
||||||
|
&& unicode_char == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
synchronized (eventStrings)
|
synchronized (eventStrings)
|
||||||
{
|
{
|
||||||
serial
|
serial
|
||||||
= EmacsNative.sendKeyPress (this.handle,
|
= EmacsNative.sendKeyPress (this.handle,
|
||||||
event.getEventTime (),
|
event.getEventTime (),
|
||||||
state, keyCode,
|
state, keyCode,
|
||||||
getEventUnicodeChar (event,
|
unicode_char);
|
||||||
state_1));
|
|
||||||
|
|
||||||
characters = event.getCharacters ();
|
characters = event.getCharacters ();
|
||||||
|
|
||||||
if (characters != null && characters.length () > 1)
|
if (characters != null && characters.length () > 1)
|
||||||
saveUnicodeString ((int) serial, characters);
|
saveUnicodeString ((int) serial, characters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void
|
public boolean
|
||||||
onKeyUp (int keyCode, KeyEvent event)
|
onKeyUp (int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
int state, state_1, unicode_char, extra_ignored;
|
int state, state_1, unicode_char, extra_ignored;
|
||||||
|
|
@ -781,12 +794,20 @@ public final class EmacsWindow extends EmacsHandleObject
|
||||||
/* If the key press's been canceled, return immediately. */
|
/* If the key press's been canceled, return immediately. */
|
||||||
|
|
||||||
if ((event.getFlags () & KeyEvent.FLAG_CANCELED) != 0)
|
if ((event.getFlags () & KeyEvent.FLAG_CANCELED) != 0)
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
/* Dispatch the key press event that was deferred till now. */
|
/* Dispatch the key press event that was deferred till now. */
|
||||||
EmacsNative.sendKeyPress (this.handle, event.getEventTime (),
|
EmacsNative.sendKeyPress (this.handle, event.getEventTime (),
|
||||||
state, keyCode, unicode_char);
|
state, keyCode, unicode_char);
|
||||||
}
|
}
|
||||||
|
/* If a NUMPAD_ key is detected for which no character is returned,
|
||||||
|
return false without sending the key event, as this will prompt
|
||||||
|
the system to send an event with the corresponding action
|
||||||
|
key. */
|
||||||
|
else if (keyCode >= KeyEvent.KEYCODE_NUMPAD_0
|
||||||
|
&& keyCode <= KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN
|
||||||
|
&& unicode_char == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
EmacsNative.sendKeyRelease (this.handle, event.getEventTime (),
|
EmacsNative.sendKeyRelease (this.handle, event.getEventTime (),
|
||||||
state, keyCode, unicode_char);
|
state, keyCode, unicode_char);
|
||||||
|
|
@ -804,6 +825,8 @@ public final class EmacsWindow extends EmacsHandleObject
|
||||||
|
|
||||||
lastQuitKeyRelease = time;
|
lastQuitKeyRelease = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void
|
public void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue