OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/input_injector.h" | 5 #include "remoting/host/input_injector.h" |
6 | 6 |
7 #include <X11/extensions/XInput.h> | 7 #include <X11/extensions/XInput.h> |
8 #include <X11/extensions/XTest.h> | 8 #include <X11/extensions/XTest.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/XKBlib.h> | 10 #include <X11/XKBlib.h> |
11 | 11 |
12 #include <set> | 12 #include <set> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/location.h" | 17 #include "base/location.h" |
18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
19 #include "base/strings/utf_string_conversion_utils.h" | 19 #include "base/strings/utf_string_conversion_utils.h" |
20 #include "remoting/base/logging.h" | 20 #include "remoting/base/logging.h" |
21 #if defined(OS_CHROMEOS) | |
22 #include "remoting/host/chromeos/display_transform_util.h" | |
23 #endif | |
21 #include "remoting/host/clipboard.h" | 24 #include "remoting/host/clipboard.h" |
22 #include "remoting/host/linux/unicode_to_keysym.h" | 25 #include "remoting/host/linux/unicode_to_keysym.h" |
23 #include "remoting/proto/internal.pb.h" | 26 #include "remoting/proto/internal.pb.h" |
24 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 27 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
25 #include "ui/events/keycodes/dom4/keycode_converter.h" | 28 #include "ui/events/keycodes/dom4/keycode_converter.h" |
26 | 29 |
27 namespace remoting { | 30 namespace remoting { |
28 | 31 |
29 namespace { | 32 namespace { |
30 | 33 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 VLOG(3) << "Moving mouse by " << event.delta_x() << "," << event.delta_y(); | 397 VLOG(3) << "Moving mouse by " << event.delta_x() << "," << event.delta_y(); |
395 XTestFakeRelativeMotionEvent(display_, | 398 XTestFakeRelativeMotionEvent(display_, |
396 event.delta_x(), event.delta_y(), | 399 event.delta_x(), event.delta_y(), |
397 CurrentTime); | 400 CurrentTime); |
398 | 401 |
399 } else if (event.has_x() && event.has_y()) { | 402 } else if (event.has_x() && event.has_y()) { |
400 // Injecting a motion event immediately before a button release results in | 403 // Injecting a motion event immediately before a button release results in |
401 // a MotionNotify even if the mouse position hasn't changed, which confuses | 404 // a MotionNotify even if the mouse position hasn't changed, which confuses |
402 // apps which assume MotionNotify implies movement. See crbug.com/138075. | 405 // apps which assume MotionNotify implies movement. See crbug.com/138075. |
403 bool inject_motion = true; | 406 bool inject_motion = true; |
404 webrtc::DesktopVector new_mouse_position( | 407 webrtc::DesktopVector new_mouse_position(event.x(), event.y()); |
405 webrtc::DesktopVector(event.x(), event.y())); | 408 #if defined(OS_CHROMEOS) |
409 // When a physical display (1280 x 850) is rotated 90 degs (it is | |
410 // effectively an 850 x 1280) display, Chromoting clients sends mouse events | |
411 // in the rotated co-ordinates system (850 x 1280). However, ChromeOS | |
412 // expects the raw events to match the native resolution. | |
413 // Rotates the co-ordinates of the input events appropriately for the | |
414 // current display rotation settings. | |
415 gfx::PointF screen_location = | |
416 ConvertPointToNativeScreen(gfx::PointF(event.x(), event.y())); | |
417 new_mouse_position.set(screen_location.x(), screen_location.y()); | |
Wez
2014/12/04 01:28:25
Can we do this rotation in the InputInjectorChrome
kelvinp
2014/12/05 03:17:28
This is going to be an interim hack, that will be
| |
418 #endif | |
406 if (event.has_button() && event.has_button_down() && !event.button_down()) { | 419 if (event.has_button() && event.has_button_down() && !event.button_down()) { |
407 if (new_mouse_position.equals(latest_mouse_position_)) | 420 if (new_mouse_position.equals(latest_mouse_position_)) |
408 inject_motion = false; | 421 inject_motion = false; |
409 } | 422 } |
410 | 423 |
411 if (inject_motion) { | 424 if (inject_motion) { |
412 latest_mouse_position_.set(std::max(0, new_mouse_position.x()), | 425 latest_mouse_position_.set(std::max(0, new_mouse_position.x()), |
413 std::max(0, new_mouse_position.y())); | 426 std::max(0, new_mouse_position.y())); |
414 | 427 |
415 VLOG(3) << "Moving mouse to " << latest_mouse_position_.x() | 428 VLOG(3) << "Moving mouse to " << latest_mouse_position_.x() |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 617 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
605 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 618 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
606 scoped_ptr<InputInjectorX11> injector( | 619 scoped_ptr<InputInjectorX11> injector( |
607 new InputInjectorX11(main_task_runner)); | 620 new InputInjectorX11(main_task_runner)); |
608 if (!injector->Init()) | 621 if (!injector->Init()) |
609 return nullptr; | 622 return nullptr; |
610 return injector.Pass(); | 623 return injector.Pass(); |
611 } | 624 } |
612 | 625 |
613 } // namespace remoting | 626 } // namespace remoting |
OLD | NEW |