| 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/workspace/workspace_layout_manager.h" | 5 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/session_state_delegate.h" | 10 #include "ash/session_state_delegate.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 void WorkspaceLayoutManager::SetShelf(internal::ShelfLayoutManager* shelf) { | 111 void WorkspaceLayoutManager::SetShelf(internal::ShelfLayoutManager* shelf) { |
| 112 shelf_ = shelf; | 112 shelf_ = shelf; |
| 113 } | 113 } |
| 114 | 114 |
| 115 ////////////////////////////////////////////////////////////////////////////// | 115 ////////////////////////////////////////////////////////////////////////////// |
| 116 // WorkspaceLayoutManager, aura::LayoutManager implementation: | 116 // WorkspaceLayoutManager, aura::LayoutManager implementation: |
| 117 | 117 |
| 118 void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) { | 118 void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) { |
| 119 AdjustWindowBoundsWhenAdded(wm::GetWindowState(child)); | 119 wm::WindowState* window_state = wm::GetWindowState(child); |
| 120 AdjustWindowBoundsWhenAdded(window_state); |
| 120 | 121 |
| 121 windows_.insert(child); | 122 windows_.insert(child); |
| 122 child->AddObserver(this); | 123 child->AddObserver(this); |
| 123 wm::WindowState* window_state = wm::GetWindowState(child); | |
| 124 window_state->AddObserver(this); | 124 window_state->AddObserver(this); |
| 125 | |
| 126 // Only update the bounds if the window has a show state that depends on the | |
| 127 // workspace area. | |
| 128 if (window_state->IsMaximized()) { | |
| 129 SetChildBoundsDirect( | |
| 130 child, ScreenUtil::GetMaximizedWindowBoundsInParent(child)); | |
| 131 } else if (window_state->IsFullscreen()) { | |
| 132 SetChildBoundsDirect( | |
| 133 child, ScreenUtil::GetDisplayBoundsInParent(child)); | |
| 134 } | |
| 135 | |
| 136 UpdateShelfVisibility(); | 125 UpdateShelfVisibility(); |
| 137 UpdateFullscreenState(); | 126 UpdateFullscreenState(); |
| 138 WindowPositioner::RearrangeVisibleWindowOnShow(child); | 127 WindowPositioner::RearrangeVisibleWindowOnShow(child); |
| 139 } | 128 } |
| 140 | 129 |
| 141 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) { | 130 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) { |
| 142 windows_.erase(child); | 131 windows_.erase(child); |
| 143 child->RemoveObserver(this); | 132 child->RemoveObserver(this); |
| 144 wm::GetWindowState(child)->RemoveObserver(this); | 133 wm::GetWindowState(child)->RemoveObserver(this); |
| 145 | 134 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 168 } | 157 } |
| 169 UpdateShelfVisibility(); | 158 UpdateShelfVisibility(); |
| 170 } | 159 } |
| 171 | 160 |
| 172 void WorkspaceLayoutManager::SetChildBounds( | 161 void WorkspaceLayoutManager::SetChildBounds( |
| 173 Window* child, | 162 Window* child, |
| 174 const gfx::Rect& requested_bounds) { | 163 const gfx::Rect& requested_bounds) { |
| 175 wm::WindowState* window_state = wm::GetWindowState(child); | 164 wm::WindowState* window_state = wm::GetWindowState(child); |
| 176 if (window_state->is_dragged()) { | 165 if (window_state->is_dragged()) { |
| 177 SetChildBoundsDirect(child, requested_bounds); | 166 SetChildBoundsDirect(child, requested_bounds); |
| 167 } else if (window_state->IsSnapped()) { |
| 168 gfx::Rect child_bounds(requested_bounds); |
| 169 wm::AdjustBoundsSmallerThan(work_area_in_parent_.size(), &child_bounds); |
| 170 AdjustSnappedBounds(window_state, &child_bounds); |
| 171 SetChildBoundsDirect(child, child_bounds); |
| 178 } else if (!SetMaximizedOrFullscreenBounds(window_state)) { | 172 } else if (!SetMaximizedOrFullscreenBounds(window_state)) { |
| 179 // Some windows rely on this to set their initial bounds. | 173 // Some windows rely on this to set their initial bounds. |
| 180 // Non-maximized/full-screen windows have their size constrained to the | 174 // Non-maximized/full-screen windows have their size constrained to the |
| 181 // work-area. | 175 // work-area. |
| 182 gfx::Rect child_bounds(requested_bounds); | 176 gfx::Rect child_bounds(requested_bounds); |
| 183 child_bounds.set_width(std::min(work_area_in_parent_.width(), | 177 wm::AdjustBoundsSmallerThan(work_area_in_parent_.size(), &child_bounds); |
| 184 child_bounds.width())); | |
| 185 child_bounds.set_height(std::min(work_area_in_parent_.height(), | |
| 186 child_bounds.height())); | |
| 187 AdjustSnappedBounds(window_state, &child_bounds); | |
| 188 SetChildBoundsDirect(child, child_bounds); | 178 SetChildBoundsDirect(child, child_bounds); |
| 189 } | 179 } |
| 190 UpdateShelfVisibility(); | 180 UpdateShelfVisibility(); |
| 191 } | 181 } |
| 192 | 182 |
| 193 ////////////////////////////////////////////////////////////////////////////// | 183 ////////////////////////////////////////////////////////////////////////////// |
| 194 // WorkspaceLayoutManager, ash::ShellObserver implementation: | 184 // WorkspaceLayoutManager, ash::ShellObserver implementation: |
| 195 | 185 |
| 196 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { | 186 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { |
| 197 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( | 187 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); | 526 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); |
| 537 slide_settings.SetPreemptionStrategy( | 527 slide_settings.SetPreemptionStrategy( |
| 538 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 528 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 539 slide_settings.SetTransitionDuration( | 529 slide_settings.SetTransitionDuration( |
| 540 base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); | 530 base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); |
| 541 SetChildBoundsDirect(child, bounds); | 531 SetChildBoundsDirect(child, bounds); |
| 542 } | 532 } |
| 543 | 533 |
| 544 } // namespace internal | 534 } // namespace internal |
| 545 } // namespace ash | 535 } // namespace ash |
| OLD | NEW |