Chromium Code Reviews| Index: ash/pointer_watcher_delegate_aura.cc |
| diff --git a/ash/pointer_watcher_delegate_aura.cc b/ash/pointer_watcher_delegate_aura.cc |
| index 9e72178a25cf0e6ce1550a8d28801a9bd6f6fd6f..41ff7e8ec134ed55d3f537641c59e4232e022952 100644 |
| --- a/ash/pointer_watcher_delegate_aura.cc |
| +++ b/ash/pointer_watcher_delegate_aura.cc |
| @@ -24,25 +24,47 @@ PointerWatcherDelegateAura::~PointerWatcherDelegateAura() { |
| } |
| void PointerWatcherDelegateAura::AddPointerWatcher( |
| - views::PointerWatcher* watcher) { |
| + views::PointerWatcher* watcher, |
| + bool wants_moves) { |
| pointer_watchers_.AddObserver(watcher); |
| + if (wants_moves) { |
|
James Cook
2016/08/11 23:51:10
Since want_moves is always true in the map, you co
|
| + wants_moves_map_.insert( |
| + std::pair<views::PointerWatcher*, bool>(watcher, wants_moves)); |
| + } |
| } |
| void PointerWatcherDelegateAura::RemovePointerWatcher( |
| views::PointerWatcher* watcher) { |
| pointer_watchers_.RemoveObserver(watcher); |
| + auto it = wants_moves_map_.find(watcher); |
| + if (it != wants_moves_map_.end()) |
| + wants_moves_map_.erase(it); |
| } |
| void PointerWatcherDelegateAura::OnMouseEvent(ui::MouseEvent* event) { |
| // For compatibility with the mus version, don't send moves. |
| - if (event->type() != ui::ET_MOUSE_PRESSED && |
| + if (event->type() != ui::ET_MOUSE_DRAGGED && |
|
James Cook
2016/08/11 23:51:10
Good catch on drags.
|
| + event->type() != ui::ET_MOUSE_MOVED && |
| + event->type() != ui::ET_MOUSE_PRESSED && |
| event->type() != ui::ET_MOUSE_RELEASED) |
| return; |
| + |
| ui::PointerEvent mouse_pointer_event(*event); |
| - FOR_EACH_OBSERVER( |
| - views::PointerWatcher, pointer_watchers_, |
| - OnPointerEventObserved(mouse_pointer_event, GetLocationInScreen(*event), |
| - GetTargetWidget(*event))); |
| + // Mouse move events only sent to a select number of observers. |
| + if (event->type() == ui::ET_MOUSE_DRAGGED || |
| + event->type() == ui::ET_MOUSE_MOVED) { |
| + auto it = wants_moves_map_.begin(); |
| + for (; it != wants_moves_map_.end(); it++) { |
| + it->first->OnPointerEventObserved(mouse_pointer_event, |
| + GetLocationInScreen(*event), |
| + GetTargetWidget(*event)); |
| + } |
| + } else { |
| + FOR_EACH_OBSERVER( |
| + views::PointerWatcher, pointer_watchers_, |
| + OnPointerEventObserved(mouse_pointer_event, GetLocationInScreen(*event), |
| + GetTargetWidget(*event))); |
| + } |
| } |
| void PointerWatcherDelegateAura::OnTouchEvent(ui::TouchEvent* event) { |