| 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/base_layout_manager.h" | 5 #include "ash/wm/base_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/screen_ash.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/session_state_delegate.h" | 8 #include "ash/session_state_delegate.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/wm/window_animations.h" | 11 #include "ash/wm/window_animations.h" |
| 12 #include "ash/wm/window_properties.h" | 12 #include "ash/wm/window_properties.h" |
| 13 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
| 15 #include "ash/wm/workspace/workspace_window_resizer.h" | 15 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 16 #include "ui/aura/client/activation_client.h" | 16 #include "ui/aura/client/activation_client.h" |
| 17 #include "ui/aura/client/aura_constants.h" | 17 #include "ui/aura/client/aura_constants.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 42 (*i)->RemoveObserver(this); | 42 (*i)->RemoveObserver(this); |
| 43 Shell::GetInstance()->RemoveShellObserver(this); | 43 Shell::GetInstance()->RemoveShellObserver(this); |
| 44 Shell::GetInstance()->activation_client()->RemoveObserver(this); | 44 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // static | 47 // static |
| 48 gfx::Rect BaseLayoutManager::BoundsWithScreenEdgeVisible( | 48 gfx::Rect BaseLayoutManager::BoundsWithScreenEdgeVisible( |
| 49 aura::Window* window, | 49 aura::Window* window, |
| 50 const gfx::Rect& restore_bounds) { | 50 const gfx::Rect& restore_bounds) { |
| 51 gfx::Rect max_bounds = | 51 gfx::Rect max_bounds = |
| 52 ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window); | 52 ash::ScreenUtil::GetMaximizedWindowBoundsInParent(window); |
| 53 // If the restore_bounds are more than 1 grid step away from the size the | 53 // If the restore_bounds are more than 1 grid step away from the size the |
| 54 // window would be when maximized, inset it. | 54 // window would be when maximized, inset it. |
| 55 max_bounds.Inset(ash::internal::WorkspaceWindowResizer::kScreenEdgeInset, | 55 max_bounds.Inset(ash::internal::WorkspaceWindowResizer::kScreenEdgeInset, |
| 56 ash::internal::WorkspaceWindowResizer::kScreenEdgeInset); | 56 ash::internal::WorkspaceWindowResizer::kScreenEdgeInset); |
| 57 if (restore_bounds.Contains(max_bounds)) | 57 if (restore_bounds.Contains(max_bounds)) |
| 58 return max_bounds; | 58 return max_bounds; |
| 59 return restore_bounds; | 59 return restore_bounds; |
| 60 } | 60 } |
| 61 | 61 |
| 62 ///////////////////////////////////////////////////////////////////////////// | 62 ///////////////////////////////////////////////////////////////////////////// |
| (...skipping 30 matching lines...) Expand all Loading... |
| 93 if (visible && window_state->IsMinimized()) | 93 if (visible && window_state->IsMinimized()) |
| 94 window_state->Unminimize(); | 94 window_state->Unminimize(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void BaseLayoutManager::SetChildBounds(aura::Window* child, | 97 void BaseLayoutManager::SetChildBounds(aura::Window* child, |
| 98 const gfx::Rect& requested_bounds) { | 98 const gfx::Rect& requested_bounds) { |
| 99 gfx::Rect child_bounds(requested_bounds); | 99 gfx::Rect child_bounds(requested_bounds); |
| 100 wm::WindowState* window_state = wm::GetWindowState(child); | 100 wm::WindowState* window_state = wm::GetWindowState(child); |
| 101 // Some windows rely on this to set their initial bounds. | 101 // Some windows rely on this to set their initial bounds. |
| 102 if (window_state->IsMaximized()) | 102 if (window_state->IsMaximized()) |
| 103 child_bounds = ScreenAsh::GetMaximizedWindowBoundsInParent(child); | 103 child_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent(child); |
| 104 else if (window_state->IsFullscreen()) | 104 else if (window_state->IsFullscreen()) |
| 105 child_bounds = ScreenAsh::GetDisplayBoundsInParent(child); | 105 child_bounds = ScreenUtil::GetDisplayBoundsInParent(child); |
| 106 SetChildBoundsDirect(child, child_bounds); | 106 SetChildBoundsDirect(child, child_bounds); |
| 107 } | 107 } |
| 108 | 108 |
| 109 ///////////////////////////////////////////////////////////////////////////// | 109 ///////////////////////////////////////////////////////////////////////////// |
| 110 // BaseLayoutManager, aura::WindowObserver overrides: | 110 // BaseLayoutManager, aura::WindowObserver overrides: |
| 111 | 111 |
| 112 void BaseLayoutManager::OnWindowDestroying(aura::Window* window) { | 112 void BaseLayoutManager::OnWindowDestroying(aura::Window* window) { |
| 113 if (root_window_ == window) { | 113 if (root_window_ == window) { |
| 114 root_window_->RemoveObserver(this); | 114 root_window_->RemoveObserver(this); |
| 115 root_window_ = NULL; | 115 root_window_ = NULL; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 AdjustWindowBoundsForWorkAreaChange(wm::GetWindowState(*it), reason); | 214 AdjustWindowBoundsForWorkAreaChange(wm::GetWindowState(*it), reason); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 void BaseLayoutManager::AdjustWindowBoundsForWorkAreaChange( | 218 void BaseLayoutManager::AdjustWindowBoundsForWorkAreaChange( |
| 219 wm::WindowState* window_state, | 219 wm::WindowState* window_state, |
| 220 AdjustWindowReason reason) { | 220 AdjustWindowReason reason) { |
| 221 aura::Window* window = window_state->window(); | 221 aura::Window* window = window_state->window(); |
| 222 if (window_state->IsMaximized()) { | 222 if (window_state->IsMaximized()) { |
| 223 SetChildBoundsDirect( | 223 SetChildBoundsDirect( |
| 224 window, ScreenAsh::GetMaximizedWindowBoundsInParent(window)); | 224 window, ScreenUtil::GetMaximizedWindowBoundsInParent(window)); |
| 225 } else if (window_state->IsFullscreen()) { | 225 } else if (window_state->IsFullscreen()) { |
| 226 SetChildBoundsDirect( | 226 SetChildBoundsDirect( |
| 227 window, ScreenAsh::GetDisplayBoundsInParent(window)); | 227 window, ScreenUtil::GetDisplayBoundsInParent(window)); |
| 228 } else { | 228 } else { |
| 229 // The work area may be smaller than the full screen. | 229 // The work area may be smaller than the full screen. |
| 230 gfx::Rect display_rect = | 230 gfx::Rect display_rect = |
| 231 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window); | 231 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); |
| 232 // Put as much of the window as possible within the display area. | 232 // Put as much of the window as possible within the display area. |
| 233 gfx::Rect bounds = window->bounds(); | 233 gfx::Rect bounds = window->bounds(); |
| 234 bounds.AdjustToFit(display_rect); | 234 bounds.AdjustToFit(display_rect); |
| 235 window->SetBounds(bounds); | 235 window->SetBounds(bounds); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 | 238 |
| 239 ////////////////////////////////////////////////////////////////////////////// | 239 ////////////////////////////////////////////////////////////////////////////// |
| 240 // BaseLayoutManager, private: | 240 // BaseLayoutManager, private: |
| 241 | 241 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 256 | 256 |
| 257 case wm::SHOW_TYPE_LEFT_SNAPPED: | 257 case wm::SHOW_TYPE_LEFT_SNAPPED: |
| 258 case wm::SHOW_TYPE_RIGHT_SNAPPED: | 258 case wm::SHOW_TYPE_RIGHT_SNAPPED: |
| 259 if (window_state->HasRestoreBounds()) | 259 if (window_state->HasRestoreBounds()) |
| 260 SetChildBoundsDirect(window, window_state->GetRestoreBoundsInParent()); | 260 SetChildBoundsDirect(window, window_state->GetRestoreBoundsInParent()); |
| 261 window_state->ClearRestoreBounds(); | 261 window_state->ClearRestoreBounds(); |
| 262 break; | 262 break; |
| 263 | 263 |
| 264 case wm::SHOW_TYPE_MAXIMIZED: | 264 case wm::SHOW_TYPE_MAXIMIZED: |
| 265 SetChildBoundsDirect( | 265 SetChildBoundsDirect( |
| 266 window, ScreenAsh::GetMaximizedWindowBoundsInParent(window)); | 266 window, ScreenUtil::GetMaximizedWindowBoundsInParent(window)); |
| 267 break; | 267 break; |
| 268 | 268 |
| 269 case wm::SHOW_TYPE_FULLSCREEN: | 269 case wm::SHOW_TYPE_FULLSCREEN: |
| 270 // Don't animate the full-screen window transition. | 270 // Don't animate the full-screen window transition. |
| 271 // TODO(jamescook): Use animation here. Be sure the lock screen works. | 271 // TODO(jamescook): Use animation here. Be sure the lock screen works. |
| 272 SetChildBoundsDirect(window, | 272 SetChildBoundsDirect(window, |
| 273 ScreenAsh::GetDisplayBoundsInParent(window)); | 273 ScreenUtil::GetDisplayBoundsInParent(window)); |
| 274 break; | 274 break; |
| 275 | 275 |
| 276 case wm::SHOW_TYPE_MINIMIZED: | 276 case wm::SHOW_TYPE_MINIMIZED: |
| 277 case wm::SHOW_TYPE_INACTIVE: | 277 case wm::SHOW_TYPE_INACTIVE: |
| 278 case wm::SHOW_TYPE_DETACHED: | 278 case wm::SHOW_TYPE_DETACHED: |
| 279 case wm::SHOW_TYPE_END: | 279 case wm::SHOW_TYPE_END: |
| 280 case wm::SHOW_TYPE_AUTO_POSITIONED: | 280 case wm::SHOW_TYPE_AUTO_POSITIONED: |
| 281 break; | 281 break; |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace internal | 285 } // namespace internal |
| 286 } // namespace ash | 286 } // namespace ash |
| OLD | NEW |