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" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 DispatchDetails details = | 133 DispatchDetails details = |
134 DispatchEvent(focused_window ? focused_window : window(), &event); | 134 DispatchEvent(focused_window ? focused_window : window(), &event); |
135 if (details.dispatcher_destroyed) | 135 if (details.dispatcher_destroyed) |
136 return; | 136 return; |
137 } | 137 } |
138 | 138 |
139 void WindowEventDispatcher::DispatchGestureEvent(ui::GestureEvent* event) { | 139 void WindowEventDispatcher::DispatchGestureEvent(ui::GestureEvent* event) { |
140 DispatchDetails details = DispatchHeldEvents(); | 140 DispatchDetails details = DispatchHeldEvents(); |
141 if (details.dispatcher_destroyed) | 141 if (details.dispatcher_destroyed) |
142 return; | 142 return; |
143 | |
144 Window* target = GetGestureTarget(event); | 143 Window* target = GetGestureTarget(event); |
145 if (target) { | 144 if (target) { |
146 event->ConvertLocationToTarget(window(), target); | 145 event->ConvertLocationToTarget(window(), target); |
147 DispatchDetails details = DispatchEvent(target, event); | 146 DispatchDetails details = DispatchEvent(target, event); |
148 if (details.dispatcher_destroyed) | 147 if (details.dispatcher_destroyed) |
149 return; | 148 return; |
150 } | 149 } |
151 } | 150 } |
152 | 151 |
153 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( | 152 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
523 //////////////////////////////////////////////////////////////////////////////// | 522 //////////////////////////////////////////////////////////////////////////////// |
524 // WindowEventDispatcher, ui::GestureEventHelper implementation: | 523 // WindowEventDispatcher, ui::GestureEventHelper implementation: |
525 | 524 |
526 bool WindowEventDispatcher::CanDispatchToConsumer( | 525 bool WindowEventDispatcher::CanDispatchToConsumer( |
527 ui::GestureConsumer* consumer) { | 526 ui::GestureConsumer* consumer) { |
528 Window* consumer_window = ConsumerToWindow(consumer); | 527 Window* consumer_window = ConsumerToWindow(consumer); |
529 return (consumer_window && consumer_window->GetRootWindow() == window()); | 528 return (consumer_window && consumer_window->GetRootWindow() == window()); |
530 } | 529 } |
531 | 530 |
532 void WindowEventDispatcher::DispatchCancelTouchEvent(ui::TouchEvent* event) { | 531 void WindowEventDispatcher::DispatchCancelTouchEvent(ui::TouchEvent* event) { |
532 // We observe that the cancel touch event's location got scale twice, | |
533 // because the location we use to create the touch cancel event | |
534 // is already scaled, and we scale it again in the PrepareEventForDispatch | |
535 // function. Thus, we revert the location back in the below function. | |
tdresser
2014/08/15 14:22:04
I think this could be a bit clearer. The key thing
sadrul
2014/08/15 16:10:43
What if you we don't transform the event in Window
tdresser
2014/08/15 16:48:44
Yeah, that sounds reasonable.
lanwei
2014/08/15 17:09:28
This is a very good suggestion, I will give it a t
lanwei
2014/08/27 03:54:03
Done.
| |
536 event->UpdateForRootTransform(host_->GetRootTransform()); | |
533 DispatchDetails details = OnEventFromSource(event); | 537 DispatchDetails details = OnEventFromSource(event); |
534 if (details.dispatcher_destroyed) | 538 if (details.dispatcher_destroyed) |
535 return; | 539 return; |
536 } | 540 } |
537 | 541 |
538 //////////////////////////////////////////////////////////////////////////////// | 542 //////////////////////////////////////////////////////////////////////////////// |
539 // WindowEventDispatcher, WindowObserver implementation: | 543 // WindowEventDispatcher, WindowObserver implementation: |
540 | 544 |
541 void WindowEventDispatcher::OnWindowDestroying(Window* window) { | 545 void WindowEventDispatcher::OnWindowDestroying(Window* window) { |
542 if (!host_->window()->Contains(window)) | 546 if (!host_->window()->Contains(window)) |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
898 if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event, | 902 if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event, |
899 target)) { | 903 target)) { |
900 event->SetHandled(); | 904 event->SetHandled(); |
901 } | 905 } |
902 } | 906 } |
903 | 907 |
904 PreDispatchLocatedEvent(target, event); | 908 PreDispatchLocatedEvent(target, event); |
905 } | 909 } |
906 | 910 |
907 } // namespace aura | 911 } // namespace aura |
OLD | NEW |