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/extensions/XTest.h> | 10 #include <X11/extensions/XTest.h> |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // Clipboard stub interface. | 42 // Clipboard stub interface. |
43 virtual void InjectClipboardEvent(const ClipboardEvent& event) | 43 virtual void InjectClipboardEvent(const ClipboardEvent& event) |
44 OVERRIDE; | 44 OVERRIDE; |
45 | 45 |
46 // InputStub interface. | 46 // InputStub interface. |
47 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 47 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
48 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 48 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
49 | 49 |
50 // EventExecutor interface. | 50 // EventExecutor interface. |
51 virtual void OnSessionStarted( | 51 virtual void Start( |
52 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; | 52 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; |
53 virtual void OnSessionFinished() OVERRIDE; | 53 virtual void StopAndDelete() OVERRIDE; |
54 | 54 |
55 private: | 55 private: |
56 // |mode| is one of the AutoRepeatModeOn, AutoRepeatModeOff, | 56 // |mode| is one of the AutoRepeatModeOn, AutoRepeatModeOff, |
57 // AutoRepeatModeDefault constants defined by the XChangeKeyboardControl() | 57 // AutoRepeatModeDefault constants defined by the XChangeKeyboardControl() |
58 // API. | 58 // API. |
59 void SetAutoRepeatForKey(int keycode, int mode); | 59 void SetAutoRepeatForKey(int keycode, int mode); |
60 void InjectScrollWheelClicks(int button, int count); | 60 void InjectScrollWheelClicks(int button, int count); |
61 | 61 |
62 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 62 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
63 | 63 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 if (event.has_wheel_offset_x() && event.wheel_offset_x() != 0) { | 255 if (event.has_wheel_offset_x() && event.wheel_offset_x() != 0) { |
256 int dx = event.wheel_offset_x(); | 256 int dx = event.wheel_offset_x(); |
257 InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(dx), | 257 InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(dx), |
258 abs(dx)); | 258 abs(dx)); |
259 } | 259 } |
260 | 260 |
261 XFlush(display_); | 261 XFlush(display_); |
262 } | 262 } |
263 | 263 |
264 void EventExecutorLinux::OnSessionStarted( | 264 void EventExecutorLinux::Start( |
265 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 265 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
266 return; | 266 return; |
267 } | 267 } |
268 | 268 |
269 void EventExecutorLinux::OnSessionFinished() { | 269 void EventExecutorLinux::StopAndDelete() { |
270 return; | 270 delete this; |
271 } | 271 } |
272 | 272 |
273 } // namespace | 273 } // namespace |
274 | 274 |
275 scoped_ptr<EventExecutor> EventExecutor::Create( | 275 scoped_ptr<EventExecutor> EventExecutor::Create( |
276 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 276 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
277 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 277 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
278 scoped_ptr<EventExecutorLinux> executor( | 278 scoped_ptr<EventExecutorLinux> executor( |
279 new EventExecutorLinux(main_task_runner)); | 279 new EventExecutorLinux(main_task_runner)); |
280 if (!executor->Init()) | 280 if (!executor->Init()) |
281 return scoped_ptr<EventExecutor>(NULL); | 281 return scoped_ptr<EventExecutor>(NULL); |
282 return executor.PassAs<EventExecutor>(); | 282 return executor.PassAs<EventExecutor>(); |
283 } | 283 } |
284 | 284 |
285 } // namespace remoting | 285 } // namespace remoting |
OLD | NEW |