| 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/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 : container_(container) {} | 45 : container_(container) {} |
| 46 | 46 |
| 47 SystemModalContainerLayoutManager::~SystemModalContainerLayoutManager() { | 47 SystemModalContainerLayoutManager::~SystemModalContainerLayoutManager() { |
| 48 if (keyboard::KeyboardController::GetInstance()) | 48 if (keyboard::KeyboardController::GetInstance()) |
| 49 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | 49 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
| 50 } | 50 } |
| 51 | 51 |
| 52 //////////////////////////////////////////////////////////////////////////////// | 52 //////////////////////////////////////////////////////////////////////////////// |
| 53 // SystemModalContainerLayoutManager, WmLayoutManager implementation: | 53 // SystemModalContainerLayoutManager, WmLayoutManager implementation: |
| 54 | 54 |
| 55 void SystemModalContainerLayoutManager::OnChildWindowVisibilityChanged( |
| 56 WmWindow* window, |
| 57 bool visible) { |
| 58 if (GetModalType(window) != ui::MODAL_TYPE_SYSTEM) |
| 59 return; |
| 60 |
| 61 if (window->IsVisible()) { |
| 62 DCHECK(!base::ContainsValue(modal_windows_, window)); |
| 63 AddModalWindow(window); |
| 64 } else { |
| 65 if (RemoveModalWindow(window)) |
| 66 WmShell::Get()->OnModalWindowRemoved(window); |
| 67 } |
| 68 } |
| 69 |
| 55 void SystemModalContainerLayoutManager::OnWindowResized() { | 70 void SystemModalContainerLayoutManager::OnWindowResized() { |
| 56 PositionDialogsAfterWorkAreaResize(); | 71 PositionDialogsAfterWorkAreaResize(); |
| 57 } | 72 } |
| 58 | 73 |
| 59 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { | 74 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { |
| 60 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || | 75 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || |
| 61 child->GetType() == ui::wm::WINDOW_TYPE_POPUP); | 76 child->GetType() == ui::wm::WINDOW_TYPE_POPUP); |
| 62 DCHECK(container_->GetShellWindowId() != | 77 DCHECK(container_->GetShellWindowId() != |
| 63 kShellWindowId_LockSystemModalContainer || | 78 kShellWindowId_LockSystemModalContainer || |
| 64 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()); | 79 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 if (GetModalType(window) == ui::MODAL_TYPE_SYSTEM) { | 118 if (GetModalType(window) == ui::MODAL_TYPE_SYSTEM) { |
| 104 if (base::ContainsValue(modal_windows_, window)) | 119 if (base::ContainsValue(modal_windows_, window)) |
| 105 return; | 120 return; |
| 106 AddModalWindow(window); | 121 AddModalWindow(window); |
| 107 } else { | 122 } else { |
| 108 if (RemoveModalWindow(window)) | 123 if (RemoveModalWindow(window)) |
| 109 WmShell::Get()->OnModalWindowRemoved(window); | 124 WmShell::Get()->OnModalWindowRemoved(window); |
| 110 } | 125 } |
| 111 } | 126 } |
| 112 | 127 |
| 113 void SystemModalContainerLayoutManager::OnWindowVisibilityChanged( | |
| 114 WmWindow* window, | |
| 115 bool visible) { | |
| 116 if (GetModalType(window) != ui::MODAL_TYPE_SYSTEM) | |
| 117 return; | |
| 118 | |
| 119 if (window->IsVisible()) { | |
| 120 AddModalWindow(window); | |
| 121 } else { | |
| 122 RemoveModalWindow(window); | |
| 123 WmShell::Get()->OnModalWindowRemoved(window); | |
| 124 } | |
| 125 } | |
| 126 | |
| 127 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// |
| 128 // SystemModalContainerLayoutManager, Keyboard::KeybaordControllerObserver | 129 // SystemModalContainerLayoutManager, Keyboard::KeybaordControllerObserver |
| 129 // implementation: | 130 // implementation: |
| 130 | 131 |
| 131 void SystemModalContainerLayoutManager::OnKeyboardBoundsChanging( | 132 void SystemModalContainerLayoutManager::OnKeyboardBoundsChanging( |
| 132 const gfx::Rect& new_bounds) { | 133 const gfx::Rect& new_bounds) { |
| 133 PositionDialogsAfterWorkAreaResize(); | 134 PositionDialogsAfterWorkAreaResize(); |
| 134 } | 135 } |
| 135 | 136 |
| 136 void SystemModalContainerLayoutManager::OnKeyboardClosed() {} | 137 void SystemModalContainerLayoutManager::OnKeyboardClosed() {} |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 bool SystemModalContainerLayoutManager::IsBoundsCentered( | 264 bool SystemModalContainerLayoutManager::IsBoundsCentered( |
| 264 const gfx::Rect& bounds) const { | 265 const gfx::Rect& bounds) const { |
| 265 gfx::Point window_center = bounds.CenterPoint(); | 266 gfx::Point window_center = bounds.CenterPoint(); |
| 266 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); | 267 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); |
| 267 return std::abs(window_center.x() - container_center.x()) < | 268 return std::abs(window_center.x() - container_center.x()) < |
| 268 kCenterPixelDelta && | 269 kCenterPixelDelta && |
| 269 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; | 270 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; |
| 270 } | 271 } |
| 271 | 272 |
| 272 } // namespace ash | 273 } // namespace ash |
| OLD | NEW |