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/shadow_controller.h" | 5 #include "ui/views/corewm/shadow_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/shell.h" | |
10 #include "ash/wm/shadow.h" | |
11 #include "ash/wm/shadow_types.h" | |
12 #include "ash/wm/window_properties.h" | |
13 #include "base/command_line.h" | 9 #include "base/command_line.h" |
14 #include "base/logging.h" | 10 #include "base/logging.h" |
15 #include "ui/aura/client/activation_client.h" | 11 #include "ui/aura/client/activation_client.h" |
16 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
17 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
18 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
19 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
| 16 #include "ui/views/corewm/shadow.h" |
| 17 #include "ui/views/corewm/shadow_types.h" |
20 | 18 |
21 using std::make_pair; | 19 using std::make_pair; |
22 | 20 |
23 namespace ash { | 21 namespace views { |
24 namespace internal { | 22 namespace corewm { |
25 | 23 |
26 namespace { | 24 namespace { |
27 | 25 |
28 ShadowType GetShadowTypeFromWindow(aura::Window* window) { | 26 ShadowType GetShadowTypeFromWindow(aura::Window* window) { |
29 switch (window->type()) { | 27 switch (window->type()) { |
30 case aura::client::WINDOW_TYPE_NORMAL: | 28 case aura::client::WINDOW_TYPE_NORMAL: |
31 case aura::client::WINDOW_TYPE_PANEL: | 29 case aura::client::WINDOW_TYPE_PANEL: |
32 case aura::client::WINDOW_TYPE_MENU: | 30 case aura::client::WINDOW_TYPE_MENU: |
33 case aura::client::WINDOW_TYPE_TOOLTIP: | 31 case aura::client::WINDOW_TYPE_TOOLTIP: |
34 return SHADOW_TYPE_RECTANGULAR; | 32 return SHADOW_TYPE_RECTANGULAR; |
(...skipping 26 matching lines...) Expand all Loading... |
61 losing_active->transient_children().end(), | 59 losing_active->transient_children().end(), |
62 gaining_active); | 60 gaining_active); |
63 if (it != losing_active->transient_children().end()) | 61 if (it != losing_active->transient_children().end()) |
64 return Shadow::STYLE_ACTIVE; | 62 return Shadow::STYLE_ACTIVE; |
65 } | 63 } |
66 return Shadow::STYLE_INACTIVE; | 64 return Shadow::STYLE_INACTIVE; |
67 } | 65 } |
68 | 66 |
69 } // namespace | 67 } // namespace |
70 | 68 |
71 ShadowController::ShadowController() | 69 ShadowController::ShadowController(aura::RootWindow* root_window) |
72 : ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)) { | 70 : ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)), |
| 71 root_window_(root_window) { |
73 aura::Env::GetInstance()->AddObserver(this); | 72 aura::Env::GetInstance()->AddObserver(this); |
74 // Watch for window activation changes. | 73 // Watch for window activation changes. |
75 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 74 aura::client::GetActivationClient(root_window_)->AddObserver(this); |
76 AddObserver(this); | |
77 } | 75 } |
78 | 76 |
79 ShadowController::~ShadowController() { | 77 ShadowController::~ShadowController() { |
80 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 78 aura::client::GetActivationClient(root_window_)->RemoveObserver(this); |
81 RemoveObserver(this); | |
82 aura::Env::GetInstance()->RemoveObserver(this); | 79 aura::Env::GetInstance()->RemoveObserver(this); |
83 } | 80 } |
84 | 81 |
85 void ShadowController::OnWindowInitialized(aura::Window* window) { | 82 void ShadowController::OnWindowInitialized(aura::Window* window) { |
86 observer_manager_.Add(window); | 83 observer_manager_.Add(window); |
87 SetShadowType(window, GetShadowTypeFromWindow(window)); | 84 SetShadowType(window, GetShadowTypeFromWindow(window)); |
88 HandlePossibleShadowVisibilityChange(window); | 85 HandlePossibleShadowVisibilityChange(window); |
89 } | 86 } |
90 | 87 |
91 void ShadowController::OnWindowPropertyChanged(aura::Window* window, | 88 void ShadowController::OnWindowPropertyChanged(aura::Window* window, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 linked_ptr<Shadow> shadow(new Shadow()); | 155 linked_ptr<Shadow> shadow(new Shadow()); |
159 window_shadows_.insert(make_pair(window, shadow)); | 156 window_shadows_.insert(make_pair(window, shadow)); |
160 | 157 |
161 shadow->Init(ShouldUseSmallShadowForWindow(window) ? | 158 shadow->Init(ShouldUseSmallShadowForWindow(window) ? |
162 Shadow::STYLE_SMALL : Shadow::STYLE_ACTIVE); | 159 Shadow::STYLE_SMALL : Shadow::STYLE_ACTIVE); |
163 shadow->SetContentBounds(gfx::Rect(window->bounds().size())); | 160 shadow->SetContentBounds(gfx::Rect(window->bounds().size())); |
164 shadow->layer()->SetVisible(ShouldShowShadowForWindow(window)); | 161 shadow->layer()->SetVisible(ShouldShowShadowForWindow(window)); |
165 window->layer()->Add(shadow->layer()); | 162 window->layer()->Add(shadow->layer()); |
166 } | 163 } |
167 | 164 |
168 } // namespace internal | 165 } // namespace corewm |
169 } // namespace ash | 166 } // namespace views |
OLD | NEW |