summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/common.gypi2
-rw-r--r--views/ime/input_method_ibus.cc23
-rw-r--r--views/ime/input_method_ibus.h8
-rw-r--r--views/views.gyp29
-rw-r--r--views/widget/native_widget_gtk.cc14
5 files changed, 52 insertions, 24 deletions
diff --git a/build/common.gypi b/build/common.gypi
index d88201f..d173104 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -564,7 +564,7 @@
'<!(<(DEPTH)/tools/clang/scripts/plugin_flags.sh)',
}],
- # Set 1 to enable ibus support. Currently it is only supported in touchui.
+ # Set use_ibus to 1 to enable ibus support.
['touchui==1 and chromeos==1', {
'use_ibus%': 1,
}, {
diff --git a/views/ime/input_method_ibus.cc b/views/ime/input_method_ibus.cc
index a20e05a..c8d7251 100644
--- a/views/ime/input_method_ibus.cc
+++ b/views/ime/input_method_ibus.cc
@@ -14,6 +14,7 @@
#include <X11/Xutil.h>
#endif
+#include "base/command_line.h"
#include "base/basictypes.h"
#include "base/i18n/char_iterator.h"
#include "base/logging.h"
@@ -31,6 +32,9 @@
namespace {
+// A global flag to switch the InputMethod implementation to InputMethodIBus
+bool inputmethod_ibus_enabled = false;
+
// Converts ibus key state flags to Views event flags.
int ViewsFlagsFromIBusState(guint32 state) {
return (state & IBUS_LOCK_MASK ? ui::EF_CAPS_LOCK_DOWN : 0) |
@@ -126,6 +130,9 @@ void ExtractCompositionTextFromIBusPreedit(IBusText* text,
}
}
+// A switch to enable InputMethodIBus
+const char kEnableInputMethodIBusSwitch[] = "enable-inputmethod-ibus";
+
} // namespace
namespace views {
@@ -409,6 +416,22 @@ bool InputMethodIBus::IsActive() {
return context_ != NULL;
}
+// static
+bool InputMethodIBus::IsInputMethodIBusEnabled() {
+#if defined(TOUCH_UI)
+ return true;
+#else
+ return inputmethod_ibus_enabled ||
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ kEnableInputMethodIBusSwitch);
+#endif
+}
+
+// static
+void InputMethodIBus::SetEnableInputMethodIBus(bool enabled) {
+ inputmethod_ibus_enabled = enabled;
+}
+
void InputMethodIBus::FocusedViewWillChange() {
ConfirmCompositionText();
}
diff --git a/views/ime/input_method_ibus.h b/views/ime/input_method_ibus.h
index 1e1a2034..bda8ab5 100644
--- a/views/ime/input_method_ibus.h
+++ b/views/ime/input_method_ibus.h
@@ -41,6 +41,14 @@ class InputMethodIBus : public InputMethodBase {
virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE;
virtual bool IsActive() OVERRIDE;
+ // Returns true when
+ // 1) built with GYP_DEFINES="touchui=1" or,
+ // 2) enabled by SetEnabledInputMethodIBus or,
+ // 3) enabled by command line flag "--enable-inputmethod-ibus"
+ static bool IsInputMethodIBusEnabled();
+ // Enable/Disable InputMethodIBus
+ static void SetEnableInputMethodIBus(bool enabled);
+
private:
// A class to hold all data related to a key event being processed by the
// input method but still has no result back yet.
diff --git a/views/views.gyp b/views/views.gyp
index 8f86b11..694b5a36 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -431,6 +431,8 @@
'sources/': [
['exclude', 'focus/accelerator_handler_gtk.cc'],
['exclude', 'controls/menu/native_menu_gtk.cc'],
+ ['exclude', 'ime/input_method_gtk.cc'],
+ ['exclude', 'ime/input_method_gtk.h'],
],
'conditions': [
['"<!@(<(pkg-config) --atleast-version=2.0 inputproto || echo $?)"!=""', {
@@ -440,25 +442,16 @@
['exclude', 'touchui/touch_factory.h'],
],
}],
- ['use_ibus==1', {
- 'dependencies': [
- '../build/linux/system.gyp:ibus',
- ],
- 'sources/': [
- ['exclude', 'ime/input_method_gtk.cc'],
- ['exclude', 'ime/input_method_gtk.h'],
- ],
- }, { # else: use_ibus != 1
- 'sources/': [
- ['exclude', 'ime/input_method_ibus.cc'],
- ['exclude', 'ime/input_method_ibus.h'],
- ],
- }],
],
- }, { # else: touchui != 1
- 'sources!': [
- 'ime/input_method_ibus.cc',
- 'ime/input_method_ibus.h',
+ }],
+ ['use_ibus==1', {
+ 'dependencies': [
+ '../build/linux/system.gyp:ibus',
+ ],
+ }, { # else: use_ibus != 1
+ 'sources/': [
+ ['exclude', 'ime/input_method_ibus.cc'],
+ ['exclude', 'ime/input_method_ibus.h'],
],
}],
['OS=="win"', {
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index a838b64..c6edfd9 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -44,9 +44,10 @@
#endif
#endif
-#if defined(TOUCH_UI) && defined(HAVE_IBUS)
+#if defined(HAVE_IBUS)
#include "views/ime/input_method_ibus.h"
-#else
+#endif
+#if !defined(TOUCH_UI)
#include "views/ime/input_method_gtk.h"
#endif
@@ -619,11 +620,14 @@ void NativeWidgetGtk::InitNativeWidget(const Widget::InitParams& params) {
// already created at this point.
// TODO(suzhe): Always enable input method when we start to use
// RenderWidgetHostViewViews in normal ChromeOS.
-#if defined(TOUCH_UI) && defined(HAVE_IBUS)
- if (!child_) {
+ if (!child_ && NativeTextfieldViews::IsTextfieldViewsEnabled()) {
+#if defined(TOUCH_UI)
input_method_.reset(new InputMethodIBus(this));
+#elif defined(HAVE_IBUS)
+ input_method_.reset(InputMethodIBus::IsInputMethodIBusEnabled() ?
+ static_cast<InputMethod*>(new InputMethodIBus(this)) :
+ static_cast<InputMethod*>(new InputMethodGtk(this)));
#else
- if (!child_ && NativeTextfieldViews::IsTextfieldViewsEnabled()) {
input_method_.reset(new InputMethodGtk(this));
#endif
input_method_->Init(GetWidget());