mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 932168 Use simple IME context when focus field has focus (partially backing out a patch for bug 906072) r=karlt
This commit is contained in:
parent
c3d8e2ffd8
commit
5990ca0978
@ -65,6 +65,7 @@ nsGtkIMModule* nsGtkIMModule::sLastFocusedModule = nullptr;
|
||||
nsGtkIMModule::nsGtkIMModule(nsWindow* aOwnerWindow) :
|
||||
mOwnerWindow(aOwnerWindow), mLastFocusedWindow(nullptr),
|
||||
mContext(nullptr),
|
||||
mSimpleContext(nullptr),
|
||||
mDummyContext(nullptr),
|
||||
mCompositionStart(UINT32_MAX), mProcessingKeyEvent(nullptr),
|
||||
mCompositionState(eCompositionState_NotComposing),
|
||||
@ -114,6 +115,28 @@ nsGtkIMModule::Init()
|
||||
G_CALLBACK(nsGtkIMModule::OnEndCompositionCallback),
|
||||
this);
|
||||
|
||||
// Simple context
|
||||
mSimpleContext = gtk_im_context_simple_new();
|
||||
gtk_im_context_set_client_window(mSimpleContext, gdkWindow);
|
||||
g_signal_connect(mSimpleContext, "preedit_changed",
|
||||
G_CALLBACK(&nsGtkIMModule::OnChangeCompositionCallback),
|
||||
this);
|
||||
g_signal_connect(mSimpleContext, "retrieve_surrounding",
|
||||
G_CALLBACK(&nsGtkIMModule::OnRetrieveSurroundingCallback),
|
||||
this);
|
||||
g_signal_connect(mSimpleContext, "delete_surrounding",
|
||||
G_CALLBACK(&nsGtkIMModule::OnDeleteSurroundingCallback),
|
||||
this);
|
||||
g_signal_connect(mSimpleContext, "commit",
|
||||
G_CALLBACK(&nsGtkIMModule::OnCommitCompositionCallback),
|
||||
this);
|
||||
g_signal_connect(mSimpleContext, "preedit_start",
|
||||
G_CALLBACK(nsGtkIMModule::OnStartCompositionCallback),
|
||||
this);
|
||||
g_signal_connect(mSimpleContext, "preedit_end",
|
||||
G_CALLBACK(nsGtkIMModule::OnEndCompositionCallback),
|
||||
this);
|
||||
|
||||
// Dummy context
|
||||
mDummyContext = gtk_im_multicontext_new();
|
||||
gtk_im_context_set_client_window(mDummyContext, gdkWindow);
|
||||
@ -168,6 +191,12 @@ nsGtkIMModule::OnDestroyWindow(nsWindow* aWindow)
|
||||
mContext = nullptr;
|
||||
}
|
||||
|
||||
if (mSimpleContext) {
|
||||
gtk_im_context_set_client_window(mSimpleContext, nullptr);
|
||||
g_object_unref(mSimpleContext);
|
||||
mSimpleContext = nullptr;
|
||||
}
|
||||
|
||||
if (mDummyContext) {
|
||||
// mContext and mDummyContext have the same slaveType and signal_data
|
||||
// so no need for another workaround_gtk_im_display_closed.
|
||||
@ -548,7 +577,9 @@ nsGtkIMModule::GetContext()
|
||||
if (IsEnabled()) {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
if (mInputContext.mIMEState.mEnabled == IMEState::PASSWORD) {
|
||||
return mSimpleContext;
|
||||
}
|
||||
return mDummyContext;
|
||||
}
|
||||
|
||||
@ -556,7 +587,6 @@ bool
|
||||
nsGtkIMModule::IsEnabled()
|
||||
{
|
||||
return mInputContext.mIMEState.mEnabled == IMEState::ENABLED ||
|
||||
mInputContext.mIMEState.mEnabled == IMEState::PASSWORD ||
|
||||
mInputContext.mIMEState.mEnabled == IMEState::PLUGIN;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user