diff options
-rw-r--r-- | remoting/host/client_connection.h | 4 | ||||
-rw-r--r-- | remoting/host/event_executor_win.cc | 119 | ||||
-rw-r--r-- | remoting/host/event_executor_win.h | 7 | ||||
-rw-r--r-- | remoting/host/session_manager.cc | 1 | ||||
-rw-r--r-- | remoting/host/session_manager_unittest.cc | 8 |
5 files changed, 121 insertions, 18 deletions
diff --git a/remoting/host/client_connection.h b/remoting/host/client_connection.h index c139ff0..ddd0724 100644 --- a/remoting/host/client_connection.h +++ b/remoting/host/client_connection.h @@ -57,8 +57,8 @@ class ClientConnection : public base::RefCountedThreadSafe<ClientConnection>, // a libjingle channel, these events are delegated to |handler|. // It is guranteed that |handler| is called only on the |message_loop|. ClientConnection(MessageLoop* message_loop, - ProtocolDecoder* decoder, - EventHandler* handler); + ProtocolDecoder* decoder, + EventHandler* handler); virtual ~ClientConnection(); diff --git a/remoting/host/event_executor_win.cc b/remoting/host/event_executor_win.cc index 1bf0ff0..e0235ce 100644 --- a/remoting/host/event_executor_win.cc +++ b/remoting/host/event_executor_win.cc @@ -357,23 +357,17 @@ void EventExecutorWin::HandleInputEvents(ClientMessageList* messages) { for (size_t i = 0; i < messages->size(); ++i) { ChromotingClientMessage* msg = (*messages)[i]; if (msg->has_mouse_set_position_event()) { - // TODO(garykac) Updated Windows host mouse support in following cl. + HandleMouseSetPosition(msg); } else if (msg->has_mouse_move_event()) { - // TODO(garykac) Updated Windows host mouse support in following cl. + HandleMouseMove(msg); } else if (msg->has_mouse_wheel_event()) { - // TODO(garykac) Updated Windows host wheel support in following cl. + HandleMouseWheel(msg); } else if (msg->has_mouse_down_event()) { - // TODO(garykac) Updated Windows host mouse support in following cl. + HandleMouseButtonDown(msg); } else if (msg->has_mouse_up_event()) { - // TODO(garykac) Updated Windows host mouse support in following cl. + HandleMouseButtonUp(msg); } else if (msg->has_key_event()) { - base::KeyboardCode key_code = - WindowsKeyCodeForPosixKeyCode(msg->key_event().key()); - if (key_code != base::VKEY_UNKNOWN) { - keybd_event(key_code, MapVirtualKey(key_code, 0), - msg->key_event().pressed() ? 0 : KEYEVENTF_KEYUP, - NULL); - } + HandleKey(msg); } } // We simply delete all messages. @@ -381,4 +375,105 @@ void EventExecutorWin::HandleInputEvents(ClientMessageList* messages) { STLDeleteElements<ClientMessageList>(messages); } +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(); + + INPUT input; + input.type = INPUT_MOUSE; + input.mi.time = 0; + input.mi.dx = static_cast<int>((x * 65535) / width); + input.mi.dy = static_cast<int>((y * 65535) / height); + input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE; + SendInput(1, &input, sizeof(INPUT)); +} + +void EventExecutorWin::HandleMouseMove(ChromotingClientMessage* msg) { + 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.dwFlags = MOUSEEVENTF_MOVE; + SendInput(1, &input, sizeof(INPUT)); +} + +void EventExecutorWin::HandleMouseWheel(ChromotingClientMessage* msg) { + 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(); + + if (dx != 0) { + input.mi.mouseData = dx; + input.mi.dwFlags = MOUSEEVENTF_HWHEEL; + SendInput(1, &input, sizeof(INPUT)); + } + if (dy != 0) { + input.mi.mouseData = dy; + input.mi.dwFlags = MOUSEEVENTF_WHEEL; + SendInput(1, &input, sizeof(INPUT)); + } +} + +void EventExecutorWin::HandleMouseButtonDown(ChromotingClientMessage* msg) { + 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) { + input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN; + } else if (button == MouseButtonRight) { + input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN; + } else { + input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; + } + + SendInput(1, &input, sizeof(INPUT)); +} + +void EventExecutorWin::HandleMouseButtonUp(ChromotingClientMessage* msg) { + 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) { + input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP; + } else if (button == MouseButtonRight) { + input.mi.dwFlags = MOUSEEVENTF_RIGHTUP; + } else { + input.mi.dwFlags = MOUSEEVENTF_LEFTUP; + } + + SendInput(1, &input, sizeof(INPUT)); +} + +void EventExecutorWin::HandleKey(ChromotingClientMessage* msg) { + INPUT input; + input.type = INPUT_KEYBOARD; + input.ki.time = 0; + input.ki.wVk = 0; + input.ki.wScan = msg->key_event().key(); + input.ki.dwFlags = KEYEVENTF_UNICODE; + if (!msg->key_event().pressed()) { + input.ki.dwFlags |= KEYEVENTF_KEYUP; + } + + SendInput(1, &input, sizeof(INPUT)); +} + } // namespace remoting diff --git a/remoting/host/event_executor_win.h b/remoting/host/event_executor_win.h index 53e790f..86436b3 100644 --- a/remoting/host/event_executor_win.h +++ b/remoting/host/event_executor_win.h @@ -20,6 +20,13 @@ class EventExecutorWin : public EventExecutor { virtual void HandleInputEvents(ClientMessageList* messages); private: + void HandleMouseSetPosition(ChromotingClientMessage* msg); + void HandleMouseMove(ChromotingClientMessage* msg); + void HandleMouseWheel(ChromotingClientMessage* msg); + void HandleMouseButtonDown(ChromotingClientMessage* msg); + void HandleMouseButtonUp(ChromotingClientMessage* msg); + void HandleKey(ChromotingClientMessage* msg); + DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); }; diff --git a/remoting/host/session_manager.cc b/remoting/host/session_manager.cc index b8747dd..3da20b7 100644 --- a/remoting/host/session_manager.cc +++ b/remoting/host/session_manager.cc @@ -324,6 +324,7 @@ void SessionManager::DoSendUpdate(ChromotingHostMessage* message, DCHECK_EQ(network_loop_, MessageLoop::current()); // Create a data buffer in wire format from |message|. + // Note that this takes ownership of |message|. scoped_refptr<media::DataBuffer> data = ClientConnection::CreateWireFormatDataBuffer(message); diff --git a/remoting/host/session_manager_unittest.cc b/remoting/host/session_manager_unittest.cc index 6747b01..7e74e96 100644 --- a/remoting/host/session_manager_unittest.cc +++ b/remoting/host/session_manager_unittest.cc @@ -33,10 +33,10 @@ class SessionManagerTest : public testing::Test { encoder_ = new MockEncoder(); client_ = new MockClientConnection(); record_ = new SessionManager(&message_loop_, - &message_loop_, - &message_loop_, - capturer_, - encoder_); + &message_loop_, + &message_loop_, + capturer_, + encoder_); } scoped_refptr<SessionManager> record_; |