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