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/Xlib.h> | 7 #include <X11/Xlib.h> |
8 #include <X11/extensions/XTest.h> | 8 #include <X11/extensions/XTest.h> |
9 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
10 | 10 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 void InputInjectorLinux::Core::InjectMouseEvent(const MouseEvent& event) { | 295 void InputInjectorLinux::Core::InjectMouseEvent(const MouseEvent& event) { |
296 if (!task_runner_->BelongsToCurrentThread()) { | 296 if (!task_runner_->BelongsToCurrentThread()) { |
297 task_runner_->PostTask(FROM_HERE, | 297 task_runner_->PostTask(FROM_HERE, |
298 base::Bind(&Core::InjectMouseEvent, this, event)); | 298 base::Bind(&Core::InjectMouseEvent, this, event)); |
299 return; | 299 return; |
300 } | 300 } |
301 | 301 |
302 if (event.has_x() && event.has_y()) { | 302 if (event.has_delta_x() && event.has_delta_y()) { |
303 latest_mouse_position_ = SkIPoint::Make(-1, -1); | |
304 VLOG(3) << "Moving mouse by " << event.delta_x() << "," << event.delta_y(); | |
305 XTestFakeRelativeMotionEvent(display_, DefaultScreen(display_), | |
306 event.delta_x(), event.delta_y(), | |
307 CurrentTime); | |
Wez
2013/09/05 20:24:45
nit: Filter out 0x0 movement?
alexeypa (please no reviews)
2013/09/06 20:00:17
Done.
| |
308 | |
309 } else if (event.has_x() && event.has_y()) { | |
303 // Injecting a motion event immediately before a button release results in | 310 // Injecting a motion event immediately before a button release results in |
304 // a MotionNotify even if the mouse position hasn't changed, which confuses | 311 // a MotionNotify even if the mouse position hasn't changed, which confuses |
305 // apps which assume MotionNotify implies movement. See crbug.com/138075. | 312 // apps which assume MotionNotify implies movement. See crbug.com/138075. |
306 bool inject_motion = true; | 313 bool inject_motion = true; |
307 SkIPoint new_mouse_position(SkIPoint::Make(event.x(), event.y())); | 314 SkIPoint new_mouse_position(SkIPoint::Make(event.x(), event.y())); |
308 if (event.has_button() && event.has_button_down() && !event.button_down()) { | 315 if (event.has_button() && event.has_button_down() && !event.button_down()) { |
309 if (new_mouse_position == latest_mouse_position_) | 316 if (new_mouse_position == latest_mouse_position_) |
310 inject_motion = false; | 317 inject_motion = false; |
311 } | 318 } |
312 | 319 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 514 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
508 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 515 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
509 scoped_ptr<InputInjectorLinux> injector( | 516 scoped_ptr<InputInjectorLinux> injector( |
510 new InputInjectorLinux(main_task_runner)); | 517 new InputInjectorLinux(main_task_runner)); |
511 if (!injector->Init()) | 518 if (!injector->Init()) |
512 return scoped_ptr<InputInjector>(); | 519 return scoped_ptr<InputInjector>(); |
513 return injector.PassAs<InputInjector>(); | 520 return injector.PassAs<InputInjector>(); |
514 } | 521 } |
515 | 522 |
516 } // namespace remoting | 523 } // namespace remoting |
OLD | NEW |