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

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: style fix; changed the function name following zork's suggestion 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') | no next file with comments »
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..4edb03240a7b09a516d8f7ddc4e3224dbcbfcd2a 100644
--- a/chromeos_input_method.cc
+++ b/chromeos_input_method.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -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 SendHandwritingStroke(const HandwritingStroke& stroke) {
+ if (stroke.size() < 2) {
+ LOG(WARNING) << "Empty stroke data or a single dot is passed.";
+ return;
+ }
+
+ IBusInputContext* context = GetInputContext(input_context_path_, ibus_);
+ if (!context) {
+ return;
+ }
+
+ const size_t raw_stroke_size = stroke.size() * 2;
+ scoped_array<double> raw_stroke(new double[raw_stroke_size]);
+ for (size_t n = 0; n < stroke.size(); ++n) {
+ raw_stroke[n * 2] = stroke[n].first; // x
+ raw_stroke[n * 2 + 1] = stroke[n].second; // y
+ }
+ ibus_input_context_process_hand_writing_event(
+ context, raw_stroke.get(), raw_stroke_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 ChromeOSSendHandwritingStroke(InputMethodStatusConnection* connection,
+ const HandwritingStroke& stroke) {
+ g_return_if_fail(connection);
+ connection->SendHandwritingStroke(stroke);
+}
+
+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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698