| 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" |
| 11 #include "base/threading/worker_pool.h" | 11 #include "base/threading/worker_pool.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "ui/events/devices/device_data_manager.h" | 13 #include "ui/events/devices/device_data_manager.h" |
| 14 #include "ui/events/devices/input_device.h" | 14 #include "ui/events/devices/input_device.h" |
| 15 #include "ui/events/ozone/device/device_event.h" | 15 #include "ui/events/ozone/device/device_event.h" |
| 16 #include "ui/events/ozone/device/device_manager.h" | 16 #include "ui/events/ozone/device/device_manager.h" |
| 17 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 17 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
| 18 #include "ui/events/ozone/evdev/input_controller_evdev.h" | 18 #include "ui/events/ozone/evdev/input_controller_evdev.h" |
| 19 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" | 19 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" |
| 20 #include "ui/events/ozone/evdev/input_injector_evdev.h" | 20 #include "ui/events/ozone/evdev/input_injector_evdev.h" |
| 21 | 21 |
| 22 #if defined(USE_EVDEV_GESTURES) | |
| 23 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" | |
| 24 #endif | |
| 25 | |
| 26 namespace ui { | 22 namespace ui { |
| 27 | 23 |
| 28 EventFactoryEvdev::EventFactoryEvdev(CursorDelegateEvdev* cursor, | 24 EventFactoryEvdev::EventFactoryEvdev(CursorDelegateEvdev* cursor, |
| 29 DeviceManager* device_manager, | 25 DeviceManager* device_manager, |
| 30 KeyboardLayoutEngine* keyboard_layout) | 26 KeyboardLayoutEngine* keyboard_layout) |
| 31 : last_device_id_(0), | 27 : last_device_id_(0), |
| 32 device_manager_(device_manager), | 28 device_manager_(device_manager), |
| 33 dispatch_callback_( | 29 dispatch_callback_( |
| 34 base::Bind(&EventFactoryEvdev::PostUiEvent, base::Unretained(this))), | 30 base::Bind(&EventFactoryEvdev::PostUiEvent, base::Unretained(this))), |
| 35 keyboard_(&modifiers_, keyboard_layout, dispatch_callback_), | 31 keyboard_(&modifiers_, keyboard_layout, dispatch_callback_), |
| 36 cursor_(cursor), | 32 cursor_(cursor), |
| 37 #if defined(USE_EVDEV_GESTURES) | 33 input_controller_(&keyboard_, &button_map_), |
| 38 gesture_property_provider_(new GesturePropertyProvider), | |
| 39 #endif | |
| 40 input_controller_(&keyboard_, | |
| 41 &button_map_ | |
| 42 #if defined(USE_EVDEV_GESTURES) | |
| 43 , | |
| 44 gesture_property_provider_.get() | |
| 45 #endif | |
| 46 ), | |
| 47 initialized_(false), | 34 initialized_(false), |
| 48 weak_ptr_factory_(this) { | 35 weak_ptr_factory_(this) { |
| 49 DCHECK(device_manager_); | 36 DCHECK(device_manager_); |
| 50 } | 37 } |
| 51 | 38 |
| 52 EventFactoryEvdev::~EventFactoryEvdev() { | 39 EventFactoryEvdev::~EventFactoryEvdev() { |
| 53 } | 40 } |
| 54 | 41 |
| 55 void EventFactoryEvdev::Init() { | 42 void EventFactoryEvdev::Init() { |
| 56 DCHECK(!initialized_); | 43 DCHECK(!initialized_); |
| 57 | 44 |
| 58 // Set up device factory. | 45 // Set up device factory. |
| 59 input_device_factory_.reset( | 46 input_device_factory_.reset(new InputDeviceFactoryEvdev( |
| 60 new InputDeviceFactoryEvdev(this, base::ThreadTaskRunnerHandle::Get(), | 47 this, base::ThreadTaskRunnerHandle::Get(), cursor_)); |
| 61 #if defined(USE_EVDEV_GESTURES) | |
| 62 gesture_property_provider_.get(), | |
| 63 #endif | |
| 64 cursor_)); | |
| 65 // TODO(spang): This settings interface is really broken. crbug.com/450899 | 48 // TODO(spang): This settings interface is really broken. crbug.com/450899 |
| 66 input_controller_.SetInputDeviceFactory(input_device_factory_.get()); | 49 input_controller_.SetInputDeviceFactory(input_device_factory_.get()); |
| 67 | 50 |
| 68 // Scan & monitor devices. | 51 // Scan & monitor devices. |
| 69 device_manager_->AddObserver(this); | 52 device_manager_->AddObserver(this); |
| 70 device_manager_->ScanDevices(this); | 53 device_manager_->ScanDevices(this); |
| 71 | 54 |
| 72 initialized_ = true; | 55 initialized_ = true; |
| 73 } | 56 } |
| 74 | 57 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 modifiers_.GetModifierFlags(), | 193 modifiers_.GetModifierFlags(), |
| 211 /* changed_button_flags */ 0))); | 194 /* changed_button_flags */ 0))); |
| 212 } | 195 } |
| 213 } | 196 } |
| 214 | 197 |
| 215 int EventFactoryEvdev::NextDeviceId() { | 198 int EventFactoryEvdev::NextDeviceId() { |
| 216 return ++last_device_id_; | 199 return ++last_device_id_; |
| 217 } | 200 } |
| 218 | 201 |
| 219 } // namespace ui | 202 } // namespace ui |
| OLD | NEW |