| OLD | NEW |
| 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> |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 ibus_keyval, ibus_keycode, ibus_state, -1, NULL, | 362 ibus_keyval, ibus_keycode, ibus_state, -1, NULL, |
| 363 reinterpret_cast<GAsyncReadyCallback>(ProcessKeyEventDone), | 363 reinterpret_cast<GAsyncReadyCallback>(ProcessKeyEventDone), |
| 364 pending_key); | 364 pending_key); |
| 365 | 365 |
| 366 // We don't want to suppress the result generated by this key event, but it | 366 // We don't want to suppress the result generated by this key event, but it |
| 367 // may cause problem. See comment in ResetContext() method. | 367 // may cause problem. See comment in ResetContext() method. |
| 368 suppress_next_result_ = false; | 368 suppress_next_result_ = false; |
| 369 } | 369 } |
| 370 | 370 |
| 371 void InputMethodIBus::OnTextInputTypeChanged(View* view) { | 371 void InputMethodIBus::OnTextInputTypeChanged(View* view) { |
| 372 InputMethodBase::OnTextInputTypeChanged(view); |
| 372 if (context_ && IsViewFocused(view)) { | 373 if (context_ && IsViewFocused(view)) { |
| 373 ResetContext(); | 374 ResetContext(); |
| 374 UpdateContextFocusState(); | 375 UpdateContextFocusState(); |
| 375 } | 376 } |
| 376 } | 377 } |
| 377 | 378 |
| 378 void InputMethodIBus::OnCaretBoundsChanged(View* view) { | 379 void InputMethodIBus::OnCaretBoundsChanged(View* view) { |
| 379 if (!context_focused_ || !IsViewFocused(view)) | 380 if (!context_focused_ || !IsViewFocused(view)) |
| 380 return; | 381 return; |
| 381 | 382 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 406 // Not supported. | 407 // Not supported. |
| 407 return std::string(""); | 408 return std::string(""); |
| 408 } | 409 } |
| 409 | 410 |
| 410 base::i18n::TextDirection InputMethodIBus::GetInputTextDirection() { | 411 base::i18n::TextDirection InputMethodIBus::GetInputTextDirection() { |
| 411 // Not supported. | 412 // Not supported. |
| 412 return base::i18n::UNKNOWN_DIRECTION; | 413 return base::i18n::UNKNOWN_DIRECTION; |
| 413 } | 414 } |
| 414 | 415 |
| 415 bool InputMethodIBus::IsActive() { | 416 bool InputMethodIBus::IsActive() { |
| 416 return context_ != NULL; | 417 // We always need to receive TextInputTypeChanged signal, |
| 418 // so just return true here. |
| 419 return true; |
| 417 } | 420 } |
| 418 | 421 |
| 419 // static | 422 // static |
| 420 bool InputMethodIBus::IsInputMethodIBusEnabled() { | 423 bool InputMethodIBus::IsInputMethodIBusEnabled() { |
| 421 #if defined(TOUCH_UI) | 424 #if defined(TOUCH_UI) |
| 422 return true; | 425 return true; |
| 423 #else | 426 #else |
| 424 return inputmethod_ibus_enabled || | 427 return inputmethod_ibus_enabled || |
| 425 CommandLine::ForCurrentProcess()->HasSwitch( | 428 CommandLine::ForCurrentProcess()->HasSwitch( |
| 426 kEnableInputMethodIBusSwitch); | 429 kEnableInputMethodIBusSwitch); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 // This function runs asynchronously. | 578 // This function runs asynchronously. |
| 576 // Note: some input method engines may not support reset method, such as | 579 // Note: some input method engines may not support reset method, such as |
| 577 // ibus-anthy. But as we control all input method engines by ourselves, we can | 580 // ibus-anthy. But as we control all input method engines by ourselves, we can |
| 578 // make sure that all of the engines we are using support it correctly. | 581 // make sure that all of the engines we are using support it correctly. |
| 579 ibus_input_context_reset(context_); | 582 ibus_input_context_reset(context_); |
| 580 | 583 |
| 581 // We don't need to reset |fake_context_|. | 584 // We don't need to reset |fake_context_|. |
| 582 } | 585 } |
| 583 | 586 |
| 584 void InputMethodIBus::UpdateContextFocusState() { | 587 void InputMethodIBus::UpdateContextFocusState() { |
| 585 if (!context_) { | 588 if (!context_ || !widget_focused()) { |
| 586 context_focused_ = false; | 589 context_focused_ = false; |
| 587 UpdateFakeContextFocusState(); | 590 UpdateFakeContextFocusState(); |
| 588 return; | 591 return; |
| 589 } | 592 } |
| 590 | 593 |
| 591 const bool old_context_focused = context_focused_; | 594 const bool old_context_focused = context_focused_; |
| 592 // Use switch here in case we are going to add more text input types. | 595 // Use switch here in case we are going to add more text input types. |
| 593 switch (GetTextInputType()) { | 596 switch (GetTextInputType()) { |
| 594 case ui::TEXT_INPUT_TYPE_NONE: | 597 case ui::TEXT_INPUT_TYPE_NONE: |
| 595 case ui::TEXT_INPUT_TYPE_PASSWORD: | 598 case ui::TEXT_INPUT_TYPE_PASSWORD: |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 DCHECK_EQ(GetIBus(), bus); | 990 DCHECK_EQ(GetIBus(), bus); |
| 988 DCHECK(data); | 991 DCHECK(data); |
| 989 IBusInputContext* ic = | 992 IBusInputContext* ic = |
| 990 ibus_bus_create_input_context_async_finish(bus, res, NULL); | 993 ibus_bus_create_input_context_async_finish(bus, res, NULL); |
| 991 if (ic) | 994 if (ic) |
| 992 data->StoreOrAbandonInputContext(ic); | 995 data->StoreOrAbandonInputContext(ic); |
| 993 delete data; | 996 delete data; |
| 994 } | 997 } |
| 995 | 998 |
| 996 } // namespace views | 999 } // namespace views |
| OLD | NEW |