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/event_executor.h" | 5 #include "remoting/host/event_executor.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/XF86keysym.h> | 10 #include <X11/XF86keysym.h> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 // Clipboard stub interface. | 44 // Clipboard stub interface. |
45 virtual void InjectClipboardEvent(const ClipboardEvent& event) | 45 virtual void InjectClipboardEvent(const ClipboardEvent& event) |
46 OVERRIDE; | 46 OVERRIDE; |
47 | 47 |
48 // InputStub interface. | 48 // InputStub interface. |
49 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 49 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
50 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 50 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
51 | 51 |
52 // EventExecutor interface. | 52 // EventExecutor interface. |
53 virtual void Start( | 53 virtual void OnSessionStarted( |
54 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; | 54 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; |
55 virtual void StopAndDelete() OVERRIDE; | 55 virtual void OnSessionFinished() OVERRIDE; |
56 | 56 |
57 private: | 57 private: |
58 // |mode| is one of the AutoRepeatModeOn, AutoRepeatModeOff, | 58 // |mode| is one of the AutoRepeatModeOn, AutoRepeatModeOff, |
59 // AutoRepeatModeDefault constants defined by the XChangeKeyboardControl() | 59 // AutoRepeatModeDefault constants defined by the XChangeKeyboardControl() |
60 // API. | 60 // API. |
61 void SetAutoRepeatForKey(int keycode, int mode); | 61 void SetAutoRepeatForKey(int keycode, int mode); |
62 void InjectScrollWheelClicks(int button, int count); | 62 void InjectScrollWheelClicks(int button, int count); |
63 | 63 |
64 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 64 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
65 | 65 |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 } | 432 } |
433 if (event.has_wheel_offset_x() && event.wheel_offset_x() != 0) { | 433 if (event.has_wheel_offset_x() && event.wheel_offset_x() != 0) { |
434 int dx = event.wheel_offset_x(); | 434 int dx = event.wheel_offset_x(); |
435 InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(dx), | 435 InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(dx), |
436 abs(dx)); | 436 abs(dx)); |
437 } | 437 } |
438 | 438 |
439 XFlush(display_); | 439 XFlush(display_); |
440 } | 440 } |
441 | 441 |
442 void EventExecutorLinux::Start( | 442 void EventExecutorLinux::OnSessionStarted( |
443 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 443 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
444 return; | 444 return; |
445 } | 445 } |
446 | 446 |
447 void EventExecutorLinux::StopAndDelete() { | 447 void EventExecutorLinux::OnSessionFinished() { |
448 delete this; | 448 return; |
449 } | 449 } |
450 | 450 |
451 } // namespace | 451 } // namespace |
452 | 452 |
453 scoped_ptr<EventExecutor> EventExecutor::Create( | 453 scoped_ptr<EventExecutor> EventExecutor::Create( |
454 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 454 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
455 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 455 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
456 scoped_ptr<EventExecutorLinux> executor( | 456 scoped_ptr<EventExecutorLinux> executor( |
457 new EventExecutorLinux(main_task_runner)); | 457 new EventExecutorLinux(main_task_runner)); |
458 if (!executor->Init()) | 458 if (!executor->Init()) |
459 return scoped_ptr<EventExecutor>(NULL); | 459 return scoped_ptr<EventExecutor>(NULL); |
460 return executor.PassAs<EventExecutor>(); | 460 return executor.PassAs<EventExecutor>(); |
461 } | 461 } |
462 | 462 |
463 } // namespace remoting | 463 } // namespace remoting |
OLD | NEW |