mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 819073 - Set InputConnection during each focus notification; r=cpeterson
This commit is contained in:
parent
7d1ac71bab
commit
c80915d4b8
@ -569,10 +569,7 @@ public class GeckoAppShell
|
||||
|
||||
// Called on the UI thread after Gecko loads.
|
||||
private static void geckoLoaded() {
|
||||
LayerView v = GeckoApp.mAppContext.getLayerView();
|
||||
GeckoEditable editable = new GeckoEditable();
|
||||
InputConnectionHandler ich = GeckoInputConnection.create(v, editable);
|
||||
v.setInputConnectionHandler(ich);
|
||||
// install the gecko => editable listener
|
||||
mEditableListener = editable;
|
||||
}
|
||||
|
@ -5,6 +5,9 @@
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.gfx.InputConnectionHandler;
|
||||
import org.mozilla.gecko.gfx.LayerView;
|
||||
|
||||
import android.os.Build;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
@ -30,7 +33,6 @@ interface GeckoEditableClient {
|
||||
void sendEvent(GeckoEvent event);
|
||||
Editable getEditable();
|
||||
void setUpdateGecko(boolean update);
|
||||
void setListener(GeckoEditableListener listener);
|
||||
}
|
||||
|
||||
/* interface for the Editable to listen to the Gecko thread
|
||||
@ -75,7 +77,7 @@ final class GeckoEditable
|
||||
private final SpannableStringBuilder mText;
|
||||
private final SpannableStringBuilder mChangedText;
|
||||
private final Editable mProxy;
|
||||
private GeckoEditableListener mListener;
|
||||
private final GeckoEditableListener mListener;
|
||||
private final ActionQueue mActionQueue;
|
||||
|
||||
private int mSavedSelectionStart;
|
||||
@ -253,6 +255,9 @@ final class GeckoEditable
|
||||
mProxy = (Editable)Proxy.newProxyInstance(
|
||||
Editable.class.getClassLoader(),
|
||||
PROXY_INTERFACES, this);
|
||||
|
||||
LayerView v = GeckoApp.mAppContext.getLayerView();
|
||||
mListener = GeckoInputConnection.create(v, this);
|
||||
}
|
||||
|
||||
private static void geckoPostToUI(Runnable runnable) {
|
||||
@ -453,15 +458,6 @@ final class GeckoEditable
|
||||
mUpdateGecko = update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(GeckoEditableListener listener) {
|
||||
if (DEBUG) {
|
||||
// GeckoEditableClient methods should all be called from the UI thread
|
||||
GeckoApp.assertOnUiThread();
|
||||
}
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
// GeckoEditableListener interface
|
||||
|
||||
void geckoActionReply() {
|
||||
@ -490,8 +486,7 @@ final class GeckoEditable
|
||||
mActionQueue.syncWithGecko();
|
||||
final int start = Selection.getSelectionStart(mText);
|
||||
final int end = Selection.getSelectionEnd(mText);
|
||||
if (mListener != null &&
|
||||
selStart == start && selEnd == end) {
|
||||
if (selStart == start && selEnd == end) {
|
||||
// There has not been another new selection in the mean time that
|
||||
// made this notification out-of-date
|
||||
mListener.onSelectionChange(start, end);
|
||||
@ -528,14 +523,14 @@ final class GeckoEditable
|
||||
mFocused = false;
|
||||
} else {
|
||||
mFocused = true;
|
||||
LayerView v = GeckoApp.mAppContext.getLayerView();
|
||||
v.setInputConnectionHandler((InputConnectionHandler)mListener);
|
||||
// Unmask events on the Gecko side
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEEvent(
|
||||
GeckoEvent.IME_ACKNOWLEDGE_FOCUS));
|
||||
}
|
||||
}
|
||||
if (mListener != null) {
|
||||
mListener.notifyIME(type, state);
|
||||
}
|
||||
mListener.notifyIME(type, state);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -551,10 +546,8 @@ final class GeckoEditable
|
||||
public void run() {
|
||||
// Make sure there are no other things going on
|
||||
mActionQueue.syncWithGecko();
|
||||
if (mListener != null) {
|
||||
mListener.notifyIMEEnabled(state, typeHint,
|
||||
modeHint, actionHint);
|
||||
}
|
||||
mListener.notifyIMEEnabled(state, typeHint,
|
||||
modeHint, actionHint);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -678,9 +671,7 @@ final class GeckoEditable
|
||||
}
|
||||
geckoPostToUI(new Runnable() {
|
||||
public void run() {
|
||||
if (mListener != null) {
|
||||
mListener.onTextChange(text, start, oldEnd, newEnd);
|
||||
}
|
||||
mListener.onTextChange(text, start, oldEnd, newEnd);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ class GeckoInputConnection
|
||||
private boolean mBatchSelectionChanged;
|
||||
private boolean mBatchTextChanged;
|
||||
|
||||
public static InputConnectionHandler create(View targetView,
|
||||
GeckoEditableClient editable) {
|
||||
public static GeckoEditableListener create(View targetView,
|
||||
GeckoEditableClient editable) {
|
||||
if (DEBUG)
|
||||
return DebugGeckoInputConnection.create(targetView, editable);
|
||||
else
|
||||
@ -65,8 +65,6 @@ class GeckoInputConnection
|
||||
GeckoEditableClient editable) {
|
||||
super(targetView, true);
|
||||
mEditableClient = editable;
|
||||
// install the editable => input connection listener
|
||||
editable.setListener(this);
|
||||
mIMEState = IME_STATE_DISABLED;
|
||||
}
|
||||
|
||||
@ -531,8 +529,8 @@ final class DebugGeckoInputConnection
|
||||
super(targetView, editable);
|
||||
}
|
||||
|
||||
public static InputConnectionHandler create(View targetView,
|
||||
GeckoEditableClient editable) {
|
||||
public static GeckoEditableListener create(View targetView,
|
||||
GeckoEditableClient editable) {
|
||||
final Class[] PROXY_INTERFACES = { InputConnection.class,
|
||||
InputConnectionHandler.class,
|
||||
GeckoEditableListener.class };
|
||||
@ -541,8 +539,7 @@ final class DebugGeckoInputConnection
|
||||
dgic.mProxy = (InputConnection)Proxy.newProxyInstance(
|
||||
GeckoInputConnection.class.getClassLoader(),
|
||||
PROXY_INTERFACES, dgic);
|
||||
editable.setListener((GeckoEditableListener)dgic.mProxy);
|
||||
return (InputConnectionHandler)dgic.mProxy;
|
||||
return (GeckoEditableListener)dgic.mProxy;
|
||||
}
|
||||
|
||||
private static StringBuilder debugAppend(StringBuilder sb, Object obj) {
|
||||
|
Loading…
Reference in New Issue
Block a user