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/system_modal_container_layout_manager.h" | 5 #include "ash/wm/system_modal_container_layout_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/system_modal_container_event_filter.h" | 10 #include "ash/wm/system_modal_container_event_filter.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 return; | 115 return; |
116 | 116 |
117 if (window->GetIntProperty(aura::client::kModalKey)) { | 117 if (window->GetIntProperty(aura::client::kModalKey)) { |
118 AddModalWindow(window); | 118 AddModalWindow(window); |
119 } else if (static_cast<int>(reinterpret_cast<intptr_t>(old))) { | 119 } else if (static_cast<int>(reinterpret_cast<intptr_t>(old))) { |
120 RemoveModalWindow(window); | 120 RemoveModalWindow(window); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 //////////////////////////////////////////////////////////////////////////////// | 124 //////////////////////////////////////////////////////////////////////////////// |
125 // SystemModalContainerLayoutManager, | 125 // SystemModalContainerLayoutManager, ui::LayerAnimationObserver implementation: |
126 // ui::ImplicitAnimationObserver implementation: | |
127 | 126 |
128 void SystemModalContainerLayoutManager::OnImplicitAnimationsCompleted() { | 127 void SystemModalContainerLayoutManager::OnLayerAnimationEnded( |
| 128 const ui::LayerAnimationSequence* sequence) { |
129 if (modal_screen_ && !modal_screen_->GetNativeView()->layer()->ShouldDraw()) | 129 if (modal_screen_ && !modal_screen_->GetNativeView()->layer()->ShouldDraw()) |
130 DestroyModalScreen(); | 130 DestroyModalScreen(); |
131 } | 131 } |
132 | 132 |
| 133 void SystemModalContainerLayoutManager::OnLayerAnimationAborted( |
| 134 const ui::LayerAnimationSequence* sequence) { |
| 135 } |
| 136 |
| 137 void SystemModalContainerLayoutManager::OnLayerAnimationScheduled( |
| 138 const ui::LayerAnimationSequence* sequence) { |
| 139 } |
| 140 |
133 //////////////////////////////////////////////////////////////////////////////// | 141 //////////////////////////////////////////////////////////////////////////////// |
134 // SystemModalContainerLayoutManager, | 142 // SystemModalContainerLayoutManager, |
135 // SystemModalContainerEventFilter::Delegate implementation: | 143 // SystemModalContainerEventFilter::Delegate implementation: |
136 | 144 |
137 bool SystemModalContainerLayoutManager::CanWindowReceiveEvents( | 145 bool SystemModalContainerLayoutManager::CanWindowReceiveEvents( |
138 aura::Window* window) { | 146 aura::Window* window) { |
139 // This container can not handle events if the screen is locked and it is not | 147 // This container can not handle events if the screen is locked and it is not |
140 // above the lock screen layer (crbug.com/110920). | 148 // above the lock screen layer (crbug.com/110920). |
141 if (ash::Shell::GetInstance()->IsScreenLocked() && | 149 if (ash::Shell::GetInstance()->IsScreenLocked() && |
142 container_->id() < ash::internal::kShellWindowId_LockScreenContainer) | 150 container_->id() < ash::internal::kShellWindowId_LockScreenContainer) |
(...skipping 28 matching lines...) Expand all Loading... |
171 modal_screen_ = new views::Widget; | 179 modal_screen_ = new views::Widget; |
172 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 180 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
173 params.parent = container_; | 181 params.parent = container_; |
174 params.bounds = gfx::Rect(0, 0, container_->bounds().width(), | 182 params.bounds = gfx::Rect(0, 0, container_->bounds().width(), |
175 container_->bounds().height()); | 183 container_->bounds().height()); |
176 modal_screen_->Init(params); | 184 modal_screen_->Init(params); |
177 modal_screen_->GetNativeView()->SetName( | 185 modal_screen_->GetNativeView()->SetName( |
178 "SystemModalContainerLayoutManager.ModalScreen"); | 186 "SystemModalContainerLayoutManager.ModalScreen"); |
179 modal_screen_->SetContentsView(new ScreenView); | 187 modal_screen_->SetContentsView(new ScreenView); |
180 modal_screen_->GetNativeView()->layer()->SetOpacity(0.0f); | 188 modal_screen_->GetNativeView()->layer()->SetOpacity(0.0f); |
| 189 modal_screen_->GetNativeView()->layer()->GetAnimator()->AddObserver(this); |
181 | 190 |
182 Shell::GetInstance()->AddRootWindowEventFilter(modality_filter_.get()); | 191 Shell::GetInstance()->AddRootWindowEventFilter(modality_filter_.get()); |
183 | 192 |
184 StopObservingImplicitAnimations(); | |
185 | |
186 ui::ScopedLayerAnimationSettings settings( | 193 ui::ScopedLayerAnimationSettings settings( |
187 modal_screen_->GetNativeView()->layer()->GetAnimator()); | 194 modal_screen_->GetNativeView()->layer()->GetAnimator()); |
188 settings.AddObserver(this); | |
189 modal_screen_->Show(); | 195 modal_screen_->Show(); |
190 modal_screen_->GetNativeView()->layer()->SetOpacity(0.5f); | 196 modal_screen_->GetNativeView()->layer()->SetOpacity(0.5f); |
191 container_->StackChildAtTop(modal_screen_->GetNativeView()); | 197 container_->StackChildAtTop(modal_screen_->GetNativeView()); |
192 } | 198 } |
193 | 199 |
194 void SystemModalContainerLayoutManager::DestroyModalScreen() { | 200 void SystemModalContainerLayoutManager::DestroyModalScreen() { |
195 // Stop observing the modal screen's animations. | 201 modal_screen_->GetNativeView()->layer()->GetAnimator()->RemoveObserver(this); |
196 StopObservingImplicitAnimations(); | |
197 modal_screen_->Close(); | 202 modal_screen_->Close(); |
198 modal_screen_ = NULL; | 203 modal_screen_ = NULL; |
199 } | 204 } |
200 | 205 |
201 void SystemModalContainerLayoutManager::HideModalScreen() { | 206 void SystemModalContainerLayoutManager::HideModalScreen() { |
202 StopObservingImplicitAnimations(); | |
203 | |
204 Shell::GetInstance()->RemoveRootWindowEventFilter(modality_filter_.get()); | 207 Shell::GetInstance()->RemoveRootWindowEventFilter(modality_filter_.get()); |
205 ui::ScopedLayerAnimationSettings settings( | 208 ui::ScopedLayerAnimationSettings settings( |
206 modal_screen_->GetNativeView()->layer()->GetAnimator()); | 209 modal_screen_->GetNativeView()->layer()->GetAnimator()); |
207 settings.AddObserver(this); | |
208 modal_screen_->GetNativeView()->layer()->SetOpacity(0.0f); | 210 modal_screen_->GetNativeView()->layer()->SetOpacity(0.0f); |
209 } | 211 } |
210 | 212 |
211 } // namespace internal | 213 } // namespace internal |
212 } // namespace ash | 214 } // namespace ash |
OLD | NEW |