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/capture_client.h" |
8 #include "ui/aura/client/event_client.h" | 8 #include "ui/aura/client/event_client.h" |
9 #include "ui/aura/client/focus_client.h" | 9 #include "ui/aura/client/focus_client.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 Window* target = event->IsKeyEvent() ? | 49 Window* target = event->IsKeyEvent() ? |
50 FindTargetForKeyEvent(window, *static_cast<ui::KeyEvent*>(event)) : | 50 FindTargetForKeyEvent(window, *static_cast<ui::KeyEvent*>(event)) : |
51 static_cast<Window*>(EventTargeter::FindTargetForEvent(root, event)); | 51 static_cast<Window*>(EventTargeter::FindTargetForEvent(root, event)); |
52 if (target && !window->parent()) { | 52 if (target && !window->parent()) { |
53 // |window| is the root window. | 53 // |window| is the root window. |
54 if (!window->Contains(target)) { | 54 if (!window->Contains(target)) { |
55 // |target| is not a descendent of |window|. So do not allow dispatching | 55 // |target| is not a descendent of |window|. So do not allow dispatching |
56 // from here. Instead, dispatch the event through the | 56 // from here. Instead, dispatch the event through the |
57 // WindowEventDispatcher that owns |target|. | 57 // WindowEventDispatcher that owns |target|. |
58 ui::EventDispatchDetails details ALLOW_UNUSED = | 58 ui::EventDispatchDetails details ALLOW_UNUSED = |
59 target->GetDispatcher()->OnEventFromSource(event); | 59 target->GetHost()->dispatcher()->OnEventFromSource(event); |
60 target = NULL; | 60 target = NULL; |
61 } | 61 } |
62 } | 62 } |
63 return target; | 63 return target; |
64 } | 64 } |
65 | 65 |
66 bool WindowTargeter::SubtreeShouldBeExploredForEvent( | 66 bool WindowTargeter::SubtreeShouldBeExploredForEvent( |
67 ui::EventTarget* root, | 67 ui::EventTarget* root, |
68 const ui::LocatedEvent& event) { | 68 const ui::LocatedEvent& event) { |
69 Window* window = static_cast<Window*>(root); | 69 Window* window = static_cast<Window*>(root); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 return focused_window ? focused_window : window; | 106 return focused_window ? focused_window : window; |
107 } | 107 } |
108 | 108 |
109 Window* WindowTargeter::FindTargetInRootWindow(Window* root_window, | 109 Window* WindowTargeter::FindTargetInRootWindow(Window* root_window, |
110 const ui::LocatedEvent& event) { | 110 const ui::LocatedEvent& event) { |
111 DCHECK_EQ(root_window, root_window->GetRootWindow()); | 111 DCHECK_EQ(root_window, root_window->GetRootWindow()); |
112 | 112 |
113 // Mouse events should be dispatched to the window that processed the | 113 // Mouse events should be dispatched to the window that processed the |
114 // mouse-press events (if any). | 114 // mouse-press events (if any). |
115 if (event.IsScrollEvent() || event.IsMouseEvent()) { | 115 if (event.IsScrollEvent() || event.IsMouseEvent()) { |
116 WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 116 WindowEventDispatcher* dispatcher = root_window->GetHost()->dispatcher(); |
117 if (dispatcher->mouse_pressed_handler()) | 117 if (dispatcher->mouse_pressed_handler()) |
118 return dispatcher->mouse_pressed_handler(); | 118 return dispatcher->mouse_pressed_handler(); |
119 } | 119 } |
120 | 120 |
121 // All events should be directed towards the capture window (if any). | 121 // All events should be directed towards the capture window (if any). |
122 Window* capture_window = client::GetCaptureWindow(root_window); | 122 Window* capture_window = client::GetCaptureWindow(root_window); |
123 if (capture_window) | 123 if (capture_window) |
124 return capture_window; | 124 return capture_window; |
125 | 125 |
126 if (event.IsTouchEvent()) { | 126 if (event.IsTouchEvent()) { |
(...skipping 11 matching lines...) Expand all Loading... |
138 | 138 |
139 // If the initial touch is outside the root window, target the root. | 139 // If the initial touch is outside the root window, target the root. |
140 if (!root_window->bounds().Contains(event.location())) | 140 if (!root_window->bounds().Contains(event.location())) |
141 return root_window; | 141 return root_window; |
142 } | 142 } |
143 | 143 |
144 return NULL; | 144 return NULL; |
145 } | 145 } |
146 | 146 |
147 } // namespace aura | 147 } // namespace aura |
OLD | NEW |