| 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/point_transformer.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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 167 |
| 165 int test_event_base_; | 168 int test_event_base_; |
| 166 int test_error_base_; | 169 int test_error_base_; |
| 167 | 170 |
| 168 // Number of buttons we support. | 171 // Number of buttons we support. |
| 169 // Left, Right, Middle, VScroll Up/Down, HScroll Left/Right. | 172 // Left, Right, Middle, VScroll Up/Down, HScroll Left/Right. |
| 170 static const int kNumPointerButtons = 7; | 173 static const int kNumPointerButtons = 7; |
| 171 | 174 |
| 172 int pointer_button_map_[kNumPointerButtons]; | 175 int pointer_button_map_[kNumPointerButtons]; |
| 173 | 176 |
| 177 #if defined(OS_CHROMEOS) |
| 178 PointTransformer point_transformer_; |
| 179 #endif |
| 180 |
| 174 scoped_ptr<Clipboard> clipboard_; | 181 scoped_ptr<Clipboard> clipboard_; |
| 175 | 182 |
| 176 bool saved_auto_repeat_enabled_; | 183 bool saved_auto_repeat_enabled_; |
| 177 | 184 |
| 178 DISALLOW_COPY_AND_ASSIGN(Core); | 185 DISALLOW_COPY_AND_ASSIGN(Core); |
| 179 }; | 186 }; |
| 180 | 187 |
| 181 scoped_refptr<Core> core_; | 188 scoped_refptr<Core> core_; |
| 182 | 189 |
| 183 DISALLOW_COPY_AND_ASSIGN(InputInjectorX11); | 190 DISALLOW_COPY_AND_ASSIGN(InputInjectorX11); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 VLOG(3) << "Moving mouse by " << event.delta_x() << "," << event.delta_y(); | 401 VLOG(3) << "Moving mouse by " << event.delta_x() << "," << event.delta_y(); |
| 395 XTestFakeRelativeMotionEvent(display_, | 402 XTestFakeRelativeMotionEvent(display_, |
| 396 event.delta_x(), event.delta_y(), | 403 event.delta_x(), event.delta_y(), |
| 397 CurrentTime); | 404 CurrentTime); |
| 398 | 405 |
| 399 } else if (event.has_x() && event.has_y()) { | 406 } else if (event.has_x() && event.has_y()) { |
| 400 // Injecting a motion event immediately before a button release results in | 407 // Injecting a motion event immediately before a button release results in |
| 401 // a MotionNotify even if the mouse position hasn't changed, which confuses | 408 // a MotionNotify even if the mouse position hasn't changed, which confuses |
| 402 // apps which assume MotionNotify implies movement. See crbug.com/138075. | 409 // apps which assume MotionNotify implies movement. See crbug.com/138075. |
| 403 bool inject_motion = true; | 410 bool inject_motion = true; |
| 404 webrtc::DesktopVector new_mouse_position( | 411 webrtc::DesktopVector new_mouse_position(event.x(), event.y()); |
| 405 webrtc::DesktopVector(event.x(), event.y())); | 412 #if defined(OS_CHROMEOS) |
| 413 // Interim hack to handle display rotation on Chrome OS. |
| 414 // TODO(kelvin): Remove this when Chrome OS has completely migrated to |
| 415 // Ozone (crbug.com/439287). |
| 416 gfx::PointF screen_location = point_transformer_.ToScreenCoordinates( |
| 417 gfx::PointF(event.x(), event.y())); |
| 418 new_mouse_position.set(screen_location.x(), screen_location.y()); |
| 419 #endif |
| 406 if (event.has_button() && event.has_button_down() && !event.button_down()) { | 420 if (event.has_button() && event.has_button_down() && !event.button_down()) { |
| 407 if (new_mouse_position.equals(latest_mouse_position_)) | 421 if (new_mouse_position.equals(latest_mouse_position_)) |
| 408 inject_motion = false; | 422 inject_motion = false; |
| 409 } | 423 } |
| 410 | 424 |
| 411 if (inject_motion) { | 425 if (inject_motion) { |
| 412 latest_mouse_position_.set(std::max(0, new_mouse_position.x()), | 426 latest_mouse_position_.set(std::max(0, new_mouse_position.x()), |
| 413 std::max(0, new_mouse_position.y())); | 427 std::max(0, new_mouse_position.y())); |
| 414 | 428 |
| 415 VLOG(3) << "Moving mouse to " << latest_mouse_position_.x() | 429 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, | 618 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 605 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 619 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 606 scoped_ptr<InputInjectorX11> injector( | 620 scoped_ptr<InputInjectorX11> injector( |
| 607 new InputInjectorX11(main_task_runner)); | 621 new InputInjectorX11(main_task_runner)); |
| 608 if (!injector->Init()) | 622 if (!injector->Init()) |
| 609 return nullptr; | 623 return nullptr; |
| 610 return injector.Pass(); | 624 return injector.Pass(); |
| 611 } | 625 } |
| 612 | 626 |
| 613 } // namespace remoting | 627 } // namespace remoting |
| OLD | NEW |