Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: ui/aura/window_targeter.cc

Issue 184903003: Window ownership -> WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/window_event_dispatcher_unittest.cc ('k') | ui/aura/window_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « ui/aura/window_event_dispatcher_unittest.cc ('k') | ui/aura/window_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698