summaryrefslogtreecommitdiffstats
path: root/views/ime
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 02:36:05 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 02:36:05 +0000
commit452da69e427d9c9fe87b4e2ce37f1c5276db1922 (patch)
tree5cdf61851b5630cb11a70583c1a61e7b84f76e64 /views/ime
parentf8fa8fb9362151cfce0c55a61f26c55c640925de (diff)
downloadchromium_src-452da69e427d9c9fe87b4e2ce37f1c5276db1922.zip
chromium_src-452da69e427d9c9fe87b4e2ce37f1c5276db1922.tar.gz
chromium_src-452da69e427d9c9fe87b4e2ce37f1c5276db1922.tar.bz2
Fix to make InputMethodIBus usable on every ChromeOS device (even without TouchUI)
Add switch "--enable-inputmethod-ibus" to enable InputMethodIBus on ChromeOS Modify gyp files to link IBus BUG=chromium-os:15566 TEST=manually Review URL: http://codereview.chromium.org/7004029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86390 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/ime')
-rw-r--r--views/ime/input_method_ibus.cc23
-rw-r--r--views/ime/input_method_ibus.h8
2 files changed, 31 insertions, 0 deletions
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.