Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: views/ime/input_method_ibus.cc

Issue 7004029: Fix to make InputMethodIBus usable on every ChromeOS device (even without TouchUI) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small fix to replace "if" with "?" Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/ime/input_method_ibus.h ('k') | views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/ime/input_method_ibus.h" 5 #include "views/ime/input_method_ibus.h"
6 6
7 #include <ibus.h> 7 #include <ibus.h>
8 8
9 #include <cstring> 9 #include <cstring>
10 #include <set> 10 #include <set>
11 11
12 #if defined(TOUCH_UI) 12 #if defined(TOUCH_UI)
13 #include <X11/Xlib.h> 13 #include <X11/Xlib.h>
14 #include <X11/Xutil.h> 14 #include <X11/Xutil.h>
15 #endif 15 #endif
16 16
17 #include "base/command_line.h"
17 #include "base/basictypes.h" 18 #include "base/basictypes.h"
18 #include "base/i18n/char_iterator.h" 19 #include "base/i18n/char_iterator.h"
19 #include "base/logging.h" 20 #include "base/logging.h"
20 #include "base/string_util.h" 21 #include "base/string_util.h"
21 #include "base/third_party/icu/icu_utf.h" 22 #include "base/third_party/icu/icu_utf.h"
22 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
23 #include "ui/base/keycodes/keyboard_codes.h" 24 #include "ui/base/keycodes/keyboard_codes.h"
24 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" 25 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
25 #include "views/events/event.h" 26 #include "views/events/event.h"
26 #include "views/widget/widget.h" 27 #include "views/widget/widget.h"
27 28
28 #if defined(TOUCH_UI) 29 #if defined(TOUCH_UI)
29 #include "ui/base/keycodes/keyboard_code_conversion_x.h" 30 #include "ui/base/keycodes/keyboard_code_conversion_x.h"
30 #endif 31 #endif
31 32
32 namespace { 33 namespace {
33 34
35 // A global flag to switch the InputMethod implementation to InputMethodIBus
36 bool inputmethod_ibus_enabled = false;
37
34 // Converts ibus key state flags to Views event flags. 38 // Converts ibus key state flags to Views event flags.
35 int ViewsFlagsFromIBusState(guint32 state) { 39 int ViewsFlagsFromIBusState(guint32 state) {
36 return (state & IBUS_LOCK_MASK ? ui::EF_CAPS_LOCK_DOWN : 0) | 40 return (state & IBUS_LOCK_MASK ? ui::EF_CAPS_LOCK_DOWN : 0) |
37 (state & IBUS_CONTROL_MASK ? ui::EF_CONTROL_DOWN : 0) | 41 (state & IBUS_CONTROL_MASK ? ui::EF_CONTROL_DOWN : 0) |
38 (state & IBUS_SHIFT_MASK ? ui::EF_SHIFT_DOWN : 0) | 42 (state & IBUS_SHIFT_MASK ? ui::EF_SHIFT_DOWN : 0) |
39 (state & IBUS_MOD1_MASK ? ui::EF_ALT_DOWN : 0) | 43 (state & IBUS_MOD1_MASK ? ui::EF_ALT_DOWN : 0) |
40 (state & IBUS_BUTTON1_MASK ? ui::EF_LEFT_BUTTON_DOWN : 0) | 44 (state & IBUS_BUTTON1_MASK ? ui::EF_LEFT_BUTTON_DOWN : 0) |
41 (state & IBUS_BUTTON2_MASK ? ui::EF_MIDDLE_BUTTON_DOWN : 0) | 45 (state & IBUS_BUTTON2_MASK ? ui::EF_MIDDLE_BUTTON_DOWN : 0) |
42 (state & IBUS_BUTTON3_MASK ? ui::EF_RIGHT_BUTTON_DOWN : 0); 46 (state & IBUS_BUTTON3_MASK ? ui::EF_RIGHT_BUTTON_DOWN : 0);
43 } 47 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 123 }
120 } 124 }
121 125
122 // Use a black thin underline by default. 126 // Use a black thin underline by default.
123 if (composition->underlines.empty()) { 127 if (composition->underlines.empty()) {
124 composition->underlines.push_back(ui::CompositionUnderline( 128 composition->underlines.push_back(ui::CompositionUnderline(
125 0, length, SK_ColorBLACK, false /* thick */)); 129 0, length, SK_ColorBLACK, false /* thick */));
126 } 130 }
127 } 131 }
128 132
133 // A switch to enable InputMethodIBus
134 const char kEnableInputMethodIBusSwitch[] = "enable-inputmethod-ibus";
135
129 } // namespace 136 } // namespace
130 137
131 namespace views { 138 namespace views {
132 139
133 // InputMethodIBus::PendingKeyEvent implementation ---------------------------- 140 // InputMethodIBus::PendingKeyEvent implementation ----------------------------
134 class InputMethodIBus::PendingKeyEvent { 141 class InputMethodIBus::PendingKeyEvent {
135 public: 142 public:
136 PendingKeyEvent(InputMethodIBus* input_method, const KeyEvent& key); 143 PendingKeyEvent(InputMethodIBus* input_method, const KeyEvent& key);
137 ~PendingKeyEvent(); 144 ~PendingKeyEvent();
138 145
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 409
403 base::i18n::TextDirection InputMethodIBus::GetInputTextDirection() { 410 base::i18n::TextDirection InputMethodIBus::GetInputTextDirection() {
404 // Not supported. 411 // Not supported.
405 return base::i18n::UNKNOWN_DIRECTION; 412 return base::i18n::UNKNOWN_DIRECTION;
406 } 413 }
407 414
408 bool InputMethodIBus::IsActive() { 415 bool InputMethodIBus::IsActive() {
409 return context_ != NULL; 416 return context_ != NULL;
410 } 417 }
411 418
419 // static
420 bool InputMethodIBus::IsInputMethodIBusEnabled() {
421 #if defined(TOUCH_UI)
422 return true;
423 #else
424 return inputmethod_ibus_enabled ||
425 CommandLine::ForCurrentProcess()->HasSwitch(
426 kEnableInputMethodIBusSwitch);
427 #endif
428 }
429
430 // static
431 void InputMethodIBus::SetEnableInputMethodIBus(bool enabled) {
432 inputmethod_ibus_enabled = enabled;
433 }
434
412 void InputMethodIBus::FocusedViewWillChange() { 435 void InputMethodIBus::FocusedViewWillChange() {
413 ConfirmCompositionText(); 436 ConfirmCompositionText();
414 } 437 }
415 438
416 void InputMethodIBus::FocusedViewDidChange() { 439 void InputMethodIBus::FocusedViewDidChange() {
417 UpdateContextFocusState(); 440 UpdateContextFocusState();
418 441
419 // Force to update caret bounds, in case the View thinks that the caret 442 // Force to update caret bounds, in case the View thinks that the caret
420 // bounds has not changed. 443 // bounds has not changed.
421 if (context_focused_) 444 if (context_focused_)
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 DCHECK_EQ(GetIBus(), bus); 991 DCHECK_EQ(GetIBus(), bus);
969 DCHECK(data); 992 DCHECK(data);
970 IBusInputContext* ic = 993 IBusInputContext* ic =
971 ibus_bus_create_input_context_async_finish(bus, res, NULL); 994 ibus_bus_create_input_context_async_finish(bus, res, NULL);
972 if (ic) 995 if (ic)
973 data->StoreOrAbandonInputContext(ic); 996 data->StoreOrAbandonInputContext(ic);
974 delete data; 997 delete data;
975 } 998 }
976 999
977 } // namespace views 1000 } // namespace views
OLDNEW
« no previous file with comments | « views/ime/input_method_ibus.h ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698