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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 return window(); | 429 return window(); |
431 } | 430 } |
432 | 431 |
433 void WindowEventDispatcher::PrepareEventForDispatch(ui::Event* event) { | 432 void WindowEventDispatcher::PrepareEventForDispatch(ui::Event* event) { |
434 if (dispatching_held_event_) { | 433 if (dispatching_held_event_) { |
435 // The held events are already in |window()|'s coordinate system. So it is | 434 // The held events are already in |window()|'s coordinate system. So it is |
436 // not necessary to apply the transform to convert from the host's | 435 // not necessary to apply the transform to convert from the host's |
437 // coordinate system to |window()|'s coordinate system. | 436 // coordinate system to |window()|'s coordinate system. |
438 return; | 437 return; |
439 } | 438 } |
440 if (event->IsMouseEvent() || | 439 if (event->IsLocatedEvent()) { |
441 event->IsScrollEvent() || | |
442 event->IsTouchEvent() || | |
443 event->IsGestureEvent()) { | |
444 TransformEventForDeviceScaleFactor(static_cast<ui::LocatedEvent*>(event)); | 440 TransformEventForDeviceScaleFactor(static_cast<ui::LocatedEvent*>(event)); |
445 } | 441 } |
446 } | 442 } |
447 | 443 |
448 //////////////////////////////////////////////////////////////////////////////// | 444 //////////////////////////////////////////////////////////////////////////////// |
449 // WindowEventDispatcher, ui::EventDispatcherDelegate implementation: | 445 // WindowEventDispatcher, ui::EventDispatcherDelegate implementation: |
450 | 446 |
451 bool WindowEventDispatcher::CanDispatchToTarget(ui::EventTarget* target) { | 447 bool WindowEventDispatcher::CanDispatchToTarget(ui::EventTarget* target) { |
452 return event_dispatch_target_ == target; | 448 return event_dispatch_target_ == target; |
453 } | 449 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 //////////////////////////////////////////////////////////////////////////////// | 519 //////////////////////////////////////////////////////////////////////////////// |
524 // WindowEventDispatcher, ui::GestureEventHelper implementation: | 520 // WindowEventDispatcher, ui::GestureEventHelper implementation: |
525 | 521 |
526 bool WindowEventDispatcher::CanDispatchToConsumer( | 522 bool WindowEventDispatcher::CanDispatchToConsumer( |
527 ui::GestureConsumer* consumer) { | 523 ui::GestureConsumer* consumer) { |
528 Window* consumer_window = ConsumerToWindow(consumer); | 524 Window* consumer_window = ConsumerToWindow(consumer); |
529 return (consumer_window && consumer_window->GetRootWindow() == window()); | 525 return (consumer_window && consumer_window->GetRootWindow() == window()); |
530 } | 526 } |
531 | 527 |
532 void WindowEventDispatcher::DispatchCancelTouchEvent(ui::TouchEvent* event) { | 528 void WindowEventDispatcher::DispatchCancelTouchEvent(ui::TouchEvent* event) { |
| 529 // The touchcancel event's location is based on the last known location of |
| 530 // the pointer, in dips. OnEventFromSource expects events with co-ordinates |
| 531 // in raw pixels, so we convert back to raw pixels here. |
| 532 event->UpdateForRootTransform(host_->GetRootTransform()); |
533 DispatchDetails details = OnEventFromSource(event); | 533 DispatchDetails details = OnEventFromSource(event); |
534 if (details.dispatcher_destroyed) | 534 if (details.dispatcher_destroyed) |
535 return; | 535 return; |
536 } | 536 } |
537 | 537 |
538 //////////////////////////////////////////////////////////////////////////////// | 538 //////////////////////////////////////////////////////////////////////////////// |
539 // WindowEventDispatcher, WindowObserver implementation: | 539 // WindowEventDispatcher, WindowObserver implementation: |
540 | 540 |
541 void WindowEventDispatcher::OnWindowDestroying(Window* window) { | 541 void WindowEventDispatcher::OnWindowDestroying(Window* window) { |
542 if (!host_->window()->Contains(window)) | 542 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, | 898 if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(orig_event, |
899 target)) { | 899 target)) { |
900 event->StopPropagation(); | 900 event->StopPropagation(); |
901 } | 901 } |
902 } | 902 } |
903 | 903 |
904 PreDispatchLocatedEvent(target, event); | 904 PreDispatchLocatedEvent(target, event); |
905 } | 905 } |
906 | 906 |
907 } // namespace aura | 907 } // namespace aura |
OLD | NEW |