зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset e226de7caa88 (bug 1444572) for conflicts while backing out 1443421
This commit is contained in:
Родитель
660c2297f3
Коммит
b10a3945a4
|
@ -4558,13 +4558,6 @@ pref("mousewheel.system_scroll_override_on_root_content.enabled", false);
|
||||||
|
|
||||||
pref("intl.ime.use_simple_context_on_password_field", false);
|
pref("intl.ime.use_simple_context_on_password_field", false);
|
||||||
|
|
||||||
// uim may use key snooper to listen to key events. Unfortunately, we cannot
|
|
||||||
// know whether it uses or not since it's a build option. So, we need to make
|
|
||||||
// distribution switchable whether we think uim uses key snooper or not with
|
|
||||||
// this pref. Debian 9.x still uses uim as their default IM and it uses key
|
|
||||||
// snooper. So, let's use true for its default value.
|
|
||||||
pref("intl.ime.hack.uim.using_key_snooper", true);
|
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_GTK
|
#ifdef MOZ_WIDGET_GTK
|
||||||
// maximum number of fonts to substitute for a generic
|
// maximum number of fonts to substitute for a generic
|
||||||
pref("gfx.font_rendering.fontconfig.max_generic_substitutions", 3);
|
pref("gfx.font_rendering.fontconfig.max_generic_substitutions", 3);
|
||||||
|
|
|
@ -344,42 +344,21 @@ IMContextWrapper::Init()
|
||||||
if (contextID.EqualsLiteral("ibus")) {
|
if (contextID.EqualsLiteral("ibus")) {
|
||||||
mIMContextID = IMContextID::eIBus;
|
mIMContextID = IMContextID::eIBus;
|
||||||
mIsIMInAsyncKeyHandlingMode = !IsIBusInSyncMode();
|
mIsIMInAsyncKeyHandlingMode = !IsIBusInSyncMode();
|
||||||
// Although ibus has key snooper mode, it's forcibly disabled on Firefox
|
|
||||||
// in default settings by its whitelist since we always send key events
|
|
||||||
// to IME before handling shortcut keys. The whitelist can be
|
|
||||||
// customized with env, IBUS_NO_SNOOPER_APPS, but we don't need to
|
|
||||||
// support such rare cases for reducing maintenance cost.
|
|
||||||
mIsKeySnooped = false;
|
|
||||||
} else if (contextID.EqualsLiteral("fcitx")) {
|
} else if (contextID.EqualsLiteral("fcitx")) {
|
||||||
mIMContextID = IMContextID::eFcitx;
|
mIMContextID = IMContextID::eFcitx;
|
||||||
mIsIMInAsyncKeyHandlingMode = !IsFcitxInSyncMode();
|
mIsIMInAsyncKeyHandlingMode = !IsFcitxInSyncMode();
|
||||||
// Although Fcitx has key snooper mode similar to ibus, it's also
|
|
||||||
// disabled on Firefox in default settings by its whitelist. The
|
|
||||||
// whitelist can be customized with env, IBUS_NO_SNOOPER_APPS or
|
|
||||||
// FCITX_NO_SNOOPER_APPS, but we don't need to support such rare cases
|
|
||||||
// for reducing maintenance cost.
|
|
||||||
mIsKeySnooped = false;
|
|
||||||
} else if (contextID.EqualsLiteral("uim")) {
|
} else if (contextID.EqualsLiteral("uim")) {
|
||||||
mIMContextID = IMContextID::eUim;
|
mIMContextID = IMContextID::eUim;
|
||||||
mIsIMInAsyncKeyHandlingMode = false;
|
mIsIMInAsyncKeyHandlingMode = false;
|
||||||
// We cannot know if uim uses key snooper since it's build option of
|
|
||||||
// uim. Therefore, we need to retrieve the consideration from the
|
|
||||||
// pref for making users and distributions allowed to choose their
|
|
||||||
// preferred value.
|
|
||||||
mIsKeySnooped =
|
|
||||||
Preferences::GetBool("intl.ime.hack.uim.using_key_snooper", true);
|
|
||||||
} else if (contextID.EqualsLiteral("scim")) {
|
} else if (contextID.EqualsLiteral("scim")) {
|
||||||
mIMContextID = IMContextID::eScim;
|
mIMContextID = IMContextID::eScim;
|
||||||
mIsIMInAsyncKeyHandlingMode = false;
|
mIsIMInAsyncKeyHandlingMode = false;
|
||||||
mIsKeySnooped = false;
|
|
||||||
} else if (contextID.EqualsLiteral("iiim")) {
|
} else if (contextID.EqualsLiteral("iiim")) {
|
||||||
mIMContextID = IMContextID::eIIIMF;
|
mIMContextID = IMContextID::eIIIMF;
|
||||||
mIsIMInAsyncKeyHandlingMode = false;
|
mIsIMInAsyncKeyHandlingMode = false;
|
||||||
mIsKeySnooped = false;
|
|
||||||
} else {
|
} else {
|
||||||
mIMContextID = IMContextID::eUnknown;
|
mIMContextID = IMContextID::eUnknown;
|
||||||
mIsIMInAsyncKeyHandlingMode = false;
|
mIsIMInAsyncKeyHandlingMode = false;
|
||||||
mIsKeySnooped = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple context
|
// Simple context
|
||||||
|
@ -412,11 +391,10 @@ IMContextWrapper::Init()
|
||||||
|
|
||||||
MOZ_LOG(gGtkIMLog, LogLevel::Info,
|
MOZ_LOG(gGtkIMLog, LogLevel::Info,
|
||||||
("0x%p Init(), mOwnerWindow=%p, mContext=%p (%s), "
|
("0x%p Init(), mOwnerWindow=%p, mContext=%p (%s), "
|
||||||
"mIsIMInAsyncKeyHandlingMode=%s, mIsKeySnooped=%s, "
|
"mIsIMInAsyncKeyHandlingMode=%s, mSimpleContext=%p, "
|
||||||
"mSimpleContext=%p, mDummyContext=%p",
|
"mDummyContext=%p",
|
||||||
this, mOwnerWindow, mContext, contextID.get(),
|
this, mOwnerWindow, mContext, contextID.get(),
|
||||||
ToChar(mIsIMInAsyncKeyHandlingMode), ToChar(mIsKeySnooped),
|
ToChar(mIsIMInAsyncKeyHandlingMode), mSimpleContext, mDummyContext));
|
||||||
mSimpleContext, mDummyContext));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMContextWrapper::~IMContextWrapper()
|
IMContextWrapper::~IMContextWrapper()
|
||||||
|
@ -822,7 +800,7 @@ IMContextWrapper::OnKeyEvent(nsWindow* aCaller,
|
||||||
// eKeyUp event yet, we need to dispatch here unless the key event is
|
// eKeyUp event yet, we need to dispatch here unless the key event is
|
||||||
// now being handled by other IME process.
|
// now being handled by other IME process.
|
||||||
if (!maybeHandledAsynchronously) {
|
if (!maybeHandledAsynchronously) {
|
||||||
MaybeDispatchKeyEventAsProcessedByIME(eVoidEvent);
|
MaybeDispatchKeyEventAsProcessedByIME();
|
||||||
// Be aware, the widget might have been gone here.
|
// Be aware, the widget might have been gone here.
|
||||||
}
|
}
|
||||||
// If we need to wait reply from IM, IM may send some signals to us
|
// If we need to wait reply from IM, IM may send some signals to us
|
||||||
|
@ -1721,16 +1699,11 @@ IMContextWrapper::GetCompositionString(GtkIMContext* aContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IMContextWrapper::MaybeDispatchKeyEventAsProcessedByIME(
|
IMContextWrapper::MaybeDispatchKeyEventAsProcessedByIME()
|
||||||
EventMessage aFollowingEvent)
|
|
||||||
{
|
{
|
||||||
if (!mLastFocusedWindow) {
|
if ((!mProcessingKeyEvent && mPostingKeyEvents.IsEmpty()) ||
|
||||||
return false;
|
(mProcessingKeyEvent && mKeyboardEventWasDispatched) ||
|
||||||
}
|
!mLastFocusedWindow) {
|
||||||
|
|
||||||
if (!mIsKeySnooped &&
|
|
||||||
((!mProcessingKeyEvent && mPostingKeyEvents.IsEmpty()) ||
|
|
||||||
(mProcessingKeyEvent && mKeyboardEventWasDispatched))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1744,41 +1717,37 @@ IMContextWrapper::MaybeDispatchKeyEventAsProcessedByIME(
|
||||||
GtkIMContext* oldComposingContext = mComposingContext;
|
GtkIMContext* oldComposingContext = mComposingContext;
|
||||||
|
|
||||||
RefPtr<nsWindow> lastFocusedWindow(mLastFocusedWindow);
|
RefPtr<nsWindow> lastFocusedWindow(mLastFocusedWindow);
|
||||||
|
|
||||||
if (mProcessingKeyEvent || !mPostingKeyEvents.IsEmpty()) {
|
|
||||||
if (mProcessingKeyEvent) {
|
if (mProcessingKeyEvent) {
|
||||||
mKeyboardEventWasDispatched = true;
|
mKeyboardEventWasDispatched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're not handling a key event synchronously, the signal may be
|
// If we're not handling a key event synchronously, the signal may be
|
||||||
// sent by IME without sending key event to us. In such case, we
|
// sent by IME without sending key event to us. In such case, we should
|
||||||
// should dispatch keyboard event for the last key event which was
|
// dispatch keyboard event for the last key event which was posted to
|
||||||
// posted to other IME process.
|
// other IME process.
|
||||||
GdkEventKey* sourceEvent =
|
GdkEventKey* sourceEvent =
|
||||||
mProcessingKeyEvent ? mProcessingKeyEvent :
|
mProcessingKeyEvent ? mProcessingKeyEvent :
|
||||||
mPostingKeyEvents.GetFirstEvent();
|
mPostingKeyEvents.GetFirstEvent();
|
||||||
|
|
||||||
MOZ_LOG(gGtkIMLog, LogLevel::Info,
|
MOZ_LOG(gGtkIMLog, LogLevel::Info,
|
||||||
("0x%p MaybeDispatchKeyEventAsProcessedByIME("
|
("0x%p MaybeDispatchKeyEventAsProcessedByIME(), dispatch %s %s "
|
||||||
"aFollowingEvent=%s), dispatch %s %s "
|
|
||||||
"event: { type=%s, keyval=%s, unicode=0x%X, state=%s, "
|
"event: { type=%s, keyval=%s, unicode=0x%X, state=%s, "
|
||||||
"time=%u, hardware_keycode=%u, group=%u }",
|
"time=%u, hardware_keycode=%u, group=%u }",
|
||||||
this, ToChar(aFollowingEvent),
|
this, ToChar(sourceEvent->type == GDK_KEY_PRESS ? eKeyDown : eKeyUp),
|
||||||
ToChar(sourceEvent->type == GDK_KEY_PRESS ? eKeyDown : eKeyUp),
|
|
||||||
mProcessingKeyEvent ? "processing" : "posted",
|
mProcessingKeyEvent ? "processing" : "posted",
|
||||||
GetEventType(sourceEvent), gdk_keyval_name(sourceEvent->keyval),
|
GetEventType(sourceEvent), gdk_keyval_name(sourceEvent->keyval),
|
||||||
gdk_keyval_to_unicode(sourceEvent->keyval),
|
gdk_keyval_to_unicode(sourceEvent->keyval),
|
||||||
GetEventStateName(sourceEvent->state, mIMContextID).get(),
|
GetEventStateName(sourceEvent->state, mIMContextID).get(),
|
||||||
sourceEvent->time, sourceEvent->hardware_keycode,
|
sourceEvent->time, sourceEvent->hardware_keycode, sourceEvent->group));
|
||||||
sourceEvent->group));
|
|
||||||
|
|
||||||
// Let's dispatch eKeyDown event or eKeyUp event now. Note that only
|
// Let's dispatch eKeyDown event or eKeyUp event now. Note that only when
|
||||||
// when we're not in a dead key composition, we should mark the
|
// we're not in a dead key composition, we should mark the eKeyDown and
|
||||||
// eKeyDown and eKeyUp event as "processed by IME" since we should
|
// eKeyUp event as "processed by IME" since we should expose raw keyCode
|
||||||
// expose raw keyCode and key value to web apps the key event is a
|
// and key value to web apps the key event is a part of a dead key
|
||||||
// part of a dead key sequence.
|
// sequence.
|
||||||
// FYI: We should ignore if default of preceding keydown or keyup
|
// FYI: We should ignore if default of preceding keydown or keyup event is
|
||||||
// event is prevented since even on the other browsers, web
|
// prevented since even on the other browsers, web applications
|
||||||
// applications cannot cancel the following composition event.
|
// cannot cancel the following composition event.
|
||||||
// Spec bug: https://github.com/w3c/uievents/issues/180
|
// Spec bug: https://github.com/w3c/uievents/issues/180
|
||||||
bool isCancelled;
|
bool isCancelled;
|
||||||
lastFocusedWindow->DispatchKeyDownOrKeyUpEvent(sourceEvent,
|
lastFocusedWindow->DispatchKeyDownOrKeyUpEvent(sourceEvent,
|
||||||
|
@ -1796,68 +1765,6 @@ IMContextWrapper::MaybeDispatchKeyEventAsProcessedByIME(
|
||||||
this));
|
this));
|
||||||
mPostingKeyEvents.RemoveEvent(sourceEvent);
|
mPostingKeyEvents.RemoveEvent(sourceEvent);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
MOZ_ASSERT(mIsKeySnooped);
|
|
||||||
// Currently, we support key snooper mode of uim only.
|
|
||||||
MOZ_ASSERT(mIMContextID == IMContextID::eUim);
|
|
||||||
// uim sends "preedit_start" signal and "preedit_changed" separately
|
|
||||||
// at starting composition, "commit" and "preedit_end" separately at
|
|
||||||
// committing composition.
|
|
||||||
|
|
||||||
// Currently, we should dispatch only fake eKeyDown event because
|
|
||||||
// we cannot decide which is the last signal of each key operation
|
|
||||||
// and Chromium also dispatches only "keydown" event in this case.
|
|
||||||
bool dispatchFakeKeyDown = false;
|
|
||||||
switch (aFollowingEvent) {
|
|
||||||
case eCompositionStart:
|
|
||||||
case eCompositionCommit:
|
|
||||||
case eCompositionCommitAsIs:
|
|
||||||
dispatchFakeKeyDown = true;
|
|
||||||
break;
|
|
||||||
// XXX Unfortunately, I don't have a good idea to prevent to
|
|
||||||
// dispatch redundant eKeyDown event for eCompositionStart
|
|
||||||
// immediately after "delete_surrounding" signal. However,
|
|
||||||
// not dispatching eKeyDown event is worse than dispatching
|
|
||||||
// redundant eKeyDown events.
|
|
||||||
case eContentCommandDelete:
|
|
||||||
dispatchFakeKeyDown = true;
|
|
||||||
break;
|
|
||||||
// We need to prevent to dispatch redundant eKeyDown event for
|
|
||||||
// eCompositionChange immediately after eCompositionStart. So,
|
|
||||||
// We should not dispatch eKeyDown event if dispatched composition
|
|
||||||
// string is still empty string.
|
|
||||||
case eCompositionChange:
|
|
||||||
dispatchFakeKeyDown = !mDispatchedCompositionString.IsEmpty();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
MOZ_ASSERT_UNREACHABLE("Do you forget to handle the case?");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dispatchFakeKeyDown) {
|
|
||||||
WidgetKeyboardEvent fakeKeyDownEvent(true, eKeyDown,
|
|
||||||
lastFocusedWindow);
|
|
||||||
fakeKeyDownEvent.mKeyCode = NS_VK_PROCESSKEY;
|
|
||||||
fakeKeyDownEvent.mKeyNameIndex = KEY_NAME_INDEX_Process;
|
|
||||||
// It's impossible to get physical key information in this case but
|
|
||||||
// this should be okay since web apps shouldn't do anything with
|
|
||||||
// physical key information during composition.
|
|
||||||
fakeKeyDownEvent.mCodeNameIndex = CODE_NAME_INDEX_UNKNOWN;
|
|
||||||
|
|
||||||
MOZ_LOG(gGtkIMLog, LogLevel::Info,
|
|
||||||
("0x%p MaybeDispatchKeyEventAsProcessedByIME("
|
|
||||||
"aFollowingEvent=%s), dispatch fake eKeyDown event",
|
|
||||||
this, ToChar(aFollowingEvent)));
|
|
||||||
|
|
||||||
bool isCancelled;
|
|
||||||
lastFocusedWindow->DispatchKeyDownOrKeyUpEvent(fakeKeyDownEvent,
|
|
||||||
&isCancelled);
|
|
||||||
MOZ_LOG(gGtkIMLog, LogLevel::Info,
|
|
||||||
("0x%p MaybeDispatchKeyEventAsProcessedByIME(), "
|
|
||||||
"fake keydown event is dispatched",
|
|
||||||
this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastFocusedWindow->IsDestroyed() ||
|
if (lastFocusedWindow->IsDestroyed() ||
|
||||||
lastFocusedWindow != mLastFocusedWindow) {
|
lastFocusedWindow != mLastFocusedWindow) {
|
||||||
|
@ -1935,7 +1842,7 @@ IMContextWrapper::DispatchCompositionStart(GtkIMContext* aContext)
|
||||||
// eKeyDown or eKeyUp event before dispatching eCompositionStart event.
|
// eKeyDown or eKeyUp event before dispatching eCompositionStart event.
|
||||||
// Note that dispatching a keyboard event which is marked as "processed
|
// Note that dispatching a keyboard event which is marked as "processed
|
||||||
// by IME" is okay since Chromium also dispatches keyboard event as so.
|
// by IME" is okay since Chromium also dispatches keyboard event as so.
|
||||||
if (!MaybeDispatchKeyEventAsProcessedByIME(eCompositionStart)) {
|
if (!MaybeDispatchKeyEventAsProcessedByIME()) {
|
||||||
MOZ_LOG(gGtkIMLog, LogLevel::Warning,
|
MOZ_LOG(gGtkIMLog, LogLevel::Warning,
|
||||||
("0x%p DispatchCompositionStart(), Warning, "
|
("0x%p DispatchCompositionStart(), Warning, "
|
||||||
"MaybeDispatchKeyEventAsProcessedByIME() returned false",
|
"MaybeDispatchKeyEventAsProcessedByIME() returned false",
|
||||||
|
@ -2000,7 +1907,7 @@ IMContextWrapper::DispatchCompositionChangeEvent(
|
||||||
}
|
}
|
||||||
// If this composition string change caused by a key press, we need to
|
// If this composition string change caused by a key press, we need to
|
||||||
// dispatch eKeyDown or eKeyUp before dispatching eCompositionChange event.
|
// dispatch eKeyDown or eKeyUp before dispatching eCompositionChange event.
|
||||||
else if (!MaybeDispatchKeyEventAsProcessedByIME(eCompositionChange)) {
|
else if (!MaybeDispatchKeyEventAsProcessedByIME()) {
|
||||||
MOZ_LOG(gGtkIMLog, LogLevel::Warning,
|
MOZ_LOG(gGtkIMLog, LogLevel::Warning,
|
||||||
("0x%p DispatchCompositionChangeEvent(), Warning, "
|
("0x%p DispatchCompositionChangeEvent(), Warning, "
|
||||||
"MaybeDispatchKeyEventAsProcessedByIME() returned false",
|
"MaybeDispatchKeyEventAsProcessedByIME() returned false",
|
||||||
|
@ -2122,8 +2029,7 @@ IMContextWrapper::DispatchCompositionCommitEvent(
|
||||||
}
|
}
|
||||||
// If this commit caused by a key press, we need to dispatch eKeyDown or
|
// If this commit caused by a key press, we need to dispatch eKeyDown or
|
||||||
// eKeyUp before dispatching composition events.
|
// eKeyUp before dispatching composition events.
|
||||||
else if (!MaybeDispatchKeyEventAsProcessedByIME(
|
else if (!MaybeDispatchKeyEventAsProcessedByIME()) {
|
||||||
aCommitString ? eCompositionCommit : eCompositionCommitAsIs)) {
|
|
||||||
MOZ_LOG(gGtkIMLog, LogLevel::Warning,
|
MOZ_LOG(gGtkIMLog, LogLevel::Warning,
|
||||||
("0x%p DispatchCompositionCommitEvent(), Warning, "
|
("0x%p DispatchCompositionCommitEvent(), Warning, "
|
||||||
"MaybeDispatchKeyEventAsProcessedByIME() returned false",
|
"MaybeDispatchKeyEventAsProcessedByIME() returned false",
|
||||||
|
@ -2832,7 +2738,7 @@ IMContextWrapper::DeleteText(GtkIMContext* aContext,
|
||||||
|
|
||||||
// If this deleting text caused by a key press, we need to dispatch
|
// If this deleting text caused by a key press, we need to dispatch
|
||||||
// eKeyDown or eKeyUp before dispatching eContentCommandDelete event.
|
// eKeyDown or eKeyUp before dispatching eContentCommandDelete event.
|
||||||
if (!MaybeDispatchKeyEventAsProcessedByIME(eContentCommandDelete)) {
|
if (!MaybeDispatchKeyEventAsProcessedByIME()) {
|
||||||
MOZ_LOG(gGtkIMLog, LogLevel::Warning,
|
MOZ_LOG(gGtkIMLog, LogLevel::Warning,
|
||||||
("0x%p DeleteText(), Warning, "
|
("0x%p DeleteText(), Warning, "
|
||||||
"MaybeDispatchKeyEventAsProcessedByIME() returned false",
|
"MaybeDispatchKeyEventAsProcessedByIME() returned false",
|
||||||
|
|
|
@ -455,9 +455,6 @@ protected:
|
||||||
// key events asynchronously. I.e., filtered key event may come again
|
// key events asynchronously. I.e., filtered key event may come again
|
||||||
// later.
|
// later.
|
||||||
bool mIsIMInAsyncKeyHandlingMode;
|
bool mIsIMInAsyncKeyHandlingMode;
|
||||||
// mIsKeySnooped is set to true if IM uses key snooper to listen key events.
|
|
||||||
// In such case, we won't receive key events if IME consumes the event.
|
|
||||||
bool mIsKeySnooped;
|
|
||||||
|
|
||||||
// sLastFocusedContext is a pointer to the last focused instance of this
|
// sLastFocusedContext is a pointer to the last focused instance of this
|
||||||
// class. When a instance is destroyed and sLastFocusedContext refers it,
|
// class. When a instance is destroyed and sLastFocusedContext refers it,
|
||||||
|
@ -623,14 +620,13 @@ protected:
|
||||||
* dispatches a keyboard event, this sets mKeyboardEventWasDispatched
|
* dispatches a keyboard event, this sets mKeyboardEventWasDispatched
|
||||||
* to true.
|
* to true.
|
||||||
*
|
*
|
||||||
* @param aFollowingEvent The following event message.
|
|
||||||
* @return If the caller can continue to handle
|
* @return If the caller can continue to handle
|
||||||
* composition, returns true. Otherwise,
|
* composition, returns true. Otherwise,
|
||||||
* false. For example, if focus is moved
|
* false. For example, if focus is moved
|
||||||
* by dispatched keyboard event, returns
|
* by dispatched keyboard event, returns
|
||||||
* false.
|
* false.
|
||||||
*/
|
*/
|
||||||
bool MaybeDispatchKeyEventAsProcessedByIME(EventMessage aFollowingEvent);
|
bool MaybeDispatchKeyEventAsProcessedByIME();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatches a composition start event.
|
* Dispatches a composition start event.
|
||||||
|
|
|
@ -1411,14 +1411,6 @@ void
|
||||||
KeymapWrapper::WillDispatchKeyboardEventInternal(WidgetKeyboardEvent& aKeyEvent,
|
KeymapWrapper::WillDispatchKeyboardEventInternal(WidgetKeyboardEvent& aKeyEvent,
|
||||||
GdkEventKey* aGdkKeyEvent)
|
GdkEventKey* aGdkKeyEvent)
|
||||||
{
|
{
|
||||||
if (!aGdkKeyEvent) {
|
|
||||||
// If aGdkKeyEvent is nullptr, we're trying to dispatch a fake keyboard
|
|
||||||
// event in such case, we don't need to set alternative char codes.
|
|
||||||
// So, we don't need to do nothing here. This case is typically we're
|
|
||||||
// dispatching eKeyDown or eKeyUp event during composition.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t charCode = GetCharCodeFor(aGdkKeyEvent);
|
uint32_t charCode = GetCharCodeFor(aGdkKeyEvent);
|
||||||
if (!charCode) {
|
if (!charCode) {
|
||||||
MOZ_LOG(gKeymapWrapperLog, LogLevel::Info,
|
MOZ_LOG(gKeymapWrapperLog, LogLevel::Info,
|
||||||
|
|
|
@ -2941,7 +2941,7 @@ nsWindow::DispatchKeyDownOrKeyUpEvent(GdkEventKey* aEvent,
|
||||||
bool aIsProcessedByIME,
|
bool aIsProcessedByIME,
|
||||||
bool* aIsCancelled)
|
bool* aIsCancelled)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aIsCancelled, "aIsCancelled must not be nullptr");
|
MOZ_ASSERT(aIsCancelled, "aCancelled must not be null");
|
||||||
|
|
||||||
*aIsCancelled = false;
|
*aIsCancelled = false;
|
||||||
|
|
||||||
|
@ -2949,32 +2949,21 @@ nsWindow::DispatchKeyDownOrKeyUpEvent(GdkEventKey* aEvent,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventMessage message =
|
|
||||||
aEvent->type == GDK_KEY_PRESS ? eKeyDown : eKeyUp;
|
|
||||||
WidgetKeyboardEvent keyEvent(true, message, this);
|
|
||||||
KeymapWrapper::InitKeyEvent(keyEvent, aEvent, aIsProcessedByIME);
|
|
||||||
return DispatchKeyDownOrKeyUpEvent(keyEvent, aIsCancelled);
|
|
||||||
}
|
|
||||||
bool
|
|
||||||
nsWindow::DispatchKeyDownOrKeyUpEvent(WidgetKeyboardEvent& aKeyboardEvent,
|
|
||||||
bool* aIsCancelled)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aIsCancelled, "aIsCancelled must not be nullptr");
|
|
||||||
|
|
||||||
*aIsCancelled = false;
|
|
||||||
|
|
||||||
RefPtr<TextEventDispatcher> dispatcher = GetTextEventDispatcher();
|
RefPtr<TextEventDispatcher> dispatcher = GetTextEventDispatcher();
|
||||||
nsresult rv = dispatcher->BeginNativeInputTransaction();
|
nsresult rv = dispatcher->BeginNativeInputTransaction();
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventMessage message =
|
||||||
|
aEvent->type == GDK_KEY_PRESS ? eKeyDown : eKeyUp;
|
||||||
|
WidgetKeyboardEvent keyEvent(true, message, this);
|
||||||
|
KeymapWrapper::InitKeyEvent(keyEvent, aEvent, aIsProcessedByIME);
|
||||||
nsEventStatus status = nsEventStatus_eIgnore;
|
nsEventStatus status = nsEventStatus_eIgnore;
|
||||||
bool dispatched =
|
bool dispatched =
|
||||||
dispatcher->DispatchKeyboardEvent(aKeyboardEvent.mMessage,
|
dispatcher->DispatchKeyboardEvent(message, keyEvent, status, aEvent);
|
||||||
aKeyboardEvent, status, nullptr);
|
|
||||||
*aIsCancelled = (status == nsEventStatus_eConsumeNoDefault);
|
*aIsCancelled = (status == nsEventStatus_eConsumeNoDefault);
|
||||||
return dispatched;
|
return dispatched ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetEventTime
|
WidgetEventTime
|
||||||
|
|
|
@ -78,7 +78,6 @@ class nsWindow final : public nsBaseWidget
|
||||||
public:
|
public:
|
||||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||||
typedef mozilla::WidgetEventTime WidgetEventTime;
|
typedef mozilla::WidgetEventTime WidgetEventTime;
|
||||||
typedef mozilla::WidgetKeyboardEvent WidgetKeyboardEvent;
|
|
||||||
typedef mozilla::widget::PlatformCompositorWidgetDelegate PlatformCompositorWidgetDelegate;
|
typedef mozilla::widget::PlatformCompositorWidgetDelegate PlatformCompositorWidgetDelegate;
|
||||||
|
|
||||||
nsWindow();
|
nsWindow();
|
||||||
|
@ -295,18 +294,6 @@ public:
|
||||||
bool aProcessedByIME,
|
bool aProcessedByIME,
|
||||||
bool* aIsCancelled);
|
bool* aIsCancelled);
|
||||||
|
|
||||||
/**
|
|
||||||
* DispatchKeyDownOrKeyUpEvent() dispatches eKeyDown or eKeyUp event.
|
|
||||||
*
|
|
||||||
* @param aEvent An eKeyDown or eKeyUp event. This will be
|
|
||||||
* dispatched as is.
|
|
||||||
* @param aIsCancelled [Out] true if the default is prevented.
|
|
||||||
* @return true if eKeyDown event is actually dispatched.
|
|
||||||
* Otherwise, false.
|
|
||||||
*/
|
|
||||||
bool DispatchKeyDownOrKeyUpEvent(WidgetKeyboardEvent& aEvent,
|
|
||||||
bool* aIsCancelled);
|
|
||||||
|
|
||||||
WidgetEventTime GetWidgetEventTime(guint32 aEventTime);
|
WidgetEventTime GetWidgetEventTime(guint32 aEventTime);
|
||||||
mozilla::TimeStamp GetEventTimeStamp(guint32 aEventTime);
|
mozilla::TimeStamp GetEventTimeStamp(guint32 aEventTime);
|
||||||
mozilla::CurrentX11TimeGetter* GetCurrentTimeGetter();
|
mozilla::CurrentX11TimeGetter* GetCurrentTimeGetter();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче