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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 | 152 |
153 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( | 153 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( |
154 Window* window, | 154 Window* window, |
155 const gfx::Point& point) { | 155 const gfx::Point& point) { |
156 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EventTimeForNow(), | 156 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EventTimeForNow(), |
157 ui::EF_NONE, ui::EF_NONE); | 157 ui::EF_NONE, ui::EF_NONE); |
158 return DispatchMouseEnterOrExit(window, event, ui::ET_MOUSE_EXITED); | 158 return DispatchMouseEnterOrExit(window, event, ui::ET_MOUSE_EXITED); |
159 } | 159 } |
160 | 160 |
| 161 void WindowEventDispatcher::PostSynthesizeMouseMove() { |
| 162 if (synthesize_mouse_move_) |
| 163 return; |
| 164 synthesize_mouse_move_ = true; |
| 165 base::MessageLoop::current()->PostNonNestableTask( |
| 166 FROM_HERE, |
| 167 base::Bind(base::IgnoreResult( |
| 168 &WindowEventDispatcher::SynthesizeMouseMoveEvent), |
| 169 held_event_factory_.GetWeakPtr())); |
| 170 } |
| 171 |
161 void WindowEventDispatcher::ProcessedTouchEvent(Window* window, | 172 void WindowEventDispatcher::ProcessedTouchEvent(Window* window, |
162 ui::EventResult result) { | 173 ui::EventResult result) { |
163 scoped_ptr<ui::GestureRecognizer::Gestures> gestures( | 174 scoped_ptr<ui::GestureRecognizer::Gestures> gestures( |
164 ui::GestureRecognizer::Get()->AckAsyncTouchEvent(result, window)); | 175 ui::GestureRecognizer::Get()->AckAsyncTouchEvent(result, window)); |
165 DispatchDetails details = ProcessGestures(gestures.get()); | 176 DispatchDetails details = ProcessGestures(gestures.get()); |
166 if (details.dispatcher_destroyed) | 177 if (details.dispatcher_destroyed) |
167 return; | 178 return; |
168 } | 179 } |
169 | 180 |
170 void WindowEventDispatcher::HoldPointerMoves() { | 181 void WindowEventDispatcher::HoldPointerMoves() { |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 } | 689 } |
679 if (!dispatch_details.dispatcher_destroyed) | 690 if (!dispatch_details.dispatcher_destroyed) |
680 held_move_event_.reset(); | 691 held_move_event_.reset(); |
681 } | 692 } |
682 | 693 |
683 if (!dispatch_details.dispatcher_destroyed) | 694 if (!dispatch_details.dispatcher_destroyed) |
684 dispatching_held_event_ = nullptr; | 695 dispatching_held_event_ = nullptr; |
685 return dispatch_details; | 696 return dispatch_details; |
686 } | 697 } |
687 | 698 |
688 void WindowEventDispatcher::PostSynthesizeMouseMove() { | |
689 if (synthesize_mouse_move_) | |
690 return; | |
691 synthesize_mouse_move_ = true; | |
692 base::MessageLoop::current()->PostNonNestableTask( | |
693 FROM_HERE, | |
694 base::Bind(base::IgnoreResult( | |
695 &WindowEventDispatcher::SynthesizeMouseMoveEvent), | |
696 held_event_factory_.GetWeakPtr())); | |
697 } | |
698 | |
699 void WindowEventDispatcher::SynthesizeMouseMoveAfterChangeToWindow( | 699 void WindowEventDispatcher::SynthesizeMouseMoveAfterChangeToWindow( |
700 Window* window) { | 700 Window* window) { |
701 if (window->IsVisible() && | 701 if (window->IsVisible() && |
702 window->ContainsPointInRoot(GetLastMouseLocationInRoot())) { | 702 window->ContainsPointInRoot(GetLastMouseLocationInRoot())) { |
703 PostSynthesizeMouseMove(); | 703 PostSynthesizeMouseMove(); |
704 } | 704 } |
705 } | 705 } |
706 | 706 |
707 ui::EventDispatchDetails WindowEventDispatcher::SynthesizeMouseMoveEvent() { | 707 ui::EventDispatchDetails WindowEventDispatcher::SynthesizeMouseMoveEvent() { |
708 DispatchDetails details; | 708 DispatchDetails details; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 } | 891 } |
892 | 892 |
893 // This flag is set depending on the gestures recognized in the call above, | 893 // This flag is set depending on the gestures recognized in the call above, |
894 // and needs to propagate with the forwarded event. | 894 // and needs to propagate with the forwarded event. |
895 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); | 895 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); |
896 | 896 |
897 PreDispatchLocatedEvent(target, event); | 897 PreDispatchLocatedEvent(target, event); |
898 } | 898 } |
899 | 899 |
900 } // namespace aura | 900 } // namespace aura |
OLD | NEW |