mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 847823 - Clean up NotifyIME to use the Gecko NotificationToIME enum; r=cpeterson
This commit is contained in:
parent
4dcc8f5775
commit
0f7d10cf4b
@ -321,9 +321,9 @@ public class GeckoAppShell
|
||||
/*
|
||||
* The Gecko-side API: API methods that Gecko calls
|
||||
*/
|
||||
public static void notifyIME(int type, int state) {
|
||||
public static void notifyIME(int type) {
|
||||
if (mEditableListener != null) {
|
||||
mEditableListener.notifyIME(type, state);
|
||||
mEditableListener.notifyIME(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,21 +44,19 @@ interface GeckoEditableClient {
|
||||
/* interface for the Editable to listen to the Gecko thread
|
||||
and also for the IC thread to listen to the Editable */
|
||||
interface GeckoEditableListener {
|
||||
// IME notification type for notifyIME()
|
||||
final int NOTIFY_IME_RESETINPUTSTATE = 0;
|
||||
final int NOTIFY_IME_REPLY_EVENT = 1;
|
||||
final int NOTIFY_IME_CANCELCOMPOSITION = 2;
|
||||
final int NOTIFY_IME_FOCUSCHANGE = 3;
|
||||
// IME focus state for notifyIME(NOTIFY_IME_FOCUSCHANGE, ..)
|
||||
final int IME_FOCUS_STATE_FOCUS = 1;
|
||||
final int IME_FOCUS_STATE_BLUR = 0;
|
||||
// IME notification type for notifyIME(), corresponding to NotificationToIME enum in Gecko
|
||||
final int NOTIFY_IME_REPLY_EVENT = -1;
|
||||
final int NOTIFY_IME_OF_FOCUS = 1;
|
||||
final int NOTIFY_IME_OF_BLUR = 2;
|
||||
final int NOTIFY_IME_TO_COMMIT_COMPOSITION = 4;
|
||||
final int NOTIFY_IME_TO_CANCEL_COMPOSITION = 5;
|
||||
// IME enabled state for notifyIMEContext()
|
||||
final int IME_STATE_DISABLED = 0;
|
||||
final int IME_STATE_ENABLED = 1;
|
||||
final int IME_STATE_PASSWORD = 2;
|
||||
final int IME_STATE_PLUGIN = 3;
|
||||
|
||||
void notifyIME(int type, int state);
|
||||
void notifyIME(int type);
|
||||
void notifyIMEContext(int state, String typeHint,
|
||||
String modeHint, String actionHint);
|
||||
void onSelectionChange(int start, int end);
|
||||
@ -648,7 +646,7 @@ final class GeckoEditable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyIME(final int type, final int state) {
|
||||
public void notifyIME(final int type) {
|
||||
if (DEBUG) {
|
||||
// GeckoEditableListener methods should all be called from the Gecko thread
|
||||
ThreadUtils.assertOnGeckoThread();
|
||||
@ -656,7 +654,7 @@ final class GeckoEditable
|
||||
if (type != NOTIFY_IME_REPLY_EVENT) {
|
||||
Log.d(LOGTAG, "notifyIME(" +
|
||||
getConstantName(GeckoEditableListener.class, "NOTIFY_IME_", type) +
|
||||
", " + state + ")");
|
||||
")");
|
||||
}
|
||||
}
|
||||
if (type == NOTIFY_IME_REPLY_EVENT) {
|
||||
@ -678,20 +676,18 @@ final class GeckoEditable
|
||||
geckoPostToIc(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (type == NOTIFY_IME_FOCUSCHANGE) {
|
||||
if (state == IME_FOCUS_STATE_BLUR) {
|
||||
mFocused = false;
|
||||
} else {
|
||||
mFocused = true;
|
||||
// Unmask events on the Gecko side
|
||||
mActionQueue.offer(new Action(Action.TYPE_ACKNOWLEDGE_FOCUS));
|
||||
}
|
||||
if (type == NOTIFY_IME_OF_BLUR) {
|
||||
mFocused = false;
|
||||
} else if (type == NOTIFY_IME_OF_FOCUS) {
|
||||
mFocused = true;
|
||||
// Unmask events on the Gecko side
|
||||
mActionQueue.offer(new Action(Action.TYPE_ACKNOWLEDGE_FOCUS));
|
||||
}
|
||||
// Make sure there are no other things going on. If we sent
|
||||
// GeckoEvent.IME_ACKNOWLEDGE_FOCUS, this line also makes us
|
||||
// wait for Gecko to update us on the newly focused content
|
||||
mActionQueue.syncWithGecko();
|
||||
mListener.notifyIME(type, state);
|
||||
mListener.notifyIME(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -790,21 +790,22 @@ class GeckoInputConnection
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyIME(final int type, final int state) {
|
||||
public void notifyIME(int type) {
|
||||
switch (type) {
|
||||
|
||||
case NOTIFY_IME_CANCELCOMPOSITION:
|
||||
case NOTIFY_IME_TO_CANCEL_COMPOSITION:
|
||||
// Set composition to empty and end composition
|
||||
setComposingText("", 0);
|
||||
// Fall through
|
||||
|
||||
case NOTIFY_IME_RESETINPUTSTATE:
|
||||
case NOTIFY_IME_TO_COMMIT_COMPOSITION:
|
||||
// Commit and end composition
|
||||
finishComposingText();
|
||||
tryRestartInput();
|
||||
break;
|
||||
|
||||
case NOTIFY_IME_FOCUSCHANGE:
|
||||
case NOTIFY_IME_OF_FOCUS:
|
||||
case NOTIFY_IME_OF_BLUR:
|
||||
// Showing/hiding vkb is done in notifyIMEContext
|
||||
resetInputConnection();
|
||||
break;
|
||||
|
@ -102,7 +102,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
|
||||
jclass jAndroidSmsMessageClass = jEnv->FindClass("android/telephony/SmsMessage");
|
||||
mAndroidSmsMessageClass = (jclass) jEnv->NewGlobalRef(jAndroidSmsMessageClass);
|
||||
|
||||
jNotifyIME = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIME", "(II)V");
|
||||
jNotifyIME = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIME", "(I)V");
|
||||
jNotifyIMEContext = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIMEContext", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
jNotifyIMEChange = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIMEChange", "(Ljava/lang/String;III)V");
|
||||
jAcknowledgeEvent = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "acknowledgeEvent", "()V");
|
||||
@ -249,7 +249,7 @@ AndroidBridge::SetMainThread(void *thr)
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::NotifyIME(int aType, int aState)
|
||||
AndroidBridge::NotifyIME(int aType)
|
||||
{
|
||||
ALOG_BRIDGE("AndroidBridge::NotifyIME");
|
||||
|
||||
@ -259,7 +259,7 @@ AndroidBridge::NotifyIME(int aType, int aState)
|
||||
|
||||
AutoLocalJNIFrame jniFrame(env, 0);
|
||||
env->CallStaticVoidMethod(sBridge->mGeckoAppShellClass,
|
||||
sBridge->jNotifyIME, aType, aState);
|
||||
sBridge->jNotifyIME, aType);
|
||||
}
|
||||
|
||||
jstring NewJavaString(AutoLocalJNIFrame* frame, const PRUnichar* string, uint32_t len) {
|
||||
|
@ -103,10 +103,9 @@ class AndroidBridge
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
NOTIFY_IME_RESETINPUTSTATE = 0,
|
||||
NOTIFY_IME_REPLY_EVENT = 1,
|
||||
NOTIFY_IME_CANCELCOMPOSITION = 2,
|
||||
NOTIFY_IME_FOCUSCHANGE = 3
|
||||
// Values for NotifyIME, in addition to values from the Gecko
|
||||
// NotificationToIME enum; use negative values here to prevent conflict
|
||||
NOTIFY_IME_REPLY_EVENT = -1,
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -152,7 +151,7 @@ public:
|
||||
bool SetMainThread(void *thr);
|
||||
|
||||
/* These are all implemented in Java */
|
||||
static void NotifyIME(int aType, int aState);
|
||||
static void NotifyIME(int aType);
|
||||
|
||||
static void NotifyIMEContext(int aState, const nsAString& aTypeHint,
|
||||
const nsAString& aModeHint, const nsAString& aActionHint);
|
||||
|
@ -1715,7 +1715,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
NotifyIMEOfTextChange(0, INT32_MAX / 2, INT32_MAX / 2);
|
||||
FlushIMEChanges();
|
||||
}
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT, 0);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
return;
|
||||
} else if (ae->Action() == AndroidGeckoEvent::IME_UPDATE_CONTEXT) {
|
||||
AndroidBridge::NotifyIMEContext(mInputContext.mIMEState.mEnabled,
|
||||
@ -1729,7 +1729,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
// Still reply to events, but don't do anything else
|
||||
if (ae->Action() == AndroidGeckoEvent::IME_SYNCHRONIZE ||
|
||||
ae->Action() == AndroidGeckoEvent::IME_REPLACE_TEXT) {
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT, 0);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1742,7 +1742,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
case AndroidGeckoEvent::IME_SYNCHRONIZE:
|
||||
{
|
||||
FlushIMEChanges();
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT, 0);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
}
|
||||
break;
|
||||
case AndroidGeckoEvent::IME_REPLACE_TEXT:
|
||||
@ -1785,7 +1785,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
DispatchEvent(&event);
|
||||
}
|
||||
FlushIMEChanges();
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT, 0);
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
}
|
||||
break;
|
||||
case AndroidGeckoEvent::IME_SET_SELECTION:
|
||||
@ -1962,8 +1962,7 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
||||
case REQUEST_TO_COMMIT_COMPOSITION:
|
||||
//ALOGIME("IME: REQUEST_TO_COMMIT_COMPOSITION: s=%d", aState);
|
||||
RemoveIMEComposition();
|
||||
AndroidBridge::NotifyIME(
|
||||
AndroidBridge::NOTIFY_IME_RESETINPUTSTATE, 0);
|
||||
AndroidBridge::NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
|
||||
return NS_OK;
|
||||
case REQUEST_TO_CANCEL_COMPOSITION:
|
||||
ALOGIME("IME: REQUEST_TO_CANCEL_COMPOSITION");
|
||||
@ -1981,12 +1980,11 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
||||
DispatchEvent(&compEvent);
|
||||
}
|
||||
|
||||
AndroidBridge::NotifyIME(
|
||||
AndroidBridge::NOTIFY_IME_CANCELCOMPOSITION, 0);
|
||||
AndroidBridge::NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);
|
||||
return NS_OK;
|
||||
case NOTIFY_IME_OF_FOCUS:
|
||||
ALOGIME("IME: NOTIFY_IME_OF_FOCUS");
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_FOCUSCHANGE, 1);
|
||||
AndroidBridge::NotifyIME(NOTIFY_IME_OF_FOCUS);
|
||||
return NS_OK;
|
||||
case NOTIFY_IME_OF_BLUR:
|
||||
ALOGIME("IME: NOTIFY_IME_OF_BLUR");
|
||||
@ -1998,7 +1996,7 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
||||
mIMEComposing = false;
|
||||
mIMEComposingText.Truncate();
|
||||
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_FOCUSCHANGE, 0);
|
||||
AndroidBridge::NotifyIME(NOTIFY_IME_OF_BLUR);
|
||||
return NS_OK;
|
||||
case NOTIFY_IME_OF_SELECTION_CHANGE:
|
||||
if (mIMEMaskSelectionUpdate) {
|
||||
|
Loading…
Reference in New Issue
Block a user