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" | |
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
164 gestures.reset(ui::GestureRecognizer::Get()-> | 165 |
165 ProcessTouchEventForGesture(*event, result, window)); | 166 if (!ui::IsUnifiedGestureDetectorEnabled()) { |
167 gestures.reset(ui::GestureRecognizer::Get()->ProcessTouchEventForGesture( | |
168 *event, result, window)); | |
169 } else { | |
170 gestures.reset( | |
171 ui::GestureRecognizer::Get()->AckTouchEventForGesture(result, window)); | |
172 } | |
173 | |
166 DispatchDetails details = ProcessGestures(gestures.get()); | 174 DispatchDetails details = ProcessGestures(gestures.get()); |
167 if (details.dispatcher_destroyed) | 175 if (details.dispatcher_destroyed) |
168 return; | 176 return; |
169 } | 177 } |
170 | 178 |
179 void WindowEventDispatcher::OnForwardingTouchEvent(ui::TouchEvent* event, | |
180 Window* window) { | |
181 if (ui::IsUnifiedGestureDetectorEnabled()) { | |
182 ui::GestureRecognizer::Get()->ProcessTouchEventForGesture( | |
183 *event, event->result(), window); | |
184 } | |
185 } | |
186 | |
171 void WindowEventDispatcher::HoldPointerMoves() { | 187 void WindowEventDispatcher::HoldPointerMoves() { |
172 if (!move_hold_count_) | 188 if (!move_hold_count_) |
173 held_event_factory_.InvalidateWeakPtrs(); | 189 held_event_factory_.InvalidateWeakPtrs(); |
174 ++move_hold_count_; | 190 ++move_hold_count_; |
175 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", | 191 TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves", |
176 this); | 192 this); |
177 } | 193 } |
178 | 194 |
179 void WindowEventDispatcher::ReleasePointerMoves() { | 195 void WindowEventDispatcher::ReleasePointerMoves() { |
180 --move_hold_count_; | 196 --move_hold_count_; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); | 496 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); |
481 #endif | 497 #endif |
482 | 498 |
483 if (event.IsTouchEvent() && !details.target_destroyed) { | 499 if (event.IsTouchEvent() && !details.target_destroyed) { |
484 // Do not let 'held' touch events contribute to any gestures unless it is | 500 // Do not let 'held' touch events contribute to any gestures unless it is |
485 // being dispatched. | 501 // being dispatched. |
486 if (dispatching_held_event_ || !held_move_event_ || | 502 if (dispatching_held_event_ || !held_move_event_ || |
487 !held_move_event_->IsTouchEvent()) { | 503 !held_move_event_->IsTouchEvent()) { |
488 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), | 504 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), |
489 static_cast<Window*>(event.target()), window()); | 505 static_cast<Window*>(event.target()), window()); |
490 // Get the list of GestureEvents from GestureRecognizer. | 506 // If the event isn't being handled asynchronously, handle it now. |
491 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 507 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
492 gestures.reset(ui::GestureRecognizer::Get()-> | 508 gestures.reset(ui::GestureRecognizer::Get()-> |
493 ProcessTouchEventForGesture(orig_event, event.result(), | 509 ProcessTouchEventForGesture(orig_event, event.result(), |
494 static_cast<Window*>(target))); | 510 static_cast<Window*>(target))); |
511 | |
512 if (ui::IsUnifiedGestureDetectorEnabled()) { | |
513 if (!(event.result() & ui::ER_CONSUMED)) { | |
514 gestures.reset(ui::GestureRecognizer::Get()->AckTouchEventForGesture( | |
515 event.result(), static_cast<Window*>(target))); | |
516 } | |
517 } | |
sadrul
2014/07/16 21:07:49
Should this be something like:
if (unified && !c
tdresser
2014/07/28 18:22:09
This issue has been addressed in the most recent p
| |
495 return ProcessGestures(gestures.get()); | 518 return ProcessGestures(gestures.get()); |
496 } | 519 } |
497 } | 520 } |
498 | 521 |
499 return details; | 522 return details; |
500 } | 523 } |
501 | 524 |
502 //////////////////////////////////////////////////////////////////////////////// | 525 //////////////////////////////////////////////////////////////////////////////// |
503 // WindowEventDispatcher, ui::GestureEventHelper implementation: | 526 // WindowEventDispatcher, ui::GestureEventHelper implementation: |
504 | 527 |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 break; | 886 break; |
864 | 887 |
865 default: | 888 default: |
866 NOTREACHED(); | 889 NOTREACHED(); |
867 break; | 890 break; |
868 } | 891 } |
869 PreDispatchLocatedEvent(target, event); | 892 PreDispatchLocatedEvent(target, event); |
870 } | 893 } |
871 | 894 |
872 } // namespace aura | 895 } // namespace aura |
OLD | NEW |