OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_targeter.h" | 5 #include "ui/aura/window_targeter.h" |
6 | 6 |
| 7 #include "ui/aura/client/capture_client.h" |
7 #include "ui/aura/client/event_client.h" | 8 #include "ui/aura/client/event_client.h" |
8 #include "ui/aura/client/focus_client.h" | 9 #include "ui/aura/client/focus_client.h" |
| 10 #include "ui/aura/root_window.h" |
9 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
10 #include "ui/aura/window_delegate.h" | 12 #include "ui/aura/window_delegate.h" |
11 #include "ui/events/event_target.h" | 13 #include "ui/events/event_target.h" |
12 | 14 |
13 namespace aura { | 15 namespace aura { |
14 | 16 |
15 WindowTargeter::WindowTargeter() {} | 17 WindowTargeter::WindowTargeter() {} |
16 WindowTargeter::~WindowTargeter() {} | 18 WindowTargeter::~WindowTargeter() {} |
17 | 19 |
18 ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root, | 20 ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root, |
(...skipping 30 matching lines...) Expand all Loading... |
49 return false; | 51 return false; |
50 | 52 |
51 Window* parent = window->parent(); | 53 Window* parent = window->parent(); |
52 if (parent && parent->delegate_ && !parent->delegate_-> | 54 if (parent && parent->delegate_ && !parent->delegate_-> |
53 ShouldDescendIntoChildForEventHandling(window, event.location())) { | 55 ShouldDescendIntoChildForEventHandling(window, event.location())) { |
54 return false; | 56 return false; |
55 } | 57 } |
56 return window->bounds().Contains(event.location()); | 58 return window->bounds().Contains(event.location()); |
57 } | 59 } |
58 | 60 |
| 61 ui::EventTarget* WindowTargeter::FindTargetForLocatedEvent( |
| 62 ui::EventTarget* root, |
| 63 ui::LocatedEvent* event) { |
| 64 Window* window = static_cast<Window*>(root); |
| 65 if (!window->parent()) { |
| 66 Window* target = FindTargetInRootWindow(window, *event); |
| 67 if (target) { |
| 68 window->ConvertEventToTarget(target, event); |
| 69 return target; |
| 70 } |
| 71 } |
| 72 return EventTargeter::FindTargetForLocatedEvent(root, event); |
| 73 } |
| 74 |
| 75 Window* WindowTargeter::FindTargetInRootWindow(Window* root_window, |
| 76 const ui::LocatedEvent& event) { |
| 77 DCHECK_EQ(root_window, root_window->GetRootWindow()); |
| 78 |
| 79 // Mouse events should be dispatched to the window that processed the |
| 80 // mouse-press events (if any). |
| 81 if (event.IsScrollEvent() || event.IsMouseEvent()) { |
| 82 WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
| 83 if (dispatcher->mouse_pressed_handler()) |
| 84 return dispatcher->mouse_pressed_handler(); |
| 85 } |
| 86 |
| 87 // All events should be directed towards the capture window (if any). |
| 88 Window* capture_window = client::GetCaptureWindow(root_window); |
| 89 if (capture_window) |
| 90 return capture_window; |
| 91 |
| 92 return NULL; |
| 93 } |
| 94 |
59 } // namespace aura | 95 } // namespace aura |
OLD | NEW |