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

Side by Side Diff: remoting/host/event_executor_win.cc

Issue 3187021: Mouse support for chromoting host. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/event_executor_win.h ('k') | remoting/host/session_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 EventExecutorWin::EventExecutorWin() { 350 EventExecutorWin::EventExecutorWin() {
351 } 351 }
352 352
353 EventExecutorWin::~EventExecutorWin() { 353 EventExecutorWin::~EventExecutorWin() {
354 } 354 }
355 355
356 void EventExecutorWin::HandleInputEvents(ClientMessageList* messages) { 356 void EventExecutorWin::HandleInputEvents(ClientMessageList* messages) {
357 for (size_t i = 0; i < messages->size(); ++i) { 357 for (size_t i = 0; i < messages->size(); ++i) {
358 ChromotingClientMessage* msg = (*messages)[i]; 358 ChromotingClientMessage* msg = (*messages)[i];
359 if (msg->has_mouse_set_position_event()) { 359 if (msg->has_mouse_set_position_event()) {
360 // TODO(garykac) Updated Windows host mouse support in following cl. 360 HandleMouseSetPosition(msg);
361 } else if (msg->has_mouse_move_event()) { 361 } else if (msg->has_mouse_move_event()) {
362 // TODO(garykac) Updated Windows host mouse support in following cl. 362 HandleMouseMove(msg);
363 } else if (msg->has_mouse_wheel_event()) { 363 } else if (msg->has_mouse_wheel_event()) {
364 // TODO(garykac) Updated Windows host wheel support in following cl. 364 HandleMouseWheel(msg);
365 } else if (msg->has_mouse_down_event()) { 365 } else if (msg->has_mouse_down_event()) {
366 // TODO(garykac) Updated Windows host mouse support in following cl. 366 HandleMouseButtonDown(msg);
367 } else if (msg->has_mouse_up_event()) { 367 } else if (msg->has_mouse_up_event()) {
368 // TODO(garykac) Updated Windows host mouse support in following cl. 368 HandleMouseButtonUp(msg);
369 } else if (msg->has_key_event()) { 369 } else if (msg->has_key_event()) {
370 base::KeyboardCode key_code = 370 HandleKey(msg);
371 WindowsKeyCodeForPosixKeyCode(msg->key_event().key());
372 if (key_code != base::VKEY_UNKNOWN) {
373 keybd_event(key_code, MapVirtualKey(key_code, 0),
374 msg->key_event().pressed() ? 0 : KEYEVENTF_KEYUP,
375 NULL);
376 }
377 } 371 }
378 } 372 }
379 // We simply delete all messages. 373 // We simply delete all messages.
380 // TODO(hclam): Delete messages processed. 374 // TODO(hclam): Delete messages processed.
381 STLDeleteElements<ClientMessageList>(messages); 375 STLDeleteElements<ClientMessageList>(messages);
382 } 376 }
383 377
378 void EventExecutorWin::HandleMouseSetPosition(ChromotingClientMessage* msg) {
379 int x = msg->mouse_set_position_event().x();
380 int y = msg->mouse_set_position_event().y();
381 int width = msg->mouse_set_position_event().width();
382 int height = msg->mouse_set_position_event().height();
383
384 INPUT input;
385 input.type = INPUT_MOUSE;
386 input.mi.time = 0;
387 input.mi.dx = static_cast<int>((x * 65535) / width);
388 input.mi.dy = static_cast<int>((y * 65535) / height);
389 input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
390 SendInput(1, &input, sizeof(INPUT));
391 }
392
393 void EventExecutorWin::HandleMouseMove(ChromotingClientMessage* msg) {
394 INPUT input;
395 input.type = INPUT_MOUSE;
396 input.mi.time = 0;
397 input.mi.dx = msg->mouse_move_event().offset_x();
398 input.mi.dy = msg->mouse_move_event().offset_y();
399 input.mi.dwFlags = MOUSEEVENTF_MOVE;
400 SendInput(1, &input, sizeof(INPUT));
401 }
402
403 void EventExecutorWin::HandleMouseWheel(ChromotingClientMessage* msg) {
404 INPUT input;
405 input.type = INPUT_MOUSE;
406 input.mi.time = 0;
407
408 int dx = msg->mouse_wheel_event().offset_x();
409 int dy = msg->mouse_wheel_event().offset_y();
410
411 if (dx != 0) {
412 input.mi.mouseData = dx;
413 input.mi.dwFlags = MOUSEEVENTF_HWHEEL;
414 SendInput(1, &input, sizeof(INPUT));
415 }
416 if (dy != 0) {
417 input.mi.mouseData = dy;
418 input.mi.dwFlags = MOUSEEVENTF_WHEEL;
419 SendInput(1, &input, sizeof(INPUT));
420 }
421 }
422
423 void EventExecutorWin::HandleMouseButtonDown(ChromotingClientMessage* msg) {
424 INPUT input;
425 input.type = INPUT_MOUSE;
426 input.mi.time = 0;
427 input.mi.dx = 0;
428 input.mi.dy = 0;
429
430 MouseButton button = msg->mouse_down_event().button();
431 if (button == MouseButtonLeft) {
432 input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
433 } else if (button == MouseButtonMiddle) {
434 input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
435 } else if (button == MouseButtonRight) {
436 input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
437 } else {
438 input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
439 }
440
441 SendInput(1, &input, sizeof(INPUT));
442 }
443
444 void EventExecutorWin::HandleMouseButtonUp(ChromotingClientMessage* msg) {
445 INPUT input;
446 input.type = INPUT_MOUSE;
447 input.mi.time = 0;
448 input.mi.dx = 0;
449 input.mi.dy = 0;
450
451 MouseButton button = msg->mouse_down_event().button();
452 if (button == MouseButtonLeft) {
453 input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
454 } else if (button == MouseButtonMiddle) {
455 input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
456 } else if (button == MouseButtonRight) {
457 input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
458 } else {
459 input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
460 }
461
462 SendInput(1, &input, sizeof(INPUT));
463 }
464
465 void EventExecutorWin::HandleKey(ChromotingClientMessage* msg) {
466 INPUT input;
467 input.type = INPUT_KEYBOARD;
468 input.ki.time = 0;
469 input.ki.wVk = 0;
470 input.ki.wScan = msg->key_event().key();
471 input.ki.dwFlags = KEYEVENTF_UNICODE;
472 if (!msg->key_event().pressed()) {
473 input.ki.dwFlags |= KEYEVENTF_KEYUP;
474 }
475
476 SendInput(1, &input, sizeof(INPUT));
477 }
478
384 } // namespace remoting 479 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/event_executor_win.h ('k') | remoting/host/session_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698