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/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 |
11 #include <set> | 11 #include <set> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
(...skipping 15 matching lines...) Expand all Loading... |
31 // USB to XKB keycode map table. | 31 // USB to XKB keycode map table. |
32 #define USB_KEYMAP(usb, xkb, win, mac) {usb, xkb} | 32 #define USB_KEYMAP(usb, xkb, win, mac) {usb, xkb} |
33 #include "ui/base/keycodes/usb_keycode_map.h" | 33 #include "ui/base/keycodes/usb_keycode_map.h" |
34 #undef USB_KEYMAP | 34 #undef USB_KEYMAP |
35 | 35 |
36 // Pixel-to-wheel-ticks conversion ratio used by GTK. | 36 // Pixel-to-wheel-ticks conversion ratio used by GTK. |
37 // From Source/WebKit/chromium/src/gtk/WebInputFactory.cc. | 37 // From Source/WebKit/chromium/src/gtk/WebInputFactory.cc. |
38 const float kWheelTicksPerPixel = 3.0f / 160.0f; | 38 const float kWheelTicksPerPixel = 3.0f / 160.0f; |
39 | 39 |
40 // A class to generate events on Linux. | 40 // A class to generate events on Linux. |
41 class EventExecutorLinux : public EventExecutor { | 41 class InputInjectorLinux : public InputInjector { |
42 public: | 42 public: |
43 explicit EventExecutorLinux( | 43 explicit InputInjectorLinux( |
44 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 44 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
45 virtual ~EventExecutorLinux(); | 45 virtual ~InputInjectorLinux(); |
46 | 46 |
47 bool Init(); | 47 bool Init(); |
48 | 48 |
49 // Clipboard stub interface. | 49 // Clipboard stub interface. |
50 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; | 50 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; |
51 | 51 |
52 // InputStub interface. | 52 // InputStub interface. |
53 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 53 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
54 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 54 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
55 | 55 |
56 // EventExecutor interface. | 56 // InputInjector interface. |
57 virtual void Start( | 57 virtual void Start( |
58 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; | 58 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; |
59 | 59 |
60 private: | 60 private: |
61 // The actual implementation resides in EventExecutorLinux::Core class. | 61 // The actual implementation resides in InputInjectorLinux::Core class. |
62 class Core : public base::RefCountedThreadSafe<Core> { | 62 class Core : public base::RefCountedThreadSafe<Core> { |
63 public: | 63 public: |
64 explicit Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 64 explicit Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
65 | 65 |
66 bool Init(); | 66 bool Init(); |
67 | 67 |
68 // Mirrors the ClipboardStub interface. | 68 // Mirrors the ClipboardStub interface. |
69 void InjectClipboardEvent(const ClipboardEvent& event); | 69 void InjectClipboardEvent(const ClipboardEvent& event); |
70 | 70 |
71 // Mirrors the InputStub interface. | 71 // Mirrors the InputStub interface. |
72 void InjectKeyEvent(const KeyEvent& event); | 72 void InjectKeyEvent(const KeyEvent& event); |
73 void InjectMouseEvent(const MouseEvent& event); | 73 void InjectMouseEvent(const MouseEvent& event); |
74 | 74 |
75 // Mirrors the EventExecutor interface. | 75 // Mirrors the InputInjector interface. |
76 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard); | 76 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard); |
77 | 77 |
78 void Stop(); | 78 void Stop(); |
79 | 79 |
80 private: | 80 private: |
81 friend class base::RefCountedThreadSafe<Core>; | 81 friend class base::RefCountedThreadSafe<Core>; |
82 virtual ~Core(); | 82 virtual ~Core(); |
83 | 83 |
84 void InitClipboard(); | 84 void InitClipboard(); |
85 | 85 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 scoped_ptr<Clipboard> clipboard_; | 123 scoped_ptr<Clipboard> clipboard_; |
124 | 124 |
125 bool saved_auto_repeat_enabled_; | 125 bool saved_auto_repeat_enabled_; |
126 | 126 |
127 DISALLOW_COPY_AND_ASSIGN(Core); | 127 DISALLOW_COPY_AND_ASSIGN(Core); |
128 }; | 128 }; |
129 | 129 |
130 scoped_refptr<Core> core_; | 130 scoped_refptr<Core> core_; |
131 | 131 |
132 DISALLOW_COPY_AND_ASSIGN(EventExecutorLinux); | 132 DISALLOW_COPY_AND_ASSIGN(InputInjectorLinux); |
133 }; | 133 }; |
134 | 134 |
135 EventExecutorLinux::EventExecutorLinux( | 135 InputInjectorLinux::InputInjectorLinux( |
136 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 136 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
137 core_ = new Core(task_runner); | 137 core_ = new Core(task_runner); |
138 } | 138 } |
139 EventExecutorLinux::~EventExecutorLinux() { | 139 InputInjectorLinux::~InputInjectorLinux() { |
140 core_->Stop(); | 140 core_->Stop(); |
141 } | 141 } |
142 | 142 |
143 bool EventExecutorLinux::Init() { | 143 bool InputInjectorLinux::Init() { |
144 return core_->Init(); | 144 return core_->Init(); |
145 } | 145 } |
146 | 146 |
147 void EventExecutorLinux::InjectClipboardEvent(const ClipboardEvent& event) { | 147 void InputInjectorLinux::InjectClipboardEvent(const ClipboardEvent& event) { |
148 core_->InjectClipboardEvent(event); | 148 core_->InjectClipboardEvent(event); |
149 } | 149 } |
150 | 150 |
151 void EventExecutorLinux::InjectKeyEvent(const KeyEvent& event) { | 151 void InputInjectorLinux::InjectKeyEvent(const KeyEvent& event) { |
152 core_->InjectKeyEvent(event); | 152 core_->InjectKeyEvent(event); |
153 } | 153 } |
154 | 154 |
155 void EventExecutorLinux::InjectMouseEvent(const MouseEvent& event) { | 155 void InputInjectorLinux::InjectMouseEvent(const MouseEvent& event) { |
156 core_->InjectMouseEvent(event); | 156 core_->InjectMouseEvent(event); |
157 } | 157 } |
158 | 158 |
159 void EventExecutorLinux::Start( | 159 void InputInjectorLinux::Start( |
160 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 160 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
161 core_->Start(client_clipboard.Pass()); | 161 core_->Start(client_clipboard.Pass()); |
162 } | 162 } |
163 | 163 |
164 EventExecutorLinux::Core::Core( | 164 InputInjectorLinux::Core::Core( |
165 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 165 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
166 : task_runner_(task_runner), | 166 : task_runner_(task_runner), |
167 latest_mouse_position_(SkIPoint::Make(-1, -1)), | 167 latest_mouse_position_(SkIPoint::Make(-1, -1)), |
168 wheel_ticks_x_(0.0f), | 168 wheel_ticks_x_(0.0f), |
169 wheel_ticks_y_(0.0f), | 169 wheel_ticks_y_(0.0f), |
170 display_(XOpenDisplay(NULL)), | 170 display_(XOpenDisplay(NULL)), |
171 root_window_(BadValue), | 171 root_window_(BadValue), |
172 saved_auto_repeat_enabled_(false) { | 172 saved_auto_repeat_enabled_(false) { |
173 } | 173 } |
174 | 174 |
175 bool EventExecutorLinux::Core::Init() { | 175 bool InputInjectorLinux::Core::Init() { |
176 CHECK(display_); | 176 CHECK(display_); |
177 | 177 |
178 if (!task_runner_->BelongsToCurrentThread()) | 178 if (!task_runner_->BelongsToCurrentThread()) |
179 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::InitClipboard, this)); | 179 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::InitClipboard, this)); |
180 | 180 |
181 root_window_ = RootWindow(display_, DefaultScreen(display_)); | 181 root_window_ = RootWindow(display_, DefaultScreen(display_)); |
182 if (root_window_ == BadValue) { | 182 if (root_window_ == BadValue) { |
183 LOG(ERROR) << "Unable to get the root window"; | 183 LOG(ERROR) << "Unable to get the root window"; |
184 return false; | 184 return false; |
185 } | 185 } |
186 | 186 |
187 // TODO(ajwong): Do we want to check the major/minor version at all for XTest? | 187 // TODO(ajwong): Do we want to check the major/minor version at all for XTest? |
188 int major = 0; | 188 int major = 0; |
189 int minor = 0; | 189 int minor = 0; |
190 if (!XTestQueryExtension(display_, &test_event_base_, &test_error_base_, | 190 if (!XTestQueryExtension(display_, &test_event_base_, &test_error_base_, |
191 &major, &minor)) { | 191 &major, &minor)) { |
192 LOG(ERROR) << "Server does not support XTest."; | 192 LOG(ERROR) << "Server does not support XTest."; |
193 return false; | 193 return false; |
194 } | 194 } |
195 InitMouseButtonMap(); | 195 InitMouseButtonMap(); |
196 return true; | 196 return true; |
197 } | 197 } |
198 | 198 |
199 void EventExecutorLinux::Core::InjectClipboardEvent( | 199 void InputInjectorLinux::Core::InjectClipboardEvent( |
200 const ClipboardEvent& event) { | 200 const ClipboardEvent& event) { |
201 if (!task_runner_->BelongsToCurrentThread()) { | 201 if (!task_runner_->BelongsToCurrentThread()) { |
202 task_runner_->PostTask( | 202 task_runner_->PostTask( |
203 FROM_HERE, base::Bind(&Core::InjectClipboardEvent, this, event)); | 203 FROM_HERE, base::Bind(&Core::InjectClipboardEvent, this, event)); |
204 return; | 204 return; |
205 } | 205 } |
206 | 206 |
207 // |clipboard_| will ignore unknown MIME-types, and verify the data's format. | 207 // |clipboard_| will ignore unknown MIME-types, and verify the data's format. |
208 clipboard_->InjectClipboardEvent(event); | 208 clipboard_->InjectClipboardEvent(event); |
209 } | 209 } |
210 | 210 |
211 void EventExecutorLinux::Core::InjectKeyEvent(const KeyEvent& event) { | 211 void InputInjectorLinux::Core::InjectKeyEvent(const KeyEvent& event) { |
212 // HostEventDispatcher should filter events missing the pressed field. | 212 // HostEventDispatcher should filter events missing the pressed field. |
213 if (!event.has_pressed() || !event.has_usb_keycode()) | 213 if (!event.has_pressed() || !event.has_usb_keycode()) |
214 return; | 214 return; |
215 | 215 |
216 if (!task_runner_->BelongsToCurrentThread()) { | 216 if (!task_runner_->BelongsToCurrentThread()) { |
217 task_runner_->PostTask(FROM_HERE, | 217 task_runner_->PostTask(FROM_HERE, |
218 base::Bind(&Core::InjectKeyEvent, this, event)); | 218 base::Bind(&Core::InjectKeyEvent, this, event)); |
219 return; | 219 return; |
220 } | 220 } |
221 | 221 |
(...skipping 27 matching lines...) Expand all Loading... |
249 // Re-enable auto-repeat, if necessary, when all keys are released. | 249 // Re-enable auto-repeat, if necessary, when all keys are released. |
250 if (saved_auto_repeat_enabled_) | 250 if (saved_auto_repeat_enabled_) |
251 SetAutoRepeatEnabled(true); | 251 SetAutoRepeatEnabled(true); |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 XTestFakeKeyEvent(display_, keycode, event.pressed(), CurrentTime); | 255 XTestFakeKeyEvent(display_, keycode, event.pressed(), CurrentTime); |
256 XFlush(display_); | 256 XFlush(display_); |
257 } | 257 } |
258 | 258 |
259 EventExecutorLinux::Core::~Core() { | 259 InputInjectorLinux::Core::~Core() { |
260 CHECK(pressed_keys_.empty()); | 260 CHECK(pressed_keys_.empty()); |
261 } | 261 } |
262 | 262 |
263 void EventExecutorLinux::Core::InitClipboard() { | 263 void InputInjectorLinux::Core::InitClipboard() { |
264 DCHECK(task_runner_->BelongsToCurrentThread()); | 264 DCHECK(task_runner_->BelongsToCurrentThread()); |
265 clipboard_ = Clipboard::Create(); | 265 clipboard_ = Clipboard::Create(); |
266 } | 266 } |
267 | 267 |
268 bool EventExecutorLinux::Core::IsAutoRepeatEnabled() { | 268 bool InputInjectorLinux::Core::IsAutoRepeatEnabled() { |
269 XKeyboardState state; | 269 XKeyboardState state; |
270 if (!XGetKeyboardControl(display_, &state)) { | 270 if (!XGetKeyboardControl(display_, &state)) { |
271 LOG(ERROR) << "Failed to get keyboard auto-repeat status, assuming ON."; | 271 LOG(ERROR) << "Failed to get keyboard auto-repeat status, assuming ON."; |
272 return true; | 272 return true; |
273 } | 273 } |
274 return state.global_auto_repeat == AutoRepeatModeOn; | 274 return state.global_auto_repeat == AutoRepeatModeOn; |
275 } | 275 } |
276 | 276 |
277 void EventExecutorLinux::Core::SetAutoRepeatEnabled(bool mode) { | 277 void InputInjectorLinux::Core::SetAutoRepeatEnabled(bool mode) { |
278 XKeyboardControl control; | 278 XKeyboardControl control; |
279 control.auto_repeat_mode = mode ? AutoRepeatModeOn : AutoRepeatModeOff; | 279 control.auto_repeat_mode = mode ? AutoRepeatModeOn : AutoRepeatModeOff; |
280 XChangeKeyboardControl(display_, KBAutoRepeatMode, &control); | 280 XChangeKeyboardControl(display_, KBAutoRepeatMode, &control); |
281 } | 281 } |
282 | 282 |
283 void EventExecutorLinux::Core::InjectScrollWheelClicks(int button, int count) { | 283 void InputInjectorLinux::Core::InjectScrollWheelClicks(int button, int count) { |
284 if (button < 0) { | 284 if (button < 0) { |
285 LOG(WARNING) << "Ignoring unmapped scroll wheel button"; | 285 LOG(WARNING) << "Ignoring unmapped scroll wheel button"; |
286 return; | 286 return; |
287 } | 287 } |
288 for (int i = 0; i < count; i++) { | 288 for (int i = 0; i < count; i++) { |
289 // Generate a button-down and a button-up to simulate a wheel click. | 289 // Generate a button-down and a button-up to simulate a wheel click. |
290 XTestFakeButtonEvent(display_, button, true, CurrentTime); | 290 XTestFakeButtonEvent(display_, button, true, CurrentTime); |
291 XTestFakeButtonEvent(display_, button, false, CurrentTime); | 291 XTestFakeButtonEvent(display_, button, false, CurrentTime); |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 void EventExecutorLinux::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_x() && event.has_y()) { |
303 // Injecting a motion event immediately before a button release results in | 303 // Injecting a motion event immediately before a button release results in |
304 // a MotionNotify even if the mouse position hasn't changed, which confuses | 304 // a MotionNotify even if the mouse position hasn't changed, which confuses |
305 // apps which assume MotionNotify implies movement. See crbug.com/138075. | 305 // apps which assume MotionNotify implies movement. See crbug.com/138075. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 wheel_ticks_x_ -= ticks_x; | 358 wheel_ticks_x_ -= ticks_x; |
359 } | 359 } |
360 if (ticks_x != 0) { | 360 if (ticks_x != 0) { |
361 InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(ticks_x), | 361 InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(ticks_x), |
362 abs(ticks_x)); | 362 abs(ticks_x)); |
363 } | 363 } |
364 | 364 |
365 XFlush(display_); | 365 XFlush(display_); |
366 } | 366 } |
367 | 367 |
368 void EventExecutorLinux::Core::InitMouseButtonMap() { | 368 void InputInjectorLinux::Core::InitMouseButtonMap() { |
369 // TODO(rmsousa): Run this on global/device mapping change events. | 369 // TODO(rmsousa): Run this on global/device mapping change events. |
370 | 370 |
371 // Do not touch global pointer mapping, since this may affect the local user. | 371 // Do not touch global pointer mapping, since this may affect the local user. |
372 // Instead, try to work around it by reversing the mapping. | 372 // Instead, try to work around it by reversing the mapping. |
373 // Note that if a user has a global mapping that completely disables a button | 373 // Note that if a user has a global mapping that completely disables a button |
374 // (by assigning 0 to it), we won't be able to inject it. | 374 // (by assigning 0 to it), we won't be able to inject it. |
375 int num_buttons = XGetPointerMapping(display_, NULL, 0); | 375 int num_buttons = XGetPointerMapping(display_, NULL, 0); |
376 scoped_array<unsigned char> pointer_mapping(new unsigned char[num_buttons]); | 376 scoped_array<unsigned char> pointer_mapping(new unsigned char[num_buttons]); |
377 num_buttons = XGetPointerMapping(display_, pointer_mapping.get(), | 377 num_buttons = XGetPointerMapping(display_, pointer_mapping.get(), |
378 num_buttons); | 378 num_buttons); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 button_mapping[i] = i + 1; | 434 button_mapping[i] = i + 1; |
435 } | 435 } |
436 error = XSetDeviceButtonMapping(display_, device, button_mapping.get(), | 436 error = XSetDeviceButtonMapping(display_, device, button_mapping.get(), |
437 num_device_buttons); | 437 num_device_buttons); |
438 if (error != Success) | 438 if (error != Success) |
439 LOG(ERROR) << "Failed to set XTest device button mapping: " << error; | 439 LOG(ERROR) << "Failed to set XTest device button mapping: " << error; |
440 | 440 |
441 XCloseDevice(display_, device); | 441 XCloseDevice(display_, device); |
442 } | 442 } |
443 | 443 |
444 int EventExecutorLinux::Core::MouseButtonToX11ButtonNumber( | 444 int InputInjectorLinux::Core::MouseButtonToX11ButtonNumber( |
445 MouseEvent::MouseButton button) { | 445 MouseEvent::MouseButton button) { |
446 switch (button) { | 446 switch (button) { |
447 case MouseEvent::BUTTON_LEFT: | 447 case MouseEvent::BUTTON_LEFT: |
448 return pointer_button_map_[0]; | 448 return pointer_button_map_[0]; |
449 | 449 |
450 case MouseEvent::BUTTON_RIGHT: | 450 case MouseEvent::BUTTON_RIGHT: |
451 return pointer_button_map_[2]; | 451 return pointer_button_map_[2]; |
452 | 452 |
453 case MouseEvent::BUTTON_MIDDLE: | 453 case MouseEvent::BUTTON_MIDDLE: |
454 return pointer_button_map_[1]; | 454 return pointer_button_map_[1]; |
455 | 455 |
456 case MouseEvent::BUTTON_UNDEFINED: | 456 case MouseEvent::BUTTON_UNDEFINED: |
457 default: | 457 default: |
458 return -1; | 458 return -1; |
459 } | 459 } |
460 } | 460 } |
461 | 461 |
462 int EventExecutorLinux::Core::HorizontalScrollWheelToX11ButtonNumber(int dx) { | 462 int InputInjectorLinux::Core::HorizontalScrollWheelToX11ButtonNumber(int dx) { |
463 return (dx > 0 ? pointer_button_map_[5] : pointer_button_map_[6]); | 463 return (dx > 0 ? pointer_button_map_[5] : pointer_button_map_[6]); |
464 } | 464 } |
465 | 465 |
466 int EventExecutorLinux::Core::VerticalScrollWheelToX11ButtonNumber(int dy) { | 466 int InputInjectorLinux::Core::VerticalScrollWheelToX11ButtonNumber(int dy) { |
467 // Positive y-values are wheel scroll-up events (button 4), negative y-values | 467 // Positive y-values are wheel scroll-up events (button 4), negative y-values |
468 // are wheel scroll-down events (button 5). | 468 // are wheel scroll-down events (button 5). |
469 return (dy > 0 ? pointer_button_map_[3] : pointer_button_map_[4]); | 469 return (dy > 0 ? pointer_button_map_[3] : pointer_button_map_[4]); |
470 } | 470 } |
471 | 471 |
472 void EventExecutorLinux::Core::Start( | 472 void InputInjectorLinux::Core::Start( |
473 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 473 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
474 if (!task_runner_->BelongsToCurrentThread()) { | 474 if (!task_runner_->BelongsToCurrentThread()) { |
475 task_runner_->PostTask( | 475 task_runner_->PostTask( |
476 FROM_HERE, | 476 FROM_HERE, |
477 base::Bind(&Core::Start, this, base::Passed(&client_clipboard))); | 477 base::Bind(&Core::Start, this, base::Passed(&client_clipboard))); |
478 return; | 478 return; |
479 } | 479 } |
480 | 480 |
481 InitMouseButtonMap(); | 481 InitMouseButtonMap(); |
482 | 482 |
483 clipboard_->Start(client_clipboard.Pass()); | 483 clipboard_->Start(client_clipboard.Pass()); |
484 } | 484 } |
485 | 485 |
486 void EventExecutorLinux::Core::Stop() { | 486 void InputInjectorLinux::Core::Stop() { |
487 if (!task_runner_->BelongsToCurrentThread()) { | 487 if (!task_runner_->BelongsToCurrentThread()) { |
488 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::Stop, this)); | 488 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::Stop, this)); |
489 return; | 489 return; |
490 } | 490 } |
491 | 491 |
492 clipboard_->Stop(); | 492 clipboard_->Stop(); |
493 } | 493 } |
494 | 494 |
495 } // namespace | 495 } // namespace |
496 | 496 |
497 scoped_ptr<EventExecutor> EventExecutor::Create( | 497 scoped_ptr<InputInjector> InputInjector::Create( |
498 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 498 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
499 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 499 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
500 scoped_ptr<EventExecutorLinux> executor( | 500 scoped_ptr<InputInjectorLinux> injector( |
501 new EventExecutorLinux(main_task_runner)); | 501 new InputInjectorLinux(main_task_runner)); |
502 if (!executor->Init()) | 502 if (!injector->Init()) |
503 return scoped_ptr<EventExecutor>(NULL); | 503 return scoped_ptr<InputInjector>(NULL); |
504 return executor.PassAs<EventExecutor>(); | 504 return injector.PassAs<InputInjector>(); |
505 } | 505 } |
506 | 506 |
507 } // namespace remoting | 507 } // namespace remoting |
OLD | NEW |