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/aura/window_event_dispatcher.h" | 5 #include "ui/aura/window_event_dispatcher.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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "ui/aura/client/capture_client.h" | 11 #include "ui/aura/client/capture_client.h" |
12 #include "ui/aura/client/cursor_client.h" | 12 #include "ui/aura/client/cursor_client.h" |
13 #include "ui/aura/client/event_client.h" | 13 #include "ui/aura/client/event_client.h" |
14 #include "ui/aura/client/focus_client.h" | 14 #include "ui/aura/client/focus_client.h" |
15 #include "ui/aura/client/screen_position_client.h" | 15 #include "ui/aura/client/screen_position_client.h" |
16 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
18 #include "ui/aura/window_delegate.h" | 18 #include "ui/aura/window_delegate.h" |
19 #include "ui/aura/window_targeter.h" | 19 #include "ui/aura/window_targeter.h" |
20 #include "ui/aura/window_tracker.h" | 20 #include "ui/aura/window_tracker.h" |
21 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
22 #include "ui/base/hit_test.h" | 22 #include "ui/base/hit_test.h" |
23 #include "ui/compositor/dip_util.h" | 23 #include "ui/compositor/dip_util.h" |
24 #include "ui/events/event.h" | 24 #include "ui/events/event.h" |
25 #include "ui/events/gestures/gesture_recognizer.h" | 25 #include "ui/events/gestures/gesture_recognizer.h" |
26 #include "ui/events/gestures/gesture_types.h" | 26 #include "ui/events/gestures/gesture_types.h" |
27 #include "ui/events/gestures/unified_gesture_detector_enabled.h" | |
jdduke (slow)
2014/08/01 14:27:22
Looks like we don't need this include anymore?
tdresser
2014/08/01 18:54:00
Done.
| |
27 | 28 |
28 typedef ui::EventDispatchDetails DispatchDetails; | 29 typedef ui::EventDispatchDetails DispatchDetails; |
29 | 30 |
30 namespace aura { | 31 namespace aura { |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 // Returns true if |target| has a non-client (frame) component at |location|, | 35 // Returns true if |target| has a non-client (frame) component at |location|, |
35 // in window coordinates. | 36 // in window coordinates. |
36 bool IsNonClientLocation(Window* target, const gfx::Point& location) { | 37 bool IsNonClientLocation(Window* target, const gfx::Point& location) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( | 154 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( |
154 const gfx::Point& point) { | 155 const gfx::Point& point) { |
155 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE, | 156 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE, |
156 ui::EF_NONE); | 157 ui::EF_NONE); |
157 return DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); | 158 return DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); |
158 } | 159 } |
159 | 160 |
160 void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event, | 161 void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event, |
161 Window* window, | 162 Window* window, |
162 ui::EventResult result) { | 163 ui::EventResult result) { |
163 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 164 ui::TouchEvent orig_event(*static_cast<const ui::TouchEvent*>(event), |
164 gestures.reset(ui::GestureRecognizer::Get()-> | 165 static_cast<Window*>(window), |
165 ProcessTouchEventForGesture(*event, result, window)); | 166 this->window()); |
167 // Once we've fully migrated to the unified gesture detector, we won't need to | |
168 // pass an event here. | |
169 scoped_ptr<ui::GestureRecognizer::Gestures> gestures( | |
170 ui::GestureRecognizer::Get()->ProcessTouchEventOnAsyncAck( | |
171 orig_event, result, window)); | |
166 DispatchDetails details = ProcessGestures(gestures.get()); | 172 DispatchDetails details = ProcessGestures(gestures.get()); |
167 if (details.dispatcher_destroyed) | 173 if (details.dispatcher_destroyed) |
168 return; | 174 return; |
169 } | 175 } |
170 | 176 |
171 void WindowEventDispatcher::HoldPointerMoves() { | 177 void WindowEventDispatcher::HoldPointerMoves() { |
172 if (!move_hold_count_) | 178 if (!move_hold_count_) |
173 held_event_factory_.InvalidateWeakPtrs(); | 179 held_event_factory_.InvalidateWeakPtrs(); |
174 ++move_hold_count_; | 180 ++move_hold_count_; |
175 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", | 181 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 old_dispatch_target_ = NULL; | 484 old_dispatch_target_ = NULL; |
479 #ifndef NDEBUG | 485 #ifndef NDEBUG |
480 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); | 486 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); |
481 #endif | 487 #endif |
482 | 488 |
483 if (event.IsTouchEvent() && !details.target_destroyed) { | 489 if (event.IsTouchEvent() && !details.target_destroyed) { |
484 // Do not let 'held' touch events contribute to any gestures unless it is | 490 // Do not let 'held' touch events contribute to any gestures unless it is |
485 // being dispatched. | 491 // being dispatched. |
486 if (dispatching_held_event_ || !held_move_event_ || | 492 if (dispatching_held_event_ || !held_move_event_ || |
487 !held_move_event_->IsTouchEvent()) { | 493 !held_move_event_->IsTouchEvent()) { |
494 // If the event is being handled asynchronously, ignore it. | |
495 if(event.result() & ui::ER_CONSUMED) | |
496 return details; | |
497 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | |
498 | |
499 // Once we've fully migrated to the unified gesture detector, we won't | |
500 // need to pass an event here. | |
488 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), | 501 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), |
489 static_cast<Window*>(event.target()), window()); | 502 static_cast<Window*>(event.target()), |
490 // Get the list of GestureEvents from GestureRecognizer. | 503 window()); |
491 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 504 gestures.reset( |
492 gestures.reset(ui::GestureRecognizer::Get()-> | 505 ui::GestureRecognizer::Get()->ProcessTouchEventPostDispatch( |
493 ProcessTouchEventForGesture(orig_event, event.result(), | 506 orig_event, event.result(), static_cast<Window*>(target))); |
494 static_cast<Window*>(target))); | 507 |
495 return ProcessGestures(gestures.get()); | 508 return ProcessGestures(gestures.get()); |
496 } | 509 } |
497 } | 510 } |
498 | 511 |
499 return details; | 512 return details; |
500 } | 513 } |
501 | 514 |
502 //////////////////////////////////////////////////////////////////////////////// | 515 //////////////////////////////////////////////////////////////////////////////// |
503 // WindowEventDispatcher, ui::GestureEventHelper implementation: | 516 // WindowEventDispatcher, ui::GestureEventHelper implementation: |
504 | 517 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
859 held_move_event_.reset(new ui::TouchEvent(*event, target, window())); | 872 held_move_event_.reset(new ui::TouchEvent(*event, target, window())); |
860 event->SetHandled(); | 873 event->SetHandled(); |
861 return; | 874 return; |
862 } | 875 } |
863 break; | 876 break; |
864 | 877 |
865 default: | 878 default: |
866 NOTREACHED(); | 879 NOTREACHED(); |
867 break; | 880 break; |
868 } | 881 } |
882 | |
883 if (dispatching_held_event_ || !held_move_event_ || | |
884 !held_move_event_->IsTouchEvent()) { | |
885 ui::TouchEvent orig_event( | |
886 static_cast<const ui::TouchEvent&>(*event), target, window()); | |
887 | |
888 // If the touch event is invalid in some way, the gesture recognizer will | |
889 // reject it. In this case, stop the touch from reaching the next event | |
890 // phase. | |
891 if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event, | |
892 target)) { | |
893 event->SetHandled(); | |
894 } | |
895 } | |
896 | |
869 PreDispatchLocatedEvent(target, event); | 897 PreDispatchLocatedEvent(target, event); |
870 } | 898 } |
871 | 899 |
872 } // namespace aura | 900 } // namespace aura |
OLD | NEW |