| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 event->ConvertLocationToTarget(window(), target); | 167 event->ConvertLocationToTarget(window(), target); |
| 168 DispatchDetails details = DispatchEvent(target, event); | 168 DispatchDetails details = DispatchEvent(target, event); |
| 169 if (details.dispatcher_destroyed) | 169 if (details.dispatcher_destroyed) |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( | 174 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( |
| 175 Window* window, | 175 Window* window, |
| 176 const gfx::Point& point) { | 176 const gfx::Point& point) { |
| 177 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EventTimeForNow(), | 177 ui::MouseEvent event( |
| 178 ui::EF_NONE, ui::EF_NONE); | 178 ui::ET_MOUSE_EXITED, point, point, ui::EventTimeForNow(), ui::EF_NONE, |
| 179 ui::EF_NONE, |
| 180 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, |
| 181 ui::PointerEvent::kMousePointerId)); |
| 179 return DispatchMouseEnterOrExit(window, event, ui::ET_MOUSE_EXITED); | 182 return DispatchMouseEnterOrExit(window, event, ui::ET_MOUSE_EXITED); |
| 180 } | 183 } |
| 181 | 184 |
| 182 void WindowEventDispatcher::ProcessedTouchEvent(uint32_t unique_event_id, | 185 void WindowEventDispatcher::ProcessedTouchEvent(uint32_t unique_event_id, |
| 183 Window* window, | 186 Window* window, |
| 184 ui::EventResult result) { | 187 ui::EventResult result) { |
| 185 ui::GestureRecognizer::Gestures gestures = | 188 ui::GestureRecognizer::Gestures gestures = |
| 186 ui::GestureRecognizer::Get()->AckTouchEvent(unique_event_id, result, | 189 ui::GestureRecognizer::Get()->AckTouchEvent(unique_event_id, result, |
| 187 window); | 190 window); |
| 188 DispatchDetails details = ProcessGestures(window, std::move(gestures)); | 191 DispatchDetails details = ProcessGestures(window, std::move(gestures)); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 Window* new_capture) { | 375 Window* new_capture) { |
| 373 // |mouse_moved_handler_| may have been set to a Window in a different root | 376 // |mouse_moved_handler_| may have been set to a Window in a different root |
| 374 // (see below). Clear it here to ensure we don't end up referencing a stale | 377 // (see below). Clear it here to ensure we don't end up referencing a stale |
| 375 // Window. | 378 // Window. |
| 376 if (mouse_moved_handler_ && !window()->Contains(mouse_moved_handler_)) | 379 if (mouse_moved_handler_ && !window()->Contains(mouse_moved_handler_)) |
| 377 mouse_moved_handler_ = NULL; | 380 mouse_moved_handler_ = NULL; |
| 378 | 381 |
| 379 if (old_capture && old_capture->GetRootWindow() == window() && | 382 if (old_capture && old_capture->GetRootWindow() == window() && |
| 380 old_capture->delegate()) { | 383 old_capture->delegate()) { |
| 381 // Send a capture changed event with bogus location data. | 384 // Send a capture changed event with bogus location data. |
| 382 ui::MouseEvent event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), | 385 ui::MouseEvent event( |
| 383 gfx::Point(), ui::EventTimeForNow(), 0, 0); | 386 ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(), gfx::Point(), |
| 387 ui::EventTimeForNow(), 0, 0, |
| 388 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, |
| 389 ui::PointerEvent::kMousePointerId)); |
| 384 | 390 |
| 385 DispatchDetails details = DispatchEvent(old_capture, &event); | 391 DispatchDetails details = DispatchEvent(old_capture, &event); |
| 386 if (details.dispatcher_destroyed) | 392 if (details.dispatcher_destroyed) |
| 387 return; | 393 return; |
| 388 | 394 |
| 389 if (!details.target_destroyed) | 395 if (!details.target_destroyed) |
| 390 old_capture->delegate()->OnCaptureLost(); | 396 old_capture->delegate()->OnCaptureLost(); |
| 391 } | 397 } |
| 392 | 398 |
| 393 if (new_capture) { | 399 if (new_capture) { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 // DRAGGED event can be synthesized in the incorrect host. So avoid | 774 // DRAGGED event can be synthesized in the incorrect host. So avoid |
| 769 // synthesizing any events at all. | 775 // synthesizing any events at all. |
| 770 if (Env::GetInstance()->mouse_button_flags()) | 776 if (Env::GetInstance()->mouse_button_flags()) |
| 771 return details; | 777 return details; |
| 772 | 778 |
| 773 gfx::Point root_mouse_location = GetLastMouseLocationInRoot(); | 779 gfx::Point root_mouse_location = GetLastMouseLocationInRoot(); |
| 774 if (!window()->bounds().Contains(root_mouse_location)) | 780 if (!window()->bounds().Contains(root_mouse_location)) |
| 775 return details; | 781 return details; |
| 776 gfx::Point host_mouse_location = root_mouse_location; | 782 gfx::Point host_mouse_location = root_mouse_location; |
| 777 host_->ConvertDIPToPixels(&host_mouse_location); | 783 host_->ConvertDIPToPixels(&host_mouse_location); |
| 778 ui::MouseEvent event(ui::ET_MOUSE_MOVED, host_mouse_location, | 784 ui::MouseEvent event( |
| 779 host_mouse_location, ui::EventTimeForNow(), | 785 ui::ET_MOUSE_MOVED, host_mouse_location, host_mouse_location, |
| 780 ui::EF_IS_SYNTHESIZED, 0); | 786 ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0, |
| 787 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, |
| 788 ui::PointerEvent::kMousePointerId)); |
| 781 return OnEventFromSource(&event); | 789 return OnEventFromSource(&event); |
| 782 } | 790 } |
| 783 | 791 |
| 784 DispatchDetails WindowEventDispatcher::PreDispatchLocatedEvent( | 792 DispatchDetails WindowEventDispatcher::PreDispatchLocatedEvent( |
| 785 Window* target, | 793 Window* target, |
| 786 ui::LocatedEvent* event) { | 794 ui::LocatedEvent* event) { |
| 787 int flags = event->flags(); | 795 int flags = event->flags(); |
| 788 if (IsNonClientLocation(target, event->location())) | 796 if (IsNonClientLocation(target, event->location())) |
| 789 flags |= ui::EF_IS_NON_CLIENT; | 797 flags |= ui::EF_IS_NON_CLIENT; |
| 790 event->set_flags(flags); | 798 event->set_flags(flags); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 } | 929 } |
| 922 | 930 |
| 923 // This flag is set depending on the gestures recognized in the call above, | 931 // This flag is set depending on the gestures recognized in the call above, |
| 924 // and needs to propagate with the forwarded event. | 932 // and needs to propagate with the forwarded event. |
| 925 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); | 933 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); |
| 926 | 934 |
| 927 return PreDispatchLocatedEvent(target, event); | 935 return PreDispatchLocatedEvent(target, event); |
| 928 } | 936 } |
| 929 | 937 |
| 930 } // namespace aura | 938 } // namespace aura |
| OLD | NEW |