OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/corewm/base_focus_rules.h" | 5 #include "ui/views/corewm/base_focus_rules.h" |
6 | 6 |
7 #include "ui/aura/client/activation_delegate.h" | 7 #include "ui/aura/client/activation_delegate.h" |
8 #include "ui/aura/client/focus_client.h" | 8 #include "ui/aura/client/focus_client.h" |
9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
11 #include "ui/views/corewm/window_modality_controller.h" | 11 #include "ui/views/corewm/window_modality_controller.h" |
| 12 #include "ui/views/corewm/window_util.h" |
12 | 13 |
13 namespace views { | 14 namespace views { |
14 namespace corewm { | 15 namespace corewm { |
15 namespace { | 16 namespace { |
16 | 17 |
17 aura::Window* GetFocusedWindow(aura::Window* context) { | 18 aura::Window* GetFocusedWindow(aura::Window* context) { |
18 aura::client::FocusClient* focus_client = | 19 aura::client::FocusClient* focus_client = |
19 aura::client::GetFocusClient(context); | 20 aura::client::GetFocusClient(context); |
20 return focus_client ? focus_client->GetFocusedWindow() : NULL; | 21 return focus_client ? focus_client->GetFocusedWindow() : NULL; |
21 } | 22 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 return child; | 114 return child; |
114 | 115 |
115 // CanActivateWindow() above will return false if |child| is blocked by a | 116 // CanActivateWindow() above will return false if |child| is blocked by a |
116 // modal transient. In this case the modal is or contains the activatable | 117 // modal transient. In this case the modal is or contains the activatable |
117 // window. We recurse because the modal may itself be blocked by a modal | 118 // window. We recurse because the modal may itself be blocked by a modal |
118 // transient. | 119 // transient. |
119 aura::Window* modal_transient = GetModalTransient(child); | 120 aura::Window* modal_transient = GetModalTransient(child); |
120 if (modal_transient) | 121 if (modal_transient) |
121 return GetActivatableWindow(modal_transient); | 122 return GetActivatableWindow(modal_transient); |
122 | 123 |
123 if (child->transient_parent()) { | 124 if (views::corewm::GetTransientParent(child)) { |
124 // To avoid infinite recursion, if |child| has a transient parent | 125 // To avoid infinite recursion, if |child| has a transient parent |
125 // whose own modal transient is |child| itself, just return |child|. | 126 // whose own modal transient is |child| itself, just return |child|. |
126 aura::Window* parent_modal_transient = | 127 aura::Window* parent_modal_transient = |
127 GetModalTransient(child->transient_parent()); | 128 GetModalTransient(views::corewm::GetTransientParent(child)); |
128 if (parent_modal_transient == child) | 129 if (parent_modal_transient == child) |
129 return child; | 130 return child; |
130 | 131 |
131 return GetActivatableWindow(child->transient_parent()); | 132 return GetActivatableWindow(views::corewm::GetTransientParent(child)); |
132 } | 133 } |
133 | 134 |
134 parent = parent->parent(); | 135 parent = parent->parent(); |
135 child = child->parent(); | 136 child = child->parent(); |
136 } | 137 } |
137 return NULL; | 138 return NULL; |
138 } | 139 } |
139 | 140 |
140 aura::Window* BaseFocusRules::GetFocusableWindow(aura::Window* window) const { | 141 aura::Window* BaseFocusRules::GetFocusableWindow(aura::Window* window) const { |
141 if (CanFocusWindow(window)) | 142 if (CanFocusWindow(window)) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 if (cur == ignore) | 188 if (cur == ignore) |
188 continue; | 189 continue; |
189 if (CanActivateWindow(cur)) | 190 if (CanActivateWindow(cur)) |
190 return cur; | 191 return cur; |
191 } | 192 } |
192 return NULL; | 193 return NULL; |
193 } | 194 } |
194 | 195 |
195 } // namespace corewm | 196 } // namespace corewm |
196 } // namespace views | 197 } // namespace views |
OLD | NEW |