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/common/wm/system_modal_container_layout_manager.h" | 5 #include "ash/common/wm/system_modal_container_layout_manager.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/common/wm/window_dimmer.h" | 10 #include "ash/common/wm/window_dimmer.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 bool SystemModalContainerLayoutManager::ActivateNextModalWindow() { | 154 bool SystemModalContainerLayoutManager::ActivateNextModalWindow() { |
155 if (modal_windows_.empty()) | 155 if (modal_windows_.empty()) |
156 return false; | 156 return false; |
157 modal_window()->Activate(); | 157 modal_window()->Activate(); |
158 return true; | 158 return true; |
159 } | 159 } |
160 | 160 |
161 void SystemModalContainerLayoutManager::CreateModalBackground() { | 161 void SystemModalContainerLayoutManager::CreateModalBackground() { |
162 if (!window_dimmer_) { | 162 if (!window_dimmer_) { |
163 window_dimmer_ = base::MakeUnique<WindowDimmer>(container_); | 163 window_dimmer_ = base::MakeUnique<WindowDimmer>(container_->aura_window()); |
164 window_dimmer_->window()->SetName( | 164 window_dimmer_->window()->SetName( |
165 "SystemModalContainerLayoutManager.ModalBackground"); | 165 "SystemModalContainerLayoutManager.ModalBackground"); |
166 // There isn't always a keyboard controller. | 166 // There isn't always a keyboard controller. |
167 if (keyboard::KeyboardController::GetInstance()) | 167 if (keyboard::KeyboardController::GetInstance()) |
168 keyboard::KeyboardController::GetInstance()->AddObserver(this); | 168 keyboard::KeyboardController::GetInstance()->AddObserver(this); |
169 } | 169 } |
170 window_dimmer_->window()->Show(); | 170 window_dimmer_->window()->Show(); |
171 } | 171 } |
172 | 172 |
173 void SystemModalContainerLayoutManager::DestroyModalBackground() { | 173 void SystemModalContainerLayoutManager::DestroyModalBackground() { |
174 if (!window_dimmer_) | 174 if (!window_dimmer_) |
175 return; | 175 return; |
176 | 176 |
177 if (keyboard::KeyboardController::GetInstance()) | 177 if (keyboard::KeyboardController::GetInstance()) |
178 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | 178 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
179 window_dimmer_.reset(); | 179 window_dimmer_.reset(); |
180 } | 180 } |
181 | 181 |
182 // static | 182 // static |
183 bool SystemModalContainerLayoutManager::IsModalBackground(WmWindow* window) { | 183 bool SystemModalContainerLayoutManager::IsModalBackground(WmWindow* window) { |
184 int id = window->GetParent()->GetShellWindowId(); | 184 int id = window->GetParent()->GetShellWindowId(); |
185 if (id != kShellWindowId_SystemModalContainer && | 185 if (id != kShellWindowId_SystemModalContainer && |
186 id != kShellWindowId_LockSystemModalContainer) | 186 id != kShellWindowId_LockSystemModalContainer) |
187 return false; | 187 return false; |
188 SystemModalContainerLayoutManager* layout_manager = | 188 SystemModalContainerLayoutManager* layout_manager = |
189 static_cast<SystemModalContainerLayoutManager*>( | 189 static_cast<SystemModalContainerLayoutManager*>( |
190 window->GetParent()->GetLayoutManager()); | 190 window->GetParent()->GetLayoutManager()); |
191 return layout_manager->window_dimmer_ && | 191 return layout_manager->window_dimmer_ && |
192 layout_manager->window_dimmer_->window() == window; | 192 WmWindow::Get(layout_manager->window_dimmer_->window()) == window; |
193 } | 193 } |
194 | 194 |
195 //////////////////////////////////////////////////////////////////////////////// | 195 //////////////////////////////////////////////////////////////////////////////// |
196 // SystemModalContainerLayoutManager, private: | 196 // SystemModalContainerLayoutManager, private: |
197 | 197 |
198 void SystemModalContainerLayoutManager::AddModalWindow(WmWindow* window) { | 198 void SystemModalContainerLayoutManager::AddModalWindow(WmWindow* window) { |
199 if (modal_windows_.empty()) { | 199 if (modal_windows_.empty()) { |
200 WmWindow* capture_window = WmShell::Get()->GetCaptureWindow(); | 200 WmWindow* capture_window = WmShell::Get()->GetCaptureWindow(); |
201 if (capture_window) | 201 if (capture_window) |
202 capture_window->ReleaseCapture(); | 202 capture_window->ReleaseCapture(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 bool SystemModalContainerLayoutManager::IsBoundsCentered( | 271 bool SystemModalContainerLayoutManager::IsBoundsCentered( |
272 const gfx::Rect& bounds) const { | 272 const gfx::Rect& bounds) const { |
273 gfx::Point window_center = bounds.CenterPoint(); | 273 gfx::Point window_center = bounds.CenterPoint(); |
274 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); | 274 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); |
275 return std::abs(window_center.x() - container_center.x()) < | 275 return std::abs(window_center.x() - container_center.x()) < |
276 kCenterPixelDelta && | 276 kCenterPixelDelta && |
277 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; | 277 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; |
278 } | 278 } |
279 | 279 |
280 } // namespace ash | 280 } // namespace ash |
OLD | NEW |