| 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/task_runner.h" | 8 #include "base/task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 new InputInjectorEvdev(proxy_dispatcher.Pass(), cursor_)); | 147 new InputInjectorEvdev(proxy_dispatcher.Pass(), cursor_)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) { | 150 void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) { |
| 151 keyboard_.OnKeyChange(params.code, params.down, params.timestamp); | 151 keyboard_.OnKeyChange(params.code, params.down, params.timestamp); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void EventFactoryEvdev::DispatchMouseMoveEvent( | 154 void EventFactoryEvdev::DispatchMouseMoveEvent( |
| 155 const MouseMoveEventParams& params) { | 155 const MouseMoveEventParams& params) { |
| 156 MouseEvent event(ui::ET_MOUSE_MOVED, params.location, params.location, | 156 MouseEvent event(ui::ET_MOUSE_MOVED, params.location, params.location, |
| 157 EventTimeForNow(), modifiers_.GetModifierFlags(), | 157 params.timestamp, modifiers_.GetModifierFlags(), |
| 158 /* changed_button_flags */ 0); | 158 /* changed_button_flags */ 0); |
| 159 event.set_source_device_id(params.device_id); | 159 event.set_source_device_id(params.device_id); |
| 160 DispatchUiEvent(&event); | 160 DispatchUiEvent(&event); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void EventFactoryEvdev::DispatchMouseButtonEvent( | 163 void EventFactoryEvdev::DispatchMouseButtonEvent( |
| 164 const MouseButtonEventParams& params) { | 164 const MouseButtonEventParams& params) { |
| 165 // Mouse buttons can be remapped, touchpad taps & clicks cannot. | 165 // Mouse buttons can be remapped, touchpad taps & clicks cannot. |
| 166 unsigned int button = params.button; | 166 unsigned int button = params.button; |
| 167 if (params.allow_remap) | 167 if (params.allow_remap) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 179 modifier = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON; | 179 modifier = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON; |
| 180 break; | 180 break; |
| 181 default: | 181 default: |
| 182 return; | 182 return; |
| 183 } | 183 } |
| 184 | 184 |
| 185 int flag = modifiers_.GetEventFlagFromModifier(modifier); | 185 int flag = modifiers_.GetEventFlagFromModifier(modifier); |
| 186 modifiers_.UpdateModifier(modifier, params.down); | 186 modifiers_.UpdateModifier(modifier, params.down); |
| 187 | 187 |
| 188 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, | 188 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, |
| 189 params.location, params.location, EventTimeForNow(), | 189 params.location, params.location, params.timestamp, |
| 190 modifiers_.GetModifierFlags() | flag, | 190 modifiers_.GetModifierFlags() | flag, |
| 191 /* changed_button_flags */ flag); | 191 /* changed_button_flags */ flag); |
| 192 event.set_source_device_id(params.device_id); | 192 event.set_source_device_id(params.device_id); |
| 193 DispatchUiEvent(&event); | 193 DispatchUiEvent(&event); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void EventFactoryEvdev::DispatchMouseWheelEvent( | 196 void EventFactoryEvdev::DispatchMouseWheelEvent( |
| 197 const MouseWheelEventParams& params) { | 197 const MouseWheelEventParams& params) { |
| 198 MouseWheelEvent event(params.delta, params.location, params.location, | 198 MouseWheelEvent event(params.delta, params.location, params.location, |
| 199 modifiers_.GetModifierFlags(), | 199 params.timestamp, modifiers_.GetModifierFlags(), |
| 200 0 /* changed_button_flags */); | 200 0 /* changed_button_flags */); |
| 201 event.set_source_device_id(params.device_id); | 201 event.set_source_device_id(params.device_id); |
| 202 DispatchUiEvent(&event); | 202 DispatchUiEvent(&event); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void EventFactoryEvdev::DispatchScrollEvent(const ScrollEventParams& params) { | 205 void EventFactoryEvdev::DispatchScrollEvent(const ScrollEventParams& params) { |
| 206 ScrollEvent event(params.type, params.location, params.timestamp, | 206 ScrollEvent event(params.type, params.location, params.timestamp, |
| 207 modifiers_.GetModifierFlags(), params.delta.x(), | 207 modifiers_.GetModifierFlags(), params.delta.x(), |
| 208 params.delta.y(), params.ordinal_delta.x(), | 208 params.delta.y(), params.ordinal_delta.x(), |
| 209 params.ordinal_delta.y(), params.finger_count); | 209 params.ordinal_delta.y(), params.finger_count); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 const gfx::PointF& location) { | 296 const gfx::PointF& location) { |
| 297 if (!cursor_) | 297 if (!cursor_) |
| 298 return; | 298 return; |
| 299 | 299 |
| 300 cursor_->MoveCursorTo(widget, location); | 300 cursor_->MoveCursorTo(widget, location); |
| 301 | 301 |
| 302 base::ThreadTaskRunnerHandle::Get()->PostTask( | 302 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 303 FROM_HERE, base::Bind(&EventFactoryEvdev::DispatchMouseMoveEvent, | 303 FROM_HERE, base::Bind(&EventFactoryEvdev::DispatchMouseMoveEvent, |
| 304 weak_ptr_factory_.GetWeakPtr(), | 304 weak_ptr_factory_.GetWeakPtr(), |
| 305 MouseMoveEventParams(-1 /* device_id */, | 305 MouseMoveEventParams(-1 /* device_id */, |
| 306 cursor_->GetLocation()))); | 306 cursor_->GetLocation(), |
| 307 EventTimeForNow()))); |
| 307 } | 308 } |
| 308 | 309 |
| 309 int EventFactoryEvdev::NextDeviceId() { | 310 int EventFactoryEvdev::NextDeviceId() { |
| 310 return ++last_device_id_; | 311 return ++last_device_id_; |
| 311 } | 312 } |
| 312 | 313 |
| 313 void EventFactoryEvdev::StartThread() { | 314 void EventFactoryEvdev::StartThread() { |
| 314 // Set up device factory. | 315 // Set up device factory. |
| 315 scoped_ptr<DeviceEventDispatcherEvdev> proxy_dispatcher( | 316 scoped_ptr<DeviceEventDispatcherEvdev> proxy_dispatcher( |
| 316 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), | 317 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), |
| 317 weak_ptr_factory_.GetWeakPtr())); | 318 weak_ptr_factory_.GetWeakPtr())); |
| 318 thread_.Start(proxy_dispatcher.Pass(), cursor_, | 319 thread_.Start(proxy_dispatcher.Pass(), cursor_, |
| 319 base::Bind(&EventFactoryEvdev::OnThreadStarted, | 320 base::Bind(&EventFactoryEvdev::OnThreadStarted, |
| 320 weak_ptr_factory_.GetWeakPtr())); | 321 weak_ptr_factory_.GetWeakPtr())); |
| 321 } | 322 } |
| 322 | 323 |
| 323 void EventFactoryEvdev::OnThreadStarted( | 324 void EventFactoryEvdev::OnThreadStarted( |
| 324 scoped_ptr<InputDeviceFactoryEvdevProxy> input_device_factory) { | 325 scoped_ptr<InputDeviceFactoryEvdevProxy> input_device_factory) { |
| 325 input_device_factory_proxy_ = input_device_factory.Pass(); | 326 input_device_factory_proxy_ = input_device_factory.Pass(); |
| 326 | 327 |
| 327 // TODO(spang): This settings interface is really broken. crbug.com/450899 | 328 // TODO(spang): This settings interface is really broken. crbug.com/450899 |
| 328 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get()); | 329 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get()); |
| 329 | 330 |
| 330 // Scan & monitor devices. | 331 // Scan & monitor devices. |
| 331 device_manager_->AddObserver(this); | 332 device_manager_->AddObserver(this); |
| 332 device_manager_->ScanDevices(this); | 333 device_manager_->ScanDevices(this); |
| 333 } | 334 } |
| 334 | 335 |
| 335 } // namespace ui | 336 } // namespace ui |
| OLD | NEW |