Chromium Code Reviews| 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); |
|
pkotwicz
2014/02/13 00:32:39
Isn't the logic below redundant and already perfor
oshima
2014/02/13 01:10:13
Good point. Looks like we've been doing this twice
| |
| 125 | 125 if (!window_state->is_dragged()) |
| 126 // Only update the bounds if the window has a show state that depends on the | 126 SetMaximizedOrFullscreenBounds(window_state); |
| 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 | 127 |
| 136 UpdateShelfVisibility(); | 128 UpdateShelfVisibility(); |
| 137 UpdateFullscreenState(); | 129 UpdateFullscreenState(); |
| 138 WindowPositioner::RearrangeVisibleWindowOnShow(child); | 130 WindowPositioner::RearrangeVisibleWindowOnShow(child); |
| 139 } | 131 } |
| 140 | 132 |
| 141 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) { | 133 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) { |
| 142 windows_.erase(child); | 134 windows_.erase(child); |
| 143 child->RemoveObserver(this); | 135 child->RemoveObserver(this); |
| 144 wm::GetWindowState(child)->RemoveObserver(this); | 136 wm::GetWindowState(child)->RemoveObserver(this); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 168 } | 160 } |
| 169 UpdateShelfVisibility(); | 161 UpdateShelfVisibility(); |
| 170 } | 162 } |
| 171 | 163 |
| 172 void WorkspaceLayoutManager::SetChildBounds( | 164 void WorkspaceLayoutManager::SetChildBounds( |
| 173 Window* child, | 165 Window* child, |
| 174 const gfx::Rect& requested_bounds) { | 166 const gfx::Rect& requested_bounds) { |
| 175 wm::WindowState* window_state = wm::GetWindowState(child); | 167 wm::WindowState* window_state = wm::GetWindowState(child); |
| 176 if (window_state->is_dragged()) { | 168 if (window_state->is_dragged()) { |
| 177 SetChildBoundsDirect(child, requested_bounds); | 169 SetChildBoundsDirect(child, requested_bounds); |
| 170 } else if (window_state->IsSnapped()) { | |
|
pkotwicz
2014/02/13 00:32:39
This allows a snapped window to be as wide as it w
oshima
2014/02/13 01:10:13
Fixed. I think the same thing can happen during dr
| |
| 171 gfx::Rect child_bounds(requested_bounds); | |
| 172 AdjustSnappedBounds(window_state, &child_bounds); | |
| 173 SetChildBoundsDirect(child, child_bounds); | |
| 178 } else if (!SetMaximizedOrFullscreenBounds(window_state)) { | 174 } else if (!SetMaximizedOrFullscreenBounds(window_state)) { |
| 179 // Some windows rely on this to set their initial bounds. | 175 // Some windows rely on this to set their initial bounds. |
| 180 // Non-maximized/full-screen windows have their size constrained to the | 176 // Non-maximized/full-screen windows have their size constrained to the |
| 181 // work-area. | 177 // work-area. |
| 182 gfx::Rect child_bounds(requested_bounds); | 178 gfx::Rect child_bounds(requested_bounds); |
| 183 child_bounds.set_width(std::min(work_area_in_parent_.width(), | 179 child_bounds.set_width(std::min(work_area_in_parent_.width(), |
| 184 child_bounds.width())); | 180 child_bounds.width())); |
| 185 child_bounds.set_height(std::min(work_area_in_parent_.height(), | 181 child_bounds.set_height(std::min(work_area_in_parent_.height(), |
| 186 child_bounds.height())); | 182 child_bounds.height())); |
| 187 AdjustSnappedBounds(window_state, &child_bounds); | |
| 188 SetChildBoundsDirect(child, child_bounds); | 183 SetChildBoundsDirect(child, child_bounds); |
| 189 } | 184 } |
| 190 UpdateShelfVisibility(); | 185 UpdateShelfVisibility(); |
| 191 } | 186 } |
| 192 | 187 |
| 193 ////////////////////////////////////////////////////////////////////////////// | 188 ////////////////////////////////////////////////////////////////////////////// |
| 194 // WorkspaceLayoutManager, ash::ShellObserver implementation: | 189 // WorkspaceLayoutManager, ash::ShellObserver implementation: |
| 195 | 190 |
| 196 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { | 191 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { |
| 197 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( | 192 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); | 528 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); |
| 534 slide_settings.SetPreemptionStrategy( | 529 slide_settings.SetPreemptionStrategy( |
| 535 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 530 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 536 slide_settings.SetTransitionDuration( | 531 slide_settings.SetTransitionDuration( |
| 537 base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); | 532 base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); |
| 538 SetChildBoundsDirect(child, bounds); | 533 SetChildBoundsDirect(child, bounds); |
| 539 } | 534 } |
| 540 | 535 |
| 541 } // namespace internal | 536 } // namespace internal |
| 542 } // namespace ash | 537 } // namespace ash |
| OLD | NEW |