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

Unified Diff: remoting/host/event_executor_win.cc

Issue 4726003: Implement InputStub in the host side for chromoting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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
Index: remoting/host/event_executor_win.cc
diff --git a/remoting/host/event_executor_win.cc b/remoting/host/event_executor_win.cc
index 283d4aa8f84ec927e75850c2e96b341cf2973a60..bfaa9612f30f5d1ba66a9ac11439c3ecf0796a0b 100644
--- a/remoting/host/event_executor_win.cc
+++ b/remoting/host/event_executor_win.cc
@@ -5,8 +5,10 @@
#include "remoting/host/event_executor_win.h"
#include <windows.h>
+
#include "app/keyboard_codes.h"
#include "base/stl_util-inl.h"
+#include "base/task.h"
#include "remoting/host/capturer.h"
// TODO(hclam): Should not include internal.pb.h here.
#include "remoting/proto/internal.pb.h"
@@ -14,35 +16,36 @@
namespace remoting {
EventExecutorWin::EventExecutorWin(Capturer* capturer)
- : EventExecutor(capturer) {
+ : capturer_(capturer) {
}
EventExecutorWin::~EventExecutorWin() {
}
-void EventExecutorWin::HandleInputEvent(ChromotingClientMessage* msg) {
- if (msg->has_mouse_set_position_event()) {
- HandleMouseSetPosition(msg);
- } else if (msg->has_mouse_move_event()) {
- HandleMouseMove(msg);
- } else if (msg->has_mouse_wheel_event()) {
- HandleMouseWheel(msg);
- } else if (msg->has_mouse_down_event()) {
- HandleMouseButtonDown(msg);
- } else if (msg->has_mouse_up_event()) {
- HandleMouseButtonUp(msg);
- } else if (msg->has_key_event()) {
- HandleKey(msg);
- }
- delete msg;
+void EventExecutorMac::InjectKeyEvent(const KeyEvent* event, Task* done) {
awong 2010/11/10 19:36:54 You should talk to Dave about this. I would be ha
+ HandleKey(event->key(), event->pressed());
+ done->Run();
+ delete done;
}
-void EventExecutorWin::HandleMouseSetPosition(ChromotingClientMessage* msg) {
- int x = msg->mouse_set_position_event().x();
- int y = msg->mouse_set_position_event().y();
- int width = msg->mouse_set_position_event().width();
- int height = msg->mouse_set_position_event().height();
+void EventExecutorMac::InjectMouseEvent(const MouseEvent* event, Task* done) {
+ if (event->has_mouse_x()) {
+ HandleMouseSetPosition(event->mouse_x(), event->mouse_y(),
+ event->mouse_width(), event->mouse_height());
+ } else if (event->has_wheel_offset_x()) {
+ HandleMouseWheel(event->wheel_offset_x(), event->wheel_offset_y());
+ } else if (event->has_button()) {
+ if (event->button_down())
+ HandleMouseButtonDown(event->button());
+ else
+ HandleMouseButtonUp(event->button());
+ }
+ done->Run();
+ delete done;
+}
+void EventExecutorWin::HandleMouseSetPosition(
+ int x, int y, int width, int height) {
// Get width and height from the capturer if they are missing from the
// message.
if (width == 0 || height == 0) {
@@ -62,23 +65,23 @@ void EventExecutorWin::HandleMouseSetPosition(ChromotingClientMessage* msg) {
SendInput(1, &input, sizeof(INPUT));
}
-void EventExecutorWin::HandleMouseMove(ChromotingClientMessage* msg) {
+void EventExecutorWin::HandleMouseMove(int offset_x, int offset_y) {
INPUT input;
input.type = INPUT_MOUSE;
input.mi.time = 0;
- input.mi.dx = msg->mouse_move_event().offset_x();
- input.mi.dy = msg->mouse_move_event().offset_y();
+ input.mi.dx = offset_x;
+ input.mi.dy = offset_y;
input.mi.dwFlags = MOUSEEVENTF_MOVE;
SendInput(1, &input, sizeof(INPUT));
}
-void EventExecutorWin::HandleMouseWheel(ChromotingClientMessage* msg) {
+void EventExecutorWin::HandleMouseWheel(int offset_x, int offset_y) {
INPUT input;
input.type = INPUT_MOUSE;
input.mi.time = 0;
- int dx = msg->mouse_wheel_event().offset_x();
- int dy = msg->mouse_wheel_event().offset_y();
+ int dx = offset_x;
+ int dy = offset_y;
if (dx != 0) {
input.mi.mouseData = dx;
@@ -92,14 +95,13 @@ void EventExecutorWin::HandleMouseWheel(ChromotingClientMessage* msg) {
}
}
-void EventExecutorWin::HandleMouseButtonDown(ChromotingClientMessage* msg) {
+void EventExecutorWin::HandleMouseButtonDown(MouseButton button) {
INPUT input;
input.type = INPUT_MOUSE;
input.mi.time = 0;
input.mi.dx = 0;
input.mi.dy = 0;
- MouseButton button = msg->mouse_down_event().button();
if (button == MouseButtonLeft) {
input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
} else if (button == MouseButtonMiddle) {
@@ -113,14 +115,13 @@ void EventExecutorWin::HandleMouseButtonDown(ChromotingClientMessage* msg) {
SendInput(1, &input, sizeof(INPUT));
}
-void EventExecutorWin::HandleMouseButtonUp(ChromotingClientMessage* msg) {
+void EventExecutorWin::HandleMouseButtonUp(MouseButtom button) {
INPUT input;
input.type = INPUT_MOUSE;
input.mi.time = 0;
input.mi.dx = 0;
input.mi.dy = 0;
- MouseButton button = msg->mouse_down_event().button();
if (button == MouseButtonLeft) {
input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
} else if (button == MouseButtonMiddle) {
@@ -134,10 +135,7 @@ void EventExecutorWin::HandleMouseButtonUp(ChromotingClientMessage* msg) {
SendInput(1, &input, sizeof(INPUT));
}
-void EventExecutorWin::HandleKey(ChromotingClientMessage* msg) {
- int key = msg->key_event().key();
- bool down = msg->key_event().pressed();
-
+void EventExecutorWin::HandleKey(int key, bool down) {
// Calculate scan code from virtual key.
HKL hkl = GetKeyboardLayout(0);
int scan_code = MapVirtualKeyEx(key, MAPVK_VK_TO_VSC_EX, hkl);

Powered by Google App Engine
This is Rietveld 408576698