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

Unified Diff: chromeos_input_method.cc

Issue 6880171: Add two libcros interfaces for handwriting: SendHandwritingStrokes and CancelHandwriting. (Closed) Base URL: ssh://gitrw.chromium.org:9222/cros.git@master
Patch Set: review Created 9 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos_input_method.h ('k') | load.cc » ('j') | load.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chromeos_input_method.h ('k') | load.cc » ('j') | load.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698