mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 10:33:33 +00:00
Bug 931378 Set input purpose to IM context r=karlt
This commit is contained in:
parent
c5ed5f2191
commit
5c5c1e6b47
28
widget/gtk/compat/gtk/gtkenums.h
Normal file
28
widget/gtk/compat/gtk/gtkenums.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef GTKENUMS_WRAPPER_H
|
||||
#define GTKENUMS_WRAPPER_H
|
||||
|
||||
#include_next <gtk/gtkenums.h>
|
||||
|
||||
#include <gtk/gtkversion.h>
|
||||
|
||||
#if !GTK_CHECK_VERSION(3, 6, 0)
|
||||
enum GtkInputPurpose
|
||||
{
|
||||
GTK_INPUT_PURPOSE_FREE_FORM,
|
||||
GTK_INPUT_PURPOSE_ALPHA,
|
||||
GTK_INPUT_PURPOSE_DIGITS,
|
||||
GTK_INPUT_PURPOSE_NUMBER,
|
||||
GTK_INPUT_PURPOSE_PHONE,
|
||||
GTK_INPUT_PURPOSE_URL,
|
||||
GTK_INPUT_PURPOSE_EMAIL,
|
||||
GTK_INPUT_PURPOSE_NAME,
|
||||
GTK_INPUT_PURPOSE_PASSWORD,
|
||||
GTK_INPUT_PURPOSE_PIN
|
||||
};
|
||||
#endif // 3.6.0
|
||||
|
||||
#endif /* GTKENUMS_WRAPPER_H */
|
@ -549,7 +549,8 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller,
|
||||
}
|
||||
|
||||
bool changingEnabledState =
|
||||
aContext->mIMEState.mEnabled != mInputContext.mIMEState.mEnabled;
|
||||
aContext->mIMEState.mEnabled != mInputContext.mIMEState.mEnabled ||
|
||||
aContext->mHTMLInputType != mInputContext.mHTMLInputType;
|
||||
|
||||
// Release current IME focus if IME is enabled.
|
||||
if (changingEnabledState && IsEditable()) {
|
||||
@ -559,12 +560,39 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller,
|
||||
|
||||
mInputContext = *aContext;
|
||||
|
||||
// Even when aState is not enabled state, we need to set IME focus.
|
||||
// Because some IMs are updating the status bar of them at this time.
|
||||
// Be aware, don't use aWindow here because this method shouldn't move
|
||||
// focus actually.
|
||||
if (changingEnabledState) {
|
||||
#if (MOZ_WIDGET_GTK == 3)
|
||||
static bool sInputPurposeSupported = !gtk_check_version(3, 6, 0);
|
||||
if (sInputPurposeSupported && IsEditable()) {
|
||||
GtkIMContext* context = GetContext();
|
||||
if (context) {
|
||||
GtkInputPurpose purpose = GTK_INPUT_PURPOSE_FREE_FORM;
|
||||
const nsString& inputType = mInputContext.mHTMLInputType;
|
||||
if (inputType.EqualsLiteral("password")) {
|
||||
purpose = GTK_INPUT_PURPOSE_PASSWORD;
|
||||
} else if (inputType.EqualsLiteral("email")) {
|
||||
purpose = GTK_INPUT_PURPOSE_EMAIL;
|
||||
} else if (inputType.EqualsLiteral("url")) {
|
||||
purpose = GTK_INPUT_PURPOSE_URL;
|
||||
} else if (inputType.EqualsLiteral("tel")) {
|
||||
purpose = GTK_INPUT_PURPOSE_PHONE;
|
||||
} else if (inputType.EqualsLiteral("number")) {
|
||||
purpose = GTK_INPUT_PURPOSE_NUMBER;
|
||||
}
|
||||
|
||||
g_object_set(context, "input-purpose", purpose, nullptr);
|
||||
}
|
||||
}
|
||||
#endif // #if (MOZ_WIDGET_GTK == 3)
|
||||
|
||||
// Even when aState is not enabled state, we need to set IME focus.
|
||||
// Because some IMs are updating the status bar of them at this time.
|
||||
// Be aware, don't use aWindow here because this method shouldn't move
|
||||
// focus actually.
|
||||
Focus();
|
||||
|
||||
// XXX Should we call Blur() when it's not editable? E.g., it might be
|
||||
// better to close VKB automatically.
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user