| 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 <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/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/wm/dim_window.h" | 13 #include "ash/wm/dim_window.h" |
| 14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
| 17 #include "ui/aura/client/capture_client.h" | 17 #include "ui/aura/client/capture_client.h" |
| 18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_property.h" | 19 #include "ui/aura/window_property.h" |
| 20 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
| 21 #include "ui/keyboard/keyboard_controller.h" | 21 #include "ui/keyboard/keyboard_controller.h" |
| 22 #include "ui/wm/core/window_util.h" |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // The center point of the window can diverge this much from the center point | 27 // The center point of the window can diverge this much from the center point |
| 27 // If this is set to true, the window will get centered. | 28 // If this is set to true, the window will get centered. |
| 28 DEFINE_WINDOW_PROPERTY_KEY(bool, kCenteredKey, false); | 29 DEFINE_WINDOW_PROPERTY_KEY(bool, kCenteredKey, false); |
| 29 | 30 |
| 30 // The center point of the window can diverge this much from the center point | 31 // The center point of the window can diverge this much from the center point |
| 31 // of the container to be kept centered upon resizing operations. | 32 // of the container to be kept centered upon resizing operations. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // SystemModalContainerLayoutManager, Keyboard::KeybaordControllerObserver | 134 // SystemModalContainerLayoutManager, Keyboard::KeybaordControllerObserver |
| 134 // implementation: | 135 // implementation: |
| 135 | 136 |
| 136 void SystemModalContainerLayoutManager::OnKeyboardBoundsChanging( | 137 void SystemModalContainerLayoutManager::OnKeyboardBoundsChanging( |
| 137 const gfx::Rect& new_bounds) { | 138 const gfx::Rect& new_bounds) { |
| 138 PositionDialogsAfterWorkAreaResize(); | 139 PositionDialogsAfterWorkAreaResize(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 bool SystemModalContainerLayoutManager::IsPartOfActiveModalWindow( | 142 bool SystemModalContainerLayoutManager::IsPartOfActiveModalWindow( |
| 142 aura::Window* window) { | 143 aura::Window* window) { |
| 143 return modal_window() && modal_window()->Contains(window); | 144 return modal_window() && |
| 145 (modal_window()->Contains(window) || |
| 146 ::wm::HasTransientAncestor(::wm::GetToplevelWindow(window), |
| 147 modal_window())); |
| 144 } | 148 } |
| 145 | 149 |
| 146 bool SystemModalContainerLayoutManager::ActivateNextModalWindow() { | 150 bool SystemModalContainerLayoutManager::ActivateNextModalWindow() { |
| 147 if (modal_windows_.empty()) | 151 if (modal_windows_.empty()) |
| 148 return false; | 152 return false; |
| 149 wm::ActivateWindow(modal_window()); | 153 wm::ActivateWindow(modal_window()); |
| 150 return true; | 154 return true; |
| 151 } | 155 } |
| 152 | 156 |
| 153 void SystemModalContainerLayoutManager::CreateModalBackground() { | 157 void SystemModalContainerLayoutManager::CreateModalBackground() { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 bool SystemModalContainerLayoutManager::DialogIsCentered( | 272 bool SystemModalContainerLayoutManager::DialogIsCentered( |
| 269 const gfx::Rect& window_bounds) { | 273 const gfx::Rect& window_bounds) { |
| 270 gfx::Point window_center = window_bounds.CenterPoint(); | 274 gfx::Point window_center = window_bounds.CenterPoint(); |
| 271 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); | 275 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); |
| 272 return std::abs(window_center.x() - container_center.x()) < | 276 return std::abs(window_center.x() - container_center.x()) < |
| 273 kCenterPixelDelta && | 277 kCenterPixelDelta && |
| 274 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; | 278 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; |
| 275 } | 279 } |
| 276 | 280 |
| 277 } // namespace ash | 281 } // namespace ash |
| OLD | NEW |