| 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/shadow_controller.h" | 5 #include "ui/wm/core/shadow_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 case ui::wm::WINDOW_TYPE_PANEL: | 38 case ui::wm::WINDOW_TYPE_PANEL: |
| 39 case ui::wm::WINDOW_TYPE_MENU: | 39 case ui::wm::WINDOW_TYPE_MENU: |
| 40 case ui::wm::WINDOW_TYPE_TOOLTIP: | 40 case ui::wm::WINDOW_TYPE_TOOLTIP: |
| 41 return SHADOW_TYPE_RECTANGULAR; | 41 return SHADOW_TYPE_RECTANGULAR; |
| 42 default: | 42 default: |
| 43 break; | 43 break; |
| 44 } | 44 } |
| 45 return SHADOW_TYPE_NONE; | 45 return SHADOW_TYPE_NONE; |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool ShouldUseSmallShadowForWindow(aura::Window* window) { | 48 Shadow::Style GetShadowStyleForWindow(aura::Window* window) { |
| 49 switch (window->type()) { | 49 switch (window->type()) { |
| 50 case ui::wm::WINDOW_TYPE_MENU: | 50 case ui::wm::WINDOW_TYPE_MENU: |
| 51 case ui::wm::WINDOW_TYPE_TOOLTIP: | 51 case ui::wm::WINDOW_TYPE_TOOLTIP: |
| 52 return true; | 52 return Shadow::STYLE_SMALL; |
| 53 |
| 54 // System tray bubbles render like active windows. TODO(estade): this |
| 55 // mechanism will need to be revisited for applying WM shadows to other |
| 56 // types of bubbles which don't want to render such large shadows. |
| 57 case ui::wm::WINDOW_TYPE_POPUP: |
| 58 return Shadow::STYLE_ACTIVE; |
| 59 |
| 53 default: | 60 default: |
| 54 break; | 61 return IsActiveWindow(window) ? Shadow::STYLE_ACTIVE |
| 62 : Shadow::STYLE_INACTIVE; |
| 55 } | 63 } |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 Shadow::Style GetShadowStyleForWindow(aura::Window* window) { | |
| 60 return ShouldUseSmallShadowForWindow(window) ? Shadow::STYLE_SMALL : | |
| 61 (IsActiveWindow(window) ? Shadow::STYLE_ACTIVE : Shadow::STYLE_INACTIVE); | |
| 62 } | 64 } |
| 63 | 65 |
| 64 // Returns the shadow style to be applied to |losing_active| when it is losing | 66 // Returns the shadow style to be applied to |losing_active| when it is losing |
| 65 // active to |gaining_active|. |gaining_active| may be of a type that hides when | 67 // active to |gaining_active|. |gaining_active| may be of a type that hides when |
| 66 // inactive, and as such we do not want to render |losing_active| as inactive. | 68 // inactive, and as such we do not want to render |losing_active| as inactive. |
| 67 Shadow::Style GetShadowStyleForWindowLosingActive( | 69 Shadow::Style GetShadowStyleForWindowLosingActive( |
| 68 aura::Window* losing_active, | 70 aura::Window* losing_active, |
| 69 aura::Window* gaining_active) { | 71 aura::Window* gaining_active) { |
| 70 if (gaining_active && aura::client::GetHideOnDeactivate(gaining_active)) { | 72 if (gaining_active && aura::client::GetHideOnDeactivate(gaining_active)) { |
| 71 aura::Window::Windows::const_iterator it = | 73 aura::Window::Windows::const_iterator it = |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 void ShadowController::Impl::OnWindowDestroyed(aura::Window* window) { | 188 void ShadowController::Impl::OnWindowDestroyed(aura::Window* window) { |
| 187 window->ClearProperty(kShadowLayerKey); | 189 window->ClearProperty(kShadowLayerKey); |
| 188 observer_manager_.Remove(window); | 190 observer_manager_.Remove(window); |
| 189 } | 191 } |
| 190 | 192 |
| 191 void ShadowController::Impl::OnWindowActivated(ActivationReason reason, | 193 void ShadowController::Impl::OnWindowActivated(ActivationReason reason, |
| 192 aura::Window* gained_active, | 194 aura::Window* gained_active, |
| 193 aura::Window* lost_active) { | 195 aura::Window* lost_active) { |
| 194 if (gained_active) { | 196 if (gained_active) { |
| 195 Shadow* shadow = GetShadowForWindow(gained_active); | 197 Shadow* shadow = GetShadowForWindow(gained_active); |
| 196 if (shadow && !ShouldUseSmallShadowForWindow(gained_active)) | 198 if (shadow) |
| 197 shadow->SetStyle(Shadow::STYLE_ACTIVE); | 199 shadow->SetStyle(GetShadowStyleForWindow(gained_active)); |
| 198 } | 200 } |
| 199 if (lost_active) { | 201 if (lost_active) { |
| 200 Shadow* shadow = GetShadowForWindow(lost_active); | 202 Shadow* shadow = GetShadowForWindow(lost_active); |
| 201 if (shadow && !ShouldUseSmallShadowForWindow(lost_active)) { | 203 if (shadow && |
| 204 GetShadowStyleForWindow(lost_active) == Shadow::STYLE_INACTIVE) { |
| 202 shadow->SetStyle(GetShadowStyleForWindowLosingActive(lost_active, | 205 shadow->SetStyle(GetShadowStyleForWindowLosingActive(lost_active, |
| 203 gained_active)); | 206 gained_active)); |
| 204 } | 207 } |
| 205 } | 208 } |
| 206 } | 209 } |
| 207 | 210 |
| 208 bool ShadowController::Impl::ShouldShowShadowForWindow( | 211 bool ShadowController::Impl::ShouldShowShadowForWindow( |
| 209 aura::Window* window) const { | 212 aura::Window* window) const { |
| 210 ui::WindowShowState show_state = | 213 ui::WindowShowState show_state = |
| 211 window->GetProperty(aura::client::kShowStateKey); | 214 window->GetProperty(aura::client::kShowStateKey); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 activation_client_->RemoveObserver(this); | 279 activation_client_->RemoveObserver(this); |
| 277 } | 280 } |
| 278 | 281 |
| 279 void ShadowController::OnWindowActivated(ActivationReason reason, | 282 void ShadowController::OnWindowActivated(ActivationReason reason, |
| 280 aura::Window* gained_active, | 283 aura::Window* gained_active, |
| 281 aura::Window* lost_active) { | 284 aura::Window* lost_active) { |
| 282 impl_->OnWindowActivated(reason, gained_active, lost_active); | 285 impl_->OnWindowActivated(reason, gained_active, lost_active); |
| 283 } | 286 } |
| 284 | 287 |
| 285 } // namespace wm | 288 } // namespace wm |
| OLD | NEW |