Chromium Code Reviews| Index: ash/wm/shadow_controller.cc |
| diff --git a/ash/wm/shadow_controller.cc b/ash/wm/shadow_controller.cc |
| index 2f754533f30c8f8e310e70919a568d653bdd214f..310710eb73cc386f56f83559e59d2cb20f961741 100644 |
| --- a/ash/wm/shadow_controller.cc |
| +++ b/ash/wm/shadow_controller.cc |
| @@ -12,6 +12,7 @@ |
| #include "ash/wm/window_properties.h" |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| +#include "ui/aura/client/activation_client.h" |
| #include "ui/aura/env.h" |
| #include "ui/aura/root_window.h" |
| #include "ui/aura/window.h" |
| @@ -31,9 +32,6 @@ ShadowType GetShadowTypeFromWindow(aura::Window* window) { |
| switch (window->type()) { |
| case aura::client::WINDOW_TYPE_NORMAL: |
| case aura::client::WINDOW_TYPE_PANEL: |
| - return CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kAuraTranslucentFrames) ? |
| - SHADOW_TYPE_NONE : SHADOW_TYPE_RECTANGULAR; |
| case aura::client::WINDOW_TYPE_MENU: |
| case aura::client::WINDOW_TYPE_TOOLTIP: |
| return SHADOW_TYPE_RECTANGULAR; |
| @@ -47,6 +45,8 @@ ShadowType GetShadowTypeFromWindow(aura::Window* window) { |
| ShadowController::ShadowController() { |
| aura::Env::GetInstance()->AddObserver(this); |
| + // Watch for window activation changes. |
| + aura::RootWindow::GetInstance()->AddObserver(this); |
| } |
| ShadowController::~ShadowController() { |
| @@ -54,6 +54,7 @@ ShadowController::~ShadowController() { |
| it != window_shadows_.end(); ++it) { |
| it->first->RemoveObserver(this); |
| } |
| + aura::RootWindow::GetInstance()->RemoveObserver(this); |
| aura::Env::GetInstance()->RemoveObserver(this); |
| } |
| @@ -66,8 +67,18 @@ void ShadowController::OnWindowInitialized(aura::Window* window) { |
| void ShadowController::OnWindowPropertyChanged(aura::Window* window, |
| const void* key, |
| intptr_t old) { |
| - if (key == kShadowTypeKey) |
| + if (key == kShadowTypeKey) { |
| HandlePossibleShadowVisibilityChange(window); |
| + return; |
| + } |
| + if (key == aura::client::kRootWindowActiveWindowKey) { |
| + aura::Window* inactive = reinterpret_cast<aura::Window*>(old); |
| + HandleWindowActivationChange(inactive, false); |
|
Daniel Erat
2012/02/17 00:18:32
mind moving the NULL check out of HandleWindowActi
James Cook
2012/02/17 03:41:27
Done.
|
| + aura::Window* active = |
| + window->GetProperty(aura::client::kRootWindowActiveWindowKey); |
| + HandleWindowActivationChange(active, true); |
| + return; |
| + } |
| } |
| void ShadowController::OnWindowBoundsChanged(aura::Window* window, |
| @@ -99,6 +110,15 @@ Shadow* ShadowController::GetShadowForWindow(aura::Window* window) { |
| return it != window_shadows_.end() ? it->second.get() : NULL; |
| } |
| +void ShadowController::HandleWindowActivationChange(aura::Window* window, |
| + bool active) { |
| + if (!window) |
| + return; |
| + Shadow* shadow = GetShadowForWindow(window); |
| + if (shadow) |
| + shadow->SetStyle(active ? Shadow::STYLE_ACTIVE : Shadow::STYLE_INACTIVE); |
| +} |
| + |
| void ShadowController::HandlePossibleShadowVisibilityChange( |
| aura::Window* window) { |
| const bool should_show = ShouldShowShadowForWindow(window); |