| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/input_method/ibus_controller_impl.h" | 5 #include "chrome/browser/chromeos/input_method/ibus_controller_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> // for std::reverse. | 7 #include <algorithm> // for std::reverse. |
| 8 #include <cstdio> | 8 #include <cstdio> |
| 9 #include <cstring> // for std::strcmp. | 9 #include <cstring> // for std::strcmp. |
| 10 #include <set> | 10 #include <set> |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // We don't have to call ibus_proxy_destroy(context) explicitly here, | 638 // We don't have to call ibus_proxy_destroy(context) explicitly here, |
| 639 // i.e. we can just call g_object_unref(context), since g_object_unref can | 639 // i.e. we can just call g_object_unref(context), since g_object_unref can |
| 640 // trigger both dispose, which is overridden by src/ibusproxy.c, and | 640 // trigger both dispose, which is overridden by src/ibusproxy.c, and |
| 641 // finalize functions. For details, see | 641 // finalize functions. For details, see |
| 642 // http://library.gnome.org/devel/gobject/stable/gobject-memory.html | 642 // http://library.gnome.org/devel/gobject/stable/gobject-memory.html |
| 643 g_object_unref(context); | 643 g_object_unref(context); |
| 644 | 644 |
| 645 return true; | 645 return true; |
| 646 } | 646 } |
| 647 | 647 |
| 648 #if defined(USE_VIRTUAL_KEYBOARD) | |
| 649 // IBusController override. | |
| 650 void IBusControllerImpl::SendHandwritingStroke( | |
| 651 const HandwritingStroke& stroke) { | |
| 652 if (stroke.size() < 2) { | |
| 653 DVLOG(1) << "Empty stroke data or a single dot is passed."; | |
| 654 return; | |
| 655 } | |
| 656 | |
| 657 IBusInputContext* context = | |
| 658 GetInputContext(current_input_context_path_, ibus_); | |
| 659 if (!context) | |
| 660 return; | |
| 661 | |
| 662 const size_t raw_stroke_size = stroke.size() * 2; | |
| 663 scoped_array<double> raw_stroke(new double[raw_stroke_size]); | |
| 664 for (size_t n = 0; n < stroke.size(); ++n) { | |
| 665 raw_stroke[n * 2] = stroke[n].first; // x | |
| 666 raw_stroke[n * 2 + 1] = stroke[n].second; // y | |
| 667 } | |
| 668 ibus_input_context_process_hand_writing_event( | |
| 669 context, raw_stroke.get(), raw_stroke_size); | |
| 670 g_object_unref(context); | |
| 671 } | |
| 672 | |
| 673 // IBusController override. | |
| 674 void IBusControllerImpl::CancelHandwriting(int n_strokes) { | |
| 675 IBusInputContext* context = | |
| 676 GetInputContext(current_input_context_path_, ibus_); | |
| 677 if (!context) | |
| 678 return; | |
| 679 ibus_input_context_cancel_hand_writing(context, n_strokes); | |
| 680 g_object_unref(context); | |
| 681 } | |
| 682 #endif | |
| 683 | |
| 684 bool IBusControllerImpl::IBusConnectionsAreAlive() { | 648 bool IBusControllerImpl::IBusConnectionsAreAlive() { |
| 685 return (ibus_daemon_status_ == IBUS_DAEMON_RUNNING) && | 649 return (ibus_daemon_status_ == IBUS_DAEMON_RUNNING) && |
| 686 ibus_ && ibus_bus_is_connected(ibus_) && ibus_config_; | 650 ibus_ && ibus_bus_is_connected(ibus_) && ibus_config_; |
| 687 } | 651 } |
| 688 | 652 |
| 689 void IBusControllerImpl::MaybeRestoreConnections() { | 653 void IBusControllerImpl::MaybeRestoreConnections() { |
| 690 if (IBusConnectionsAreAlive()) | 654 if (IBusConnectionsAreAlive()) |
| 691 return; | 655 return; |
| 692 MaybeRestoreIBusConfig(); | 656 MaybeRestoreIBusConfig(); |
| 693 if (IBusConnectionsAreAlive()) { | 657 if (IBusConnectionsAreAlive()) { |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 | 1108 |
| 1145 // static | 1109 // static |
| 1146 bool IBusControllerImpl::FindAndUpdatePropertyForTesting( | 1110 bool IBusControllerImpl::FindAndUpdatePropertyForTesting( |
| 1147 const chromeos::input_method::InputMethodProperty& new_prop, | 1111 const chromeos::input_method::InputMethodProperty& new_prop, |
| 1148 chromeos::input_method::InputMethodPropertyList* prop_list) { | 1112 chromeos::input_method::InputMethodPropertyList* prop_list) { |
| 1149 return FindAndUpdateProperty(new_prop, prop_list); | 1113 return FindAndUpdateProperty(new_prop, prop_list); |
| 1150 } | 1114 } |
| 1151 | 1115 |
| 1152 } // namespace input_method | 1116 } // namespace input_method |
| 1153 } // namespace chromeos | 1117 } // namespace chromeos |
| OLD | NEW |