| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/event_executor_win.h" | 5 #include "remoting/host/event_executor_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include "base/keyboard_codes.h" | 8 #include "base/keyboard_codes.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "remoting/host/capturer.h" |
| 10 | 11 |
| 11 namespace remoting { | 12 namespace remoting { |
| 12 | 13 |
| 13 // TODO(hclam): Move this method to base. | 14 // TODO(hclam): Move this method to base. |
| 14 // TODO(hclam): Using values look ugly, change it to something else. | 15 // TODO(hclam): Using values look ugly, change it to something else. |
| 15 static base::KeyboardCode WindowsKeyCodeForPosixKeyCode(int keycode) { | 16 static base::KeyboardCode WindowsKeyCodeForPosixKeyCode(int keycode) { |
| 16 switch (keycode) { | 17 switch (keycode) { |
| 17 case 0x08: | 18 case 0x08: |
| 18 return base::VKEY_BACK; | 19 return base::VKEY_BACK; |
| 19 case 0x09: | 20 case 0x09: |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return base::VKEY_NONAME; | 341 return base::VKEY_NONAME; |
| 341 case 0xFD: | 342 case 0xFD: |
| 342 return base::VKEY_PA1; | 343 return base::VKEY_PA1; |
| 343 case 0xFE: | 344 case 0xFE: |
| 344 return base::VKEY_OEM_CLEAR; | 345 return base::VKEY_OEM_CLEAR; |
| 345 default: | 346 default: |
| 346 return base::VKEY_UNKNOWN; | 347 return base::VKEY_UNKNOWN; |
| 347 } | 348 } |
| 348 } | 349 } |
| 349 | 350 |
| 350 EventExecutorWin::EventExecutorWin() { | 351 EventExecutorWin::EventExecutorWin(Capturer* capturer) |
| 352 : EventExecutor(capturer) { |
| 351 } | 353 } |
| 352 | 354 |
| 353 EventExecutorWin::~EventExecutorWin() { | 355 EventExecutorWin::~EventExecutorWin() { |
| 354 } | 356 } |
| 355 | 357 |
| 356 void EventExecutorWin::HandleInputEvents(ClientMessageList* messages) { | 358 void EventExecutorWin::HandleInputEvents(ClientMessageList* messages) { |
| 357 for (size_t i = 0; i < messages->size(); ++i) { | 359 for (size_t i = 0; i < messages->size(); ++i) { |
| 358 ChromotingClientMessage* msg = (*messages)[i]; | 360 ChromotingClientMessage* msg = (*messages)[i]; |
| 359 if (msg->has_mouse_set_position_event()) { | 361 if (msg->has_mouse_set_position_event()) { |
| 360 HandleMouseSetPosition(msg); | 362 HandleMouseSetPosition(msg); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 374 // TODO(hclam): Delete messages processed. | 376 // TODO(hclam): Delete messages processed. |
| 375 STLDeleteElements<ClientMessageList>(messages); | 377 STLDeleteElements<ClientMessageList>(messages); |
| 376 } | 378 } |
| 377 | 379 |
| 378 void EventExecutorWin::HandleMouseSetPosition(ChromotingClientMessage* msg) { | 380 void EventExecutorWin::HandleMouseSetPosition(ChromotingClientMessage* msg) { |
| 379 int x = msg->mouse_set_position_event().x(); | 381 int x = msg->mouse_set_position_event().x(); |
| 380 int y = msg->mouse_set_position_event().y(); | 382 int y = msg->mouse_set_position_event().y(); |
| 381 int width = msg->mouse_set_position_event().width(); | 383 int width = msg->mouse_set_position_event().width(); |
| 382 int height = msg->mouse_set_position_event().height(); | 384 int height = msg->mouse_set_position_event().height(); |
| 383 | 385 |
| 386 // Get width and height from the capturer if they are missing from the |
| 387 // message. |
| 388 if (width == 0 || height == 0) { |
| 389 width = capturer_->width(); |
| 390 height = capturer_->height(); |
| 391 } |
| 392 if (width == 0 || height == 0) { |
| 393 return; |
| 394 } |
| 395 |
| 396 |
| 384 INPUT input; | 397 INPUT input; |
| 385 input.type = INPUT_MOUSE; | 398 input.type = INPUT_MOUSE; |
| 386 input.mi.time = 0; | 399 input.mi.time = 0; |
| 387 input.mi.dx = static_cast<int>((x * 65535) / width); | 400 input.mi.dx = static_cast<int>((x * 65535) / width); |
| 388 input.mi.dy = static_cast<int>((y * 65535) / height); | 401 input.mi.dy = static_cast<int>((y * 65535) / height); |
| 389 input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE; | 402 input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE; |
| 390 SendInput(1, &input, sizeof(INPUT)); | 403 SendInput(1, &input, sizeof(INPUT)); |
| 391 } | 404 } |
| 392 | 405 |
| 393 void EventExecutorWin::HandleMouseMove(ChromotingClientMessage* msg) { | 406 void EventExecutorWin::HandleMouseMove(ChromotingClientMessage* msg) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 input.ki.wScan = msg->key_event().key(); | 483 input.ki.wScan = msg->key_event().key(); |
| 471 input.ki.dwFlags = KEYEVENTF_UNICODE; | 484 input.ki.dwFlags = KEYEVENTF_UNICODE; |
| 472 if (!msg->key_event().pressed()) { | 485 if (!msg->key_event().pressed()) { |
| 473 input.ki.dwFlags |= KEYEVENTF_KEYUP; | 486 input.ki.dwFlags |= KEYEVENTF_KEYUP; |
| 474 } | 487 } |
| 475 | 488 |
| 476 SendInput(1, &input, sizeof(INPUT)); | 489 SendInput(1, &input, sizeof(INPUT)); |
| 477 } | 490 } |
| 478 | 491 |
| 479 } // namespace remoting | 492 } // namespace remoting |
| OLD | NEW |