OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/events/ozone/evdev/event_factory_evdev.h" | 5 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/task_runner.h" | 9 #include "base/task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 input_controller_.SetInputDeviceFactory(input_device_factory_.get()); | 137 input_controller_.SetInputDeviceFactory(input_device_factory_.get()); |
138 | 138 |
139 // Scan & monitor devices. | 139 // Scan & monitor devices. |
140 device_manager_->AddObserver(this); | 140 device_manager_->AddObserver(this); |
141 device_manager_->ScanDevices(this); | 141 device_manager_->ScanDevices(this); |
142 | 142 |
143 initialized_ = true; | 143 initialized_ = true; |
144 } | 144 } |
145 | 145 |
146 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { | 146 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { |
147 return make_scoped_ptr(new InputInjectorEvdev( | 147 // Use forwarding dispatcher for the injector rather than dispatching |
148 &modifiers_, cursor_, &keyboard_, dispatch_callback_)); | 148 // directly. We cannot assume it is safe to (re-)enter ui::Event dispatch |
| 149 // synchronously from the injection point. |
| 150 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher( |
| 151 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), |
| 152 weak_ptr_factory_.GetWeakPtr())); |
| 153 return make_scoped_ptr(new InputInjectorEvdev(dispatcher.Pass(), cursor_)); |
149 } | 154 } |
150 | 155 |
151 void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) { | 156 void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) { |
152 keyboard_.OnKeyChange(params.code, params.down); | 157 keyboard_.OnKeyChange(params.code, params.down); |
153 } | 158 } |
154 | 159 |
155 void EventFactoryEvdev::DispatchMouseMoveEvent( | 160 void EventFactoryEvdev::DispatchMouseMoveEvent( |
156 const MouseMoveEventParams& params) { | 161 const MouseMoveEventParams& params) { |
157 scoped_ptr<MouseEvent> event(new MouseEvent(ui::ET_MOUSE_MOVED, | 162 scoped_ptr<MouseEvent> event(new MouseEvent(ui::ET_MOUSE_MOVED, |
158 params.location, params.location, | 163 params.location, params.location, |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 modifiers_.GetModifierFlags(), | 310 modifiers_.GetModifierFlags(), |
306 /* changed_button_flags */ 0))); | 311 /* changed_button_flags */ 0))); |
307 } | 312 } |
308 } | 313 } |
309 | 314 |
310 int EventFactoryEvdev::NextDeviceId() { | 315 int EventFactoryEvdev::NextDeviceId() { |
311 return ++last_device_id_; | 316 return ++last_device_id_; |
312 } | 317 } |
313 | 318 |
314 } // namespace ui | 319 } // namespace ui |
OLD | NEW |