diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-28 07:49:56 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-28 07:49:56 +0000 |
commit | f02f6f5e35504369f8537b783766b9591dce4c35 (patch) | |
tree | 31d539242a1dbd16062c6e82189b6c43c610d5ba /remoting/client/jni | |
parent | e5b822b5da1f0fce7d388cdb577af581c69e739d (diff) | |
download | chromium_src-f02f6f5e35504369f8537b783766b9591dce4c35.zip chromium_src-f02f6f5e35504369f8537b783766b9591dce4c35.tar.gz chromium_src-f02f6f5e35504369f8537b783766b9591dce4c35.tar.bz2 |
Send TextEvent message from Android client
The new message is currently used only for keys for which Android
generates ACTION_MULTIPLE events.
BUG=265945,270356
R=lambroslambrou@chromium.org
Review URL: https://codereview.chromium.org/214173002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260088 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/jni')
-rw-r--r-- | remoting/client/jni/chromoting_jni_instance.cc | 54 | ||||
-rw-r--r-- | remoting/client/jni/chromoting_jni_instance.h | 13 | ||||
-rw-r--r-- | remoting/client/jni/chromoting_jni_runtime.cc | 50 |
3 files changed, 67 insertions, 50 deletions
diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc index 92b7615..883df5a 100644 --- a/remoting/client/jni/chromoting_jni_instance.cc +++ b/remoting/client/jni/chromoting_jni_instance.cc @@ -128,62 +128,74 @@ void ChromotingJniInstance::RedrawDesktop() { jni_runtime_->RedrawCanvas(); } -void ChromotingJniInstance::PerformMouseAction( +void ChromotingJniInstance::SendMouseEvent( int x, int y, protocol::MouseEvent_MouseButton button, bool button_down) { if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { jni_runtime_->network_task_runner()->PostTask( - FROM_HERE, base::Bind(&ChromotingJniInstance::PerformMouseAction, + FROM_HERE, base::Bind(&ChromotingJniInstance::SendMouseEvent, this, x, y, button, button_down)); return; } - protocol::MouseEvent action; - action.set_x(x); - action.set_y(y); - action.set_button(button); + protocol::MouseEvent event; + event.set_x(x); + event.set_y(y); + event.set_button(button); if (button != protocol::MouseEvent::BUTTON_UNDEFINED) - action.set_button_down(button_down); + event.set_button_down(button_down); - connection_->input_stub()->InjectMouseEvent(action); + connection_->input_stub()->InjectMouseEvent(event); } -void ChromotingJniInstance::PerformMouseWheelDeltaAction(int delta_x, - int delta_y) { +void ChromotingJniInstance::SendMouseWheelEvent(int delta_x, int delta_y) { if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { jni_runtime_->network_task_runner()->PostTask( FROM_HERE, - base::Bind(&ChromotingJniInstance::PerformMouseWheelDeltaAction, this, + base::Bind(&ChromotingJniInstance::SendMouseWheelEvent, this, delta_x, delta_y)); return; } - protocol::MouseEvent action; - action.set_wheel_delta_x(delta_x); - action.set_wheel_delta_y(delta_y); - connection_->input_stub()->InjectMouseEvent(action); + protocol::MouseEvent event; + event.set_wheel_delta_x(delta_x); + event.set_wheel_delta_y(delta_y); + connection_->input_stub()->InjectMouseEvent(event); } -void ChromotingJniInstance::PerformKeyboardAction(int key_code, bool key_down) { +void ChromotingJniInstance::SendKeyEvent(int key_code, bool key_down) { if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { jni_runtime_->network_task_runner()->PostTask( - FROM_HERE, base::Bind(&ChromotingJniInstance::PerformKeyboardAction, + FROM_HERE, base::Bind(&ChromotingJniInstance::SendKeyEvent, this, key_code, key_down)); return; } uint32 usb_code = AndroidKeycodeToUsbKeycode(key_code); if (usb_code) { - protocol::KeyEvent action; - action.set_usb_keycode(usb_code); - action.set_pressed(key_down); - connection_->input_stub()->InjectKeyEvent(action); + protocol::KeyEvent event; + event.set_usb_keycode(usb_code); + event.set_pressed(key_down); + connection_->input_stub()->InjectKeyEvent(event); } else { LOG(WARNING) << "Ignoring unknown keycode: " << key_code; } } +void ChromotingJniInstance::SendTextEvent(const std::string& text) { + if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { + jni_runtime_->network_task_runner()->PostTask( + FROM_HERE, + base::Bind(&ChromotingJniInstance::SendTextEvent, this, text)); + return; + } + + protocol::TextEvent event; + event.set_text(text); + connection_->input_stub()->InjectTextEvent(event); +} + void ChromotingJniInstance::RecordPaintTime(int64 paint_time_ms) { if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { jni_runtime_->network_task_runner()->PostTask( diff --git a/remoting/client/jni/chromoting_jni_instance.h b/remoting/client/jni/chromoting_jni_instance.h index 64be741..edb8b4a 100644 --- a/remoting/client/jni/chromoting_jni_instance.h +++ b/remoting/client/jni/chromoting_jni_instance.h @@ -65,14 +65,15 @@ class ChromotingJniInstance // Moves the host's cursor to the specified coordinates, optionally with some // mouse button depressed. If |button| is BUTTON_UNDEFINED, no click is made. - void PerformMouseAction(int x, int y, - protocol::MouseEvent_MouseButton button, - bool button_down); - - void PerformMouseWheelDeltaAction(int delta_x, int delta_y); + void SendMouseEvent(int x, int y, + protocol::MouseEvent_MouseButton button, + bool button_down); + void SendMouseWheelEvent(int delta_x, int delta_y); // Sends the provided keyboard scan code to the host. - void PerformKeyboardAction(int key_code, bool key_down); + void SendKeyEvent(int key_code, bool key_down); + + void SendTextEvent(const std::string& text); // Records paint time for statistics logging, if enabled. May be called from // any thread. diff --git a/remoting/client/jni/chromoting_jni_runtime.cc b/remoting/client/jni/chromoting_jni_runtime.cc index 7a23487..06cd7ff 100644 --- a/remoting/client/jni/chromoting_jni_runtime.cc +++ b/remoting/client/jni/chromoting_jni_runtime.cc @@ -103,38 +103,42 @@ static void ScheduleRedraw(JNIEnv* env, jclass clazz) { remoting::ChromotingJniRuntime::GetInstance()->session()->RedrawDesktop(); } -static void MouseAction(JNIEnv* env, - jclass clazz, - jint x, - jint y, - jint whichButton, - jboolean buttonDown) { +static void SendMouseEvent(JNIEnv* env, + jclass clazz, + jint x, + jint y, + jint whichButton, + jboolean buttonDown) { // Button must be within the bounds of the MouseEvent_MouseButton enum. DCHECK(whichButton >= 0 && whichButton < 5); - remoting::ChromotingJniRuntime::GetInstance()->session()->PerformMouseAction( - x, - y, + remoting::ChromotingJniRuntime::GetInstance()->session()->SendMouseEvent( + x, y, static_cast<remoting::protocol::MouseEvent_MouseButton>(whichButton), buttonDown); } -static void MouseWheelDeltaAction(JNIEnv* env, - jclass clazz, - jint delta_x, - jint delta_y) { - remoting::ChromotingJniRuntime::GetInstance() - ->session() - ->PerformMouseWheelDeltaAction(delta_x, delta_y); +static void SendMouseWheelEvent(JNIEnv* env, + jclass clazz, + jint delta_x, + jint delta_y) { + remoting::ChromotingJniRuntime::GetInstance()->session()->SendMouseWheelEvent( + delta_x, delta_y); } -static void KeyboardAction(JNIEnv* env, - jclass clazz, - jint keyCode, - jboolean keyDown) { - remoting::ChromotingJniRuntime::GetInstance() - ->session() - ->PerformKeyboardAction(keyCode, keyDown); +static void SendKeyEvent(JNIEnv* env, + jclass clazz, + jint keyCode, + jboolean keyDown) { + remoting::ChromotingJniRuntime::GetInstance()->session()->SendKeyEvent( + keyCode, keyDown); +} + +static void SendTextEvent(JNIEnv* env, + jclass clazz, + jstring text) { + remoting::ChromotingJniRuntime::GetInstance()->session()->SendTextEvent( + ConvertJavaStringToUTF8(env, text)); } // ChromotingJniRuntime implementation. |