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); |
pkotwicz
2014/02/13 02:26:16
Nit: You did not need to make |window_state| its o
oshima
2014/02/13 14:08:58
It's actually used in two places, so I'll leave it
| |
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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); | 523 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); |
534 slide_settings.SetPreemptionStrategy( | 524 slide_settings.SetPreemptionStrategy( |
535 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 525 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
536 slide_settings.SetTransitionDuration( | 526 slide_settings.SetTransitionDuration( |
537 base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); | 527 base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); |
538 SetChildBoundsDirect(child, bounds); | 528 SetChildBoundsDirect(child, bounds); |
539 } | 529 } |
540 | 530 |
541 } // namespace internal | 531 } // namespace internal |
542 } // namespace ash | 532 } // namespace ash |
OLD | NEW |