mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 05:10:49 +00:00
Bug 935821 - Part 4. GTK implementation. r=masayuki
This commit is contained in:
parent
6e15ab90e6
commit
c26175dc57
@ -68,6 +68,7 @@ nsGtkIMModule::nsGtkIMModule(nsWindow* aOwnerWindow) :
|
||||
mSimpleContext(nullptr),
|
||||
mDummyContext(nullptr),
|
||||
mCompositionStart(UINT32_MAX), mProcessingKeyEvent(nullptr),
|
||||
mCompositionTargetOffset(UINT32_MAX),
|
||||
mCompositionState(eCompositionState_NotComposing),
|
||||
mIsIMFocused(false), mIgnoreNativeCompositionEvent(false)
|
||||
{
|
||||
@ -502,6 +503,16 @@ nsGtkIMModule::CancelIMEComposition(nsWindow* aCaller)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsGtkIMModule::OnUpdateComposition(void)
|
||||
{
|
||||
if (MOZ_UNLIKELY(IsDestroyed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetCursorPosition(mCompositionTargetOffset);
|
||||
}
|
||||
|
||||
void
|
||||
nsGtkIMModule::SetInputContext(nsWindow* aCaller,
|
||||
const InputContext* aContext,
|
||||
@ -682,7 +693,7 @@ nsGtkIMModule::OnStartCompositionNative(GtkIMContext *aContext)
|
||||
if (!DispatchCompositionStart()) {
|
||||
return;
|
||||
}
|
||||
SetCursorPosition(mCompositionStart);
|
||||
mCompositionTargetOffset = mCompositionStart;
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -1049,6 +1060,7 @@ nsGtkIMModule::DispatchCompositionEnd()
|
||||
mLastFocusedWindow->DispatchEvent(&compEvent, status);
|
||||
mCompositionState = eCompositionState_NotComposing;
|
||||
mCompositionStart = UINT32_MAX;
|
||||
mCompositionTargetOffset = UINT32_MAX;
|
||||
mDispatchedCompositionString.Truncate();
|
||||
if (static_cast<nsWindow*>(kungFuDeathGrip.get())->IsDestroyed() ||
|
||||
kungFuDeathGrip != mLastFocusedWindow) {
|
||||
@ -1151,7 +1163,10 @@ nsGtkIMModule::DispatchTextEvent(const nsAString &aCompositionString,
|
||||
return false;
|
||||
}
|
||||
|
||||
SetCursorPosition(targetOffset);
|
||||
// We cannot call SetCursorPosition for e10s-aware.
|
||||
// DispatchEvent is async on e10s, so composition rect isn't updated now
|
||||
// on tab parent.
|
||||
mCompositionTargetOffset = targetOffset;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
const InputContextAction* aAction);
|
||||
InputContext GetInputContext();
|
||||
nsresult CancelIMEComposition(nsWindow* aCaller);
|
||||
void OnUpdateComposition();
|
||||
|
||||
// If a software keyboard has been opened, this returns TRUE.
|
||||
// Otherwise, FALSE.
|
||||
@ -137,6 +138,9 @@ protected:
|
||||
// event.
|
||||
GdkEventKey* mProcessingKeyEvent;
|
||||
|
||||
// current target offset of IME composition
|
||||
uint32_t mCompositionTargetOffset;
|
||||
|
||||
// mCompositionState indicates current status of composition.
|
||||
enum eCompositionState {
|
||||
eCompositionState_NotComposing,
|
||||
|
@ -5877,6 +5877,9 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
||||
case NOTIFY_IME_OF_BLUR:
|
||||
mIMModule->OnFocusChangeInGecko(false);
|
||||
return NS_OK;
|
||||
case NOTIFY_IME_OF_COMPOSITION_UPDATE:
|
||||
mIMModule->OnUpdateComposition();
|
||||
return NS_OK;
|
||||
default:
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user