Chromium Code Reviews| Index: chromeos_input_method.cc |
| diff --git a/chromeos_input_method.cc b/chromeos_input_method.cc |
| index 132ff0fc14ffd9090350aff1102791fd1fa4338b..804ce8362128651aad732d062b4d8318891bcdb2 100644 |
| --- a/chromeos_input_method.cc |
| +++ b/chromeos_input_method.cc |
| @@ -18,6 +18,7 @@ |
| #include <stack> |
| #include <utility> |
| +#include "base/scoped_ptr.h" |
| #include "base/singleton.h" |
| #include "chromeos/string.h" // for chromeos::SplitStringUsing. |
| #include "ibus_input_methods.h" |
| @@ -651,6 +652,37 @@ class InputMethodStatusConnection { |
| return true; |
| } |
| + void SendHandwritingStrokes(const HandwritingStrokes& strokes) { |
| + if (strokes.size() < 2) { |
| + LOG(WARNING) << "Empty stroke data or a single dot is passed."; |
|
Zachary Kuznia
2011/04/27 09:45:46
I think VLOG is preferred now.
Yusuke Sato
2011/04/27 10:10:33
It seems that VLOG is not supported in the logging
|
| + return; |
| + } |
| + |
| + IBusInputContext* context = GetInputContext(input_context_path_, ibus_); |
| + if (!context) { |
| + return; |
| + } |
| + |
| + const size_t raw_strokes_size = strokes.size() * 2; |
| + scoped_array<double> raw_strokes(new double[raw_strokes_size]); |
| + for (size_t n = 0; n < strokes.size(); ++n) { |
| + raw_strokes[n * 2] = strokes[n].first; // x |
| + raw_strokes[n * 2 + 1] = strokes[n].second; // y |
| + } |
| + ibus_input_context_process_hand_writing_event( |
| + context, raw_strokes.get(), raw_strokes_size); |
| + g_object_unref(context); |
| + } |
| + |
| + void CancelHandwriting(int n_strokes) { |
| + IBusInputContext* context = GetInputContext(input_context_path_, ibus_); |
| + if (!context) { |
| + return; |
| + } |
| + ibus_input_context_cancel_hand_writing(context, n_strokes); |
| + g_object_unref(context); |
| + } |
| + |
| private: |
| friend struct DefaultSingletonTraits<InputMethodStatusConnection>; |
| InputMethodStatusConnection() |
| @@ -1181,4 +1213,18 @@ std::string ChromeOSGetKeyboardOverlayId(const std::string& input_method_id) { |
| return ""; |
| } |
| +extern "C" |
| +void ChromeOSSendHandwritingStrokes(InputMethodStatusConnection* connection, |
| + const HandwritingStrokes& strokes) { |
| + g_return_if_fail(connection); |
| + connection->SendHandwritingStrokes(strokes); |
| +} |
| + |
| +extern "C" |
| +void ChromeOSCancelHandwriting(InputMethodStatusConnection* connection, |
| + int n_strokes) { |
| + g_return_if_fail(connection); |
| + connection->CancelHandwriting(n_strokes); |
| +} |
| + |
| } // namespace chromeos |