Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java |
| index 5b8e505c0ef47f03b35ce9a194aeb08f604ac060..e72e8309a8ba4310f46ccc2da83edb31750cf48b 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java |
| @@ -338,7 +338,12 @@ public class ImeAdapter { |
| } |
| public boolean dispatchKeyEvent(KeyEvent event) { |
| - return translateAndSendNativeEvents(event); |
| + // Physical keyboards have their events come through here instead of |
| + // AdapterInputConnection. |
| + if (mInputConnection != null) { |
| + return mInputConnection.sendKeyEvent(event); |
| + } |
| + return translateAndSendNativeEvents(event, 0); |
| } |
| private int shouldSendKeyEventWithKeyCode(String text) { |
| @@ -407,11 +412,11 @@ public class ImeAdapter { |
| translateAndSendNativeEvents(new KeyEvent(eventTime, eventTime, |
| KeyEvent.ACTION_DOWN, keyCode, 0, 0, |
| KeyCharacterMap.VIRTUAL_KEYBOARD, 0, |
| - flags)); |
| + flags), 0); |
| translateAndSendNativeEvents(new KeyEvent(SystemClock.uptimeMillis(), eventTime, |
| KeyEvent.ACTION_UP, keyCode, 0, 0, |
| KeyCharacterMap.VIRTUAL_KEYBOARD, 0, |
| - flags)); |
| + flags), 0); |
| } |
| // Calls from Java to C++ |
| @@ -446,9 +451,9 @@ public class ImeAdapter { |
| // composition below. |
| if (keyCode > 0 && isCommit && mLastComposeText == null) { |
| mLastSyntheticKeyCode = keyCode; |
| - return translateAndSendNativeEvents(keyEvent) |
| + return translateAndSendNativeEvents(keyEvent, 0) |
| && translateAndSendNativeEvents( |
| - KeyEvent.changeAction(keyEvent, KeyEvent.ACTION_UP)); |
| + KeyEvent.changeAction(keyEvent, KeyEvent.ACTION_UP), 0); |
| } |
| // When typing, there is no issue sending KeyDown and KeyUp events around the |
| @@ -499,7 +504,7 @@ public class ImeAdapter { |
| nativeFinishComposingText(mNativeImeAdapterAndroid); |
| } |
| - boolean translateAndSendNativeEvents(KeyEvent event) { |
| + boolean translateAndSendNativeEvents(KeyEvent event, int accentChar) { |
| if (mNativeImeAdapterAndroid == 0) return false; |
| int action = event.getAction(); |
| @@ -517,9 +522,16 @@ public class ImeAdapter { |
| return false; |
| } |
| mViewEmbedder.onImeEvent(); |
| + int unichar = event.getUnicodeChar(); |
|
Ted C
2014/12/03 02:30:14
The other file called them unicodeChar, so I would
bcwhite
2014/12/03 15:49:09
Done.
|
| + if (accentChar != 0) { |
| + int combined = KeyCharacterMap.getDeadChar(accentChar, unichar); |
|
Ted C
2014/12/03 02:30:14
Any reason to use KeyCharacterMap instead of KeyEv
bcwhite
2014/12/03 15:49:10
Not particularly. I was typing both names in diff
|
| + if (combined != 0) { |
| + unichar = combined; |
| + } |
| + } |
| return nativeSendKeyEvent(mNativeImeAdapterAndroid, event, event.getAction(), |
| getModifiers(event.getMetaState()), event.getEventTime(), event.getKeyCode(), |
| - /*isSystemKey=*/false, event.getUnicodeChar()); |
| + /*isSystemKey=*/false, unichar); |
| } |
| boolean sendSyntheticKeyEvent(int eventType, long timestampMs, int keyCode, int modifiers, |