Bug 853819 - Use focused window to process SetInputContext and GetInputContext. r=cpeterson

This commit is contained in:
Jim Chen
2013-03-27 11:32:34 -04:00
parent 3f4d9bd235
commit 1dcaf7ccff

View File

@@ -2020,6 +2020,16 @@ NS_IMETHODIMP_(void)
nsWindow::SetInputContext(const InputContext& aContext,
const InputContextAction& aAction)
{
nsWindow *top = TopWindow();
if (top && top->mFocus && this != top->mFocus) {
// We are using an IME event later to notify Java, and the IME event
// will be processed by the focused window. Therefore, to ensure the
// IME event uses the correct mInputContext, we need to let the focused
// window process SetInputContext
top->mFocus->SetInputContext(aContext, aAction);
return;
}
ALOGIME("IME: SetInputContext: s=0x%X, 0x%X, action=0x%X, 0x%X",
aContext.mIMEState.mEnabled, aContext.mIMEState.mOpen,
aAction.mCause, aAction.mFocusChange);
@@ -2060,10 +2070,17 @@ nsWindow::SetInputContext(const InputContext& aContext,
NS_IMETHODIMP_(InputContext)
nsWindow::GetInputContext()
{
mInputContext.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
nsWindow *top = TopWindow();
if (top && top->mFocus && this != top->mFocus) {
// We let the focused window process SetInputContext,
// so we should let it process GetInputContext as well.
return top->mFocus->GetInputContext();
}
InputContext context = mInputContext;
context.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
// We assume that there is only one context per process on Android
mInputContext.mNativeIMEContext = nullptr;
return mInputContext;
context.mNativeIMEContext = nullptr;
return context;
}
void