Bug 706336 - Use meta states from KeyListener; r=cpeterson

This commit is contained in:
Jim Chen 2013-03-19 18:26:33 -04:00
parent 7c176ffc62
commit 47e557c907
2 changed files with 11 additions and 6 deletions

View File

@ -184,9 +184,9 @@ public class GeckoEvent {
return new GeckoEvent(NOOP);
}
public static GeckoEvent createKeyEvent(KeyEvent k) {
public static GeckoEvent createKeyEvent(KeyEvent k, int metaState) {
GeckoEvent event = new GeckoEvent(KEY_EVENT);
event.initKeyEvent(k);
event.initKeyEvent(k, metaState);
return event;
}
@ -198,10 +198,14 @@ public class GeckoEvent {
return new GeckoEvent(COMPOSITOR_RESUME);
}
private void initKeyEvent(KeyEvent k) {
private void initKeyEvent(KeyEvent k, int metaState) {
mAction = k.getAction();
mTime = k.getEventTime();
mMetaState = k.getMetaState();
// Normally we expect k.getMetaState() to reflect the current meta-state; however,
// some software-generated key events may not have k.getMetaState() set, e.g. key
// events from Swype. Therefore, it's necessary to combine the key's meta-states
// with the meta-states that we keep separately in KeyListener
mMetaState = k.getMetaState() | metaState;
mFlags = k.getFlags();
mKeyCode = k.getKeyCode();
mUnicodeChar = k.getUnicodeChar();

View File

@ -716,7 +716,7 @@ class GeckoInputConnection
View view = getView();
if (view == null) {
mEditableClient.sendEvent(GeckoEvent.createKeyEvent(event));
mEditableClient.sendEvent(GeckoEvent.createKeyEvent(event, 0));
return true;
}
@ -731,7 +731,8 @@ class GeckoInputConnection
if (skip ||
(down && !keyListener.onKeyDown(view, uiEditable, keyCode, event)) ||
(!down && !keyListener.onKeyUp(view, uiEditable, keyCode, event))) {
mEditableClient.sendEvent(GeckoEvent.createKeyEvent(event));
mEditableClient.sendEvent(
GeckoEvent.createKeyEvent(event, TextKeyListener.getMetaState(uiEditable)));
if (skip && down) {
// Usually, the down key listener call above adjusts meta states for us.
// However, if we skip that call above, we have to manually adjust meta