| 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 "ash/wm/activation_controller.h" | 5 #include "ash/wm/activation_controller.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/wm/window_modality_controller.h" | 9 #include "ash/wm/window_modality_controller.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace | 113 } // namespace |
| 114 | 114 |
| 115 //////////////////////////////////////////////////////////////////////////////// | 115 //////////////////////////////////////////////////////////////////////////////// |
| 116 // ActivationController, public: | 116 // ActivationController, public: |
| 117 | 117 |
| 118 ActivationController::ActivationController() | 118 ActivationController::ActivationController() |
| 119 : updating_activation_(false), | 119 : updating_activation_(false), |
| 120 ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)) { | 120 ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)) { |
| 121 aura::client::SetActivationClient(Shell::GetRootWindow(), this); | 121 aura::client::SetActivationClient(Shell::GetPrimaryRootWindow(), this); |
| 122 aura::Env::GetInstance()->AddObserver(this); | 122 aura::Env::GetInstance()->AddObserver(this); |
| 123 Shell::GetRootWindow()->AddRootWindowObserver(this); | 123 Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this); |
| 124 } | 124 } |
| 125 | 125 |
| 126 ActivationController::~ActivationController() { | 126 ActivationController::~ActivationController() { |
| 127 Shell::GetRootWindow()->RemoveRootWindowObserver(this); | 127 Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this); |
| 128 aura::Env::GetInstance()->RemoveObserver(this); | 128 aura::Env::GetInstance()->RemoveObserver(this); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // static | 131 // static |
| 132 aura::Window* ActivationController::GetActivatableWindow( | 132 aura::Window* ActivationController::GetActivatableWindow( |
| 133 aura::Window* window, | 133 aura::Window* window, |
| 134 const aura::Event* event) { | 134 const aura::Event* event) { |
| 135 aura::Window* parent = window->parent(); | 135 aura::Window* parent = window->parent(); |
| 136 aura::Window* child = window; | 136 aura::Window* child = window; |
| 137 while (parent) { | 137 while (parent) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 158 void ActivationController::ActivateWindow(aura::Window* window) { | 158 void ActivationController::ActivateWindow(aura::Window* window) { |
| 159 ActivateWindowWithEvent(window, NULL); | 159 ActivateWindowWithEvent(window, NULL); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void ActivationController::DeactivateWindow(aura::Window* window) { | 162 void ActivationController::DeactivateWindow(aura::Window* window) { |
| 163 if (window) | 163 if (window) |
| 164 ActivateNextWindow(window); | 164 ActivateNextWindow(window); |
| 165 } | 165 } |
| 166 | 166 |
| 167 aura::Window* ActivationController::GetActiveWindow() { | 167 aura::Window* ActivationController::GetActiveWindow() { |
| 168 return Shell::GetRootWindow()->GetProperty( | 168 return Shell::GetPrimaryRootWindow()->GetProperty( |
| 169 aura::client::kRootWindowActiveWindowKey); | 169 aura::client::kRootWindowActiveWindowKey); |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool ActivationController::OnWillFocusWindow(aura::Window* window, | 172 bool ActivationController::OnWillFocusWindow(aura::Window* window, |
| 173 const aura::Event* event) { | 173 const aura::Event* event) { |
| 174 return CanActivateWindowWithEvent( | 174 return CanActivateWindowWithEvent( |
| 175 GetActivatableWindow(window, event), event, CURRENT_VISIBILITY); | 175 GetActivatableWindow(window, event), event, CURRENT_VISIBILITY); |
| 176 } | 176 } |
| 177 | 177 |
| 178 //////////////////////////////////////////////////////////////////////////////// | 178 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 10 matching lines...) Expand all Loading... |
| 189 next_window->layer()); | 189 next_window->layer()); |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 void ActivationController::OnWindowDestroying(aura::Window* window) { | 194 void ActivationController::OnWindowDestroying(aura::Window* window) { |
| 195 if (wm::IsActiveWindow(window)) { | 195 if (wm::IsActiveWindow(window)) { |
| 196 // Clear the property before activating something else, since | 196 // Clear the property before activating something else, since |
| 197 // ActivateWindow() will attempt to notify the window stored in this value | 197 // ActivateWindow() will attempt to notify the window stored in this value |
| 198 // otherwise. | 198 // otherwise. |
| 199 Shell::GetRootWindow()->ClearProperty( | 199 Shell::GetPrimaryRootWindow()->ClearProperty( |
| 200 aura::client::kRootWindowActiveWindowKey); | 200 aura::client::kRootWindowActiveWindowKey); |
| 201 ActivateWindow(GetTopmostWindowToActivate(window)); | 201 ActivateWindow(GetTopmostWindowToActivate(window)); |
| 202 } | 202 } |
| 203 observer_manager_.Remove(window); | 203 observer_manager_.Remove(window); |
| 204 } | 204 } |
| 205 | 205 |
| 206 //////////////////////////////////////////////////////////////////////////////// | 206 //////////////////////////////////////////////////////////////////////////////// |
| 207 // ActivationController, aura::EnvObserver implementation: | 207 // ActivationController, aura::EnvObserver implementation: |
| 208 | 208 |
| 209 void ActivationController::OnWindowInitialized(aura::Window* window) { | 209 void ActivationController::OnWindowInitialized(aura::Window* window) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // it will be activated when the lock window is destroyed. | 251 // it will be activated when the lock window is destroyed. |
| 252 if (window && !window->CanReceiveEvents()) { | 252 if (window && !window->CanReceiveEvents()) { |
| 253 StackTransientParentsBelowModalWindow(window); | 253 StackTransientParentsBelowModalWindow(window); |
| 254 window->parent()->StackChildAtTop(window); | 254 window->parent()->StackChildAtTop(window); |
| 255 return; | 255 return; |
| 256 } | 256 } |
| 257 if (window && | 257 if (window && |
| 258 !window->Contains(window->GetFocusManager()->GetFocusedWindow())) { | 258 !window->Contains(window->GetFocusManager()->GetFocusedWindow())) { |
| 259 window->GetFocusManager()->SetFocusedWindow(window, event); | 259 window->GetFocusManager()->SetFocusedWindow(window, event); |
| 260 } | 260 } |
| 261 Shell::GetRootWindow()->SetProperty(aura::client::kRootWindowActiveWindowKey, | 261 Shell::GetPrimaryRootWindow()->SetProperty( |
| 262 window); | 262 aura::client::kRootWindowActiveWindowKey, window); |
| 263 // Invoke OnLostActive after we've changed the active window. That way if the | 263 // Invoke OnLostActive after we've changed the active window. That way if the |
| 264 // delegate queries for active state it doesn't think the window is still | 264 // delegate queries for active state it doesn't think the window is still |
| 265 // active. | 265 // active. |
| 266 if (old_active && aura::client::GetActivationDelegate(old_active)) | 266 if (old_active && aura::client::GetActivationDelegate(old_active)) |
| 267 aura::client::GetActivationDelegate(old_active)->OnLostActive(); | 267 aura::client::GetActivationDelegate(old_active)->OnLostActive(); |
| 268 | 268 |
| 269 if (window) { | 269 if (window) { |
| 270 StackTransientParentsBelowModalWindow(window); | 270 StackTransientParentsBelowModalWindow(window); |
| 271 window->parent()->StackChildAtTop(window); | 271 window->parent()->StackChildAtTop(window); |
| 272 if (aura::client::GetActivationDelegate(window)) | 272 if (aura::client::GetActivationDelegate(window)) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 if (*i != ignore && | 318 if (*i != ignore && |
| 319 CanActivateWindowWithEvent(*i, NULL, CURRENT_VISIBILITY) && | 319 CanActivateWindowWithEvent(*i, NULL, CURRENT_VISIBILITY) && |
| 320 !wm::IsWindowMinimized(*i)) | 320 !wm::IsWindowMinimized(*i)) |
| 321 return *i; | 321 return *i; |
| 322 } | 322 } |
| 323 return NULL; | 323 return NULL; |
| 324 } | 324 } |
| 325 | 325 |
| 326 } // namespace internal | 326 } // namespace internal |
| 327 } // namespace ash | 327 } // namespace ash |
| OLD | NEW |