Index: ui/events/ozone/evdev/event_factory_evdev.cc |
diff --git a/ui/events/ozone/evdev/event_factory_evdev.cc b/ui/events/ozone/evdev/event_factory_evdev.cc |
index 3cda8856bc4fe7d017b2303446e813041a193a5f..bf95a38e04252b2f8040b9362592c268d81285c2 100644 |
--- a/ui/events/ozone/evdev/event_factory_evdev.cc |
+++ b/ui/events/ozone/evdev/event_factory_evdev.cc |
@@ -117,9 +117,10 @@ EventFactoryEvdev::EventFactoryEvdev(CursorDelegateEvdev* cursor, |
KeyboardLayoutEngine* keyboard_layout) |
: last_device_id_(0), |
device_manager_(device_manager), |
- dispatch_callback_( |
- base::Bind(&EventFactoryEvdev::PostUiEvent, base::Unretained(this))), |
- keyboard_(&modifiers_, keyboard_layout, dispatch_callback_), |
+ keyboard_(&modifiers_, |
+ keyboard_layout, |
+ base::Bind(&EventFactoryEvdev::DispatchUiEvent, |
+ base::Unretained(this))), |
cursor_(cursor), |
input_controller_(&keyboard_, &button_map_), |
initialized_(false), |
@@ -168,11 +169,11 @@ void EventFactoryEvdev::DispatchKeyEvent(int device_id, |
void EventFactoryEvdev::DispatchMouseMoveEvent(int device_id, |
const gfx::PointF& location) { |
- scoped_ptr<MouseEvent> event(new MouseEvent( |
- ui::ET_MOUSE_MOVED, location, location, modifiers_.GetModifierFlags(), |
- /* changed_button_flags */ 0)); |
- event->set_source_device_id(device_id); |
- PostUiEvent(event.Pass()); |
+ MouseEvent event(ui::ET_MOUSE_MOVED, location, location, |
+ modifiers_.GetModifierFlags(), |
+ /* changed_button_flags */ 0); |
+ event.set_source_device_id(device_id); |
+ DispatchUiEvent(&event); |
} |
void EventFactoryEvdev::DispatchMouseButtonEvent(int device_id, |
@@ -202,31 +203,30 @@ void EventFactoryEvdev::DispatchMouseButtonEvent(int device_id, |
int flag = modifiers_.GetEventFlagFromModifier(modifier); |
modifiers_.UpdateModifier(modifier, down); |
- scoped_ptr<MouseEvent> event( |
- new MouseEvent(down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, |
- location, location, modifiers_.GetModifierFlags() | flag, |
- /* changed_button_flags */ flag)); |
- event->set_source_device_id(device_id); |
- PostUiEvent(event.Pass()); |
+ MouseEvent event(down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, |
+ location, location, modifiers_.GetModifierFlags() | flag, |
+ /* changed_button_flags */ flag); |
+ event.set_source_device_id(device_id); |
+ DispatchUiEvent(&event); |
} |
void EventFactoryEvdev::DispatchMouseWheelEvent(int device_id, |
const gfx::PointF& location, |
const gfx::Vector2d& delta) { |
- scoped_ptr<MouseWheelEvent> event(new MouseWheelEvent( |
- delta, location, location, modifiers_.GetModifierFlags(), |
- 0 /* changed_button_flags */)); |
- event->set_source_device_id(device_id); |
- PostUiEvent(event.Pass()); |
+ MouseWheelEvent event(delta, location, location, |
+ modifiers_.GetModifierFlags(), |
+ 0 /* changed_button_flags */); |
+ event.set_source_device_id(device_id); |
+ DispatchUiEvent(&event); |
} |
void EventFactoryEvdev::DispatchScrollEvent(const ScrollEventParams& params) { |
- scoped_ptr<ScrollEvent> event(new ScrollEvent( |
- params.type, params.location, params.timestamp, |
- modifiers_.GetModifierFlags(), params.delta.x(), params.delta.y(), |
- params.ordinal_delta.x(), params.ordinal_delta.y(), params.finger_count)); |
- event->set_source_device_id(params.device_id); |
- PostUiEvent(event.Pass()); |
+ ScrollEvent event(params.type, params.location, params.timestamp, |
+ modifiers_.GetModifierFlags(), params.delta.x(), |
+ params.delta.y(), params.ordinal_delta.x(), |
+ params.ordinal_delta.y(), params.finger_count); |
+ event.set_source_device_id(params.device_id); |
+ DispatchUiEvent(&event); |
} |
void EventFactoryEvdev::DispatchTouchEvent(const TouchEventParams& params) { |
@@ -242,21 +242,16 @@ void EventFactoryEvdev::DispatchTouchEvent(const TouchEventParams& params) { |
&radius_x); |
DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, |
&radius_y); |
- |
- scoped_ptr<TouchEvent> touch_event(new TouchEvent( |
- params.type, gfx::PointF(x, y), |
- /* flags */ 0, params.touch_id, params.timestamp, radius_x, radius_y, |
- /* angle */ 0., params.pressure)); |
- touch_event->set_source_device_id(params.device_id); |
- PostUiEvent(touch_event.Pass()); |
+ TouchEvent touch_event(params.type, gfx::PointF(x, y), |
+ /* flags */ 0, params.touch_id, params.timestamp, |
+ radius_x, radius_y, |
+ /* angle */ 0.f, params.pressure); |
+ touch_event.set_source_device_id(params.device_id); |
+ DispatchUiEvent(&touch_event); |
} |
-void EventFactoryEvdev::PostUiEvent(scoped_ptr<Event> event) { |
- base::ThreadTaskRunnerHandle::Get()->PostTask( |
- FROM_HERE, |
- base::Bind(&EventFactoryEvdev::DispatchUiEventTask, |
- weak_ptr_factory_.GetWeakPtr(), |
- base::Passed(&event))); |
+void EventFactoryEvdev::DispatchUiEvent(Event* event) { |
alexst (slow to review)
2015/01/28 19:04:58
Is there a reason we can't just remove this method
spang
2015/01/28 19:38:05
The only reason is that because there's an implici
|
+ DispatchEvent(event); |
} |
void EventFactoryEvdev::DispatchKeyboardDevicesUpdated( |
@@ -283,9 +278,6 @@ void EventFactoryEvdev::DispatchTouchpadDevicesUpdated( |
input_controller_.SetHasTouchpad(devices.size() != 0); |
} |
-void EventFactoryEvdev::DispatchUiEventTask(scoped_ptr<Event> event) { |
- DispatchEvent(event.get()); |
-} |
void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) { |
if (event.device_type() != DeviceEvent::INPUT) |
@@ -313,14 +305,15 @@ void EventFactoryEvdev::OnDispatcherListChanged() { |
void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, |
const gfx::PointF& location) { |
- if (cursor_) { |
- cursor_->MoveCursorTo(widget, location); |
- PostUiEvent(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED, |
- cursor_->GetLocation(), |
- cursor_->GetLocation(), |
- modifiers_.GetModifierFlags(), |
- /* changed_button_flags */ 0))); |
- } |
+ if (!cursor_) |
+ return; |
+ |
+ cursor_->MoveCursorTo(widget, location); |
+ |
+ base::ThreadTaskRunnerHandle::Get()->PostTask( |
+ FROM_HERE, base::Bind(&EventFactoryEvdev::DispatchMouseMoveEvent, |
+ weak_ptr_factory_.GetWeakPtr(), -1 /* device_id */, |
+ cursor_->GetLocation())); |
} |
int EventFactoryEvdev::NextDeviceId() { |