| 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" |
| 11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/wm/always_on_top_controller.h" | 13 #include "ash/wm/always_on_top_controller.h" |
| 14 #include "ash/wm/window_animations.h" | 14 #include "ash/wm/window_animations.h" |
| 15 #include "ash/wm/window_positioner.h" | 15 #include "ash/wm/window_positioner.h" |
| 16 #include "ash/wm/window_properties.h" | 16 #include "ash/wm/window_properties.h" |
| 17 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
| 18 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
| 19 #include "ash/wm/workspace/workspace_window_resizer.h" | |
| 20 #include "ui/aura/client/activation_client.h" | 19 #include "ui/aura/client/activation_client.h" |
| 21 #include "ui/aura/client/aura_constants.h" | 20 #include "ui/aura/client/aura_constants.h" |
| 22 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_observer.h" | 22 #include "ui/aura/window_observer.h" |
| 24 #include "ui/base/ui_base_types.h" | 23 #include "ui/base/ui_base_types.h" |
| 25 #include "ui/compositor/layer.h" | 24 #include "ui/compositor/layer.h" |
| 26 #include "ui/compositor/scoped_layer_animation_settings.h" | |
| 27 #include "ui/events/event.h" | 25 #include "ui/events/event.h" |
| 28 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
| 29 #include "ui/views/corewm/window_util.h" | 27 #include "ui/views/corewm/window_util.h" |
| 30 | 28 |
| 31 using aura::Window; | 29 using aura::Window; |
| 32 | 30 |
| 33 namespace ash { | 31 namespace ash { |
| 34 | 32 |
| 35 namespace internal { | 33 namespace internal { |
| 36 | 34 |
| 37 namespace { | 35 namespace { |
| 38 | 36 |
| 39 // This specifies how much percent 30% of a window rect (width / height) | 37 // This specifies how much percent 30% of a window rect (width / height) |
| 40 // must be visible when the window is added to the workspace. | 38 // must be visible when the window is added to the workspace. |
| 41 const float kMinimumPercentOnScreenArea = 0.3f; | 39 const float kMinimumPercentOnScreenArea = 0.3f; |
| 42 | 40 |
| 43 void MoveToDisplayForRestore(wm::WindowState* window_state) { | |
| 44 if (!window_state->HasRestoreBounds()) | |
| 45 return; | |
| 46 const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen(); | |
| 47 | |
| 48 // Move only if the restore bounds is outside of | |
| 49 // the display. There is no information about in which | |
| 50 // display it should be restored, so this is best guess. | |
| 51 // TODO(oshima): Restore information should contain the | |
| 52 // work area information like WindowResizer does for the | |
| 53 // last window location. | |
| 54 gfx::Rect display_area = Shell::GetScreen()->GetDisplayNearestWindow( | |
| 55 window_state->window()).bounds(); | |
| 56 | |
| 57 if (!display_area.Intersects(restore_bounds)) { | |
| 58 const gfx::Display& display = | |
| 59 Shell::GetScreen()->GetDisplayMatching(restore_bounds); | |
| 60 DisplayController* display_controller = | |
| 61 Shell::GetInstance()->display_controller(); | |
| 62 aura::Window* new_root = | |
| 63 display_controller->GetRootWindowForDisplayId(display.id()); | |
| 64 if (new_root != window_state->window()->GetRootWindow()) { | |
| 65 aura::Window* new_container = | |
| 66 Shell::GetContainer(new_root, window_state->window()->parent()->id()); | |
| 67 new_container->AddChild(window_state->window()); | |
| 68 } | |
| 69 } | |
| 70 } | |
| 71 | |
| 72 gfx::Rect BoundsWithScreenEdgeVisible( | |
| 73 aura::Window* window, | |
| 74 const gfx::Rect& restore_bounds) { | |
| 75 gfx::Rect max_bounds = | |
| 76 ash::ScreenUtil::GetMaximizedWindowBoundsInParent(window); | |
| 77 // If the restore_bounds are more than 1 grid step away from the size the | |
| 78 // window would be when maximized, inset it. | |
| 79 max_bounds.Inset(ash::internal::WorkspaceWindowResizer::kScreenEdgeInset, | |
| 80 ash::internal::WorkspaceWindowResizer::kScreenEdgeInset); | |
| 81 if (restore_bounds.Contains(max_bounds)) | |
| 82 return max_bounds; | |
| 83 return restore_bounds; | |
| 84 } | |
| 85 | |
| 86 } // namespace | 41 } // namespace |
| 87 | 42 |
| 88 WorkspaceLayoutManager::WorkspaceLayoutManager(aura::Window* window) | 43 WorkspaceLayoutManager::WorkspaceLayoutManager(aura::Window* window) |
| 89 : shelf_(NULL), | 44 : shelf_(NULL), |
| 90 window_(window), | 45 window_(window), |
| 91 root_window_(window->GetRootWindow()), | 46 root_window_(window->GetRootWindow()), |
| 92 work_area_in_parent_(ScreenUtil::ConvertRectFromScreen( | 47 work_area_in_parent_(ScreenUtil::ConvertRectFromScreen( |
| 93 window_, | 48 window_, |
| 94 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area())), | 49 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area())), |
| 95 is_fullscreen_(GetRootWindowController( | 50 is_fullscreen_(GetRootWindowController( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 SetChildBoundsDirect(child, requested_bounds); | 132 SetChildBoundsDirect(child, requested_bounds); |
| 178 } else if (!SetMaximizedOrFullscreenBounds(window_state)) { | 133 } else if (!SetMaximizedOrFullscreenBounds(window_state)) { |
| 179 // Some windows rely on this to set their initial bounds. | 134 // Some windows rely on this to set their initial bounds. |
| 180 // Non-maximized/full-screen windows have their size constrained to the | 135 // Non-maximized/full-screen windows have their size constrained to the |
| 181 // work-area. | 136 // work-area. |
| 182 gfx::Rect child_bounds(requested_bounds); | 137 gfx::Rect child_bounds(requested_bounds); |
| 183 child_bounds.set_width(std::min(work_area_in_parent_.width(), | 138 child_bounds.set_width(std::min(work_area_in_parent_.width(), |
| 184 child_bounds.width())); | 139 child_bounds.width())); |
| 185 child_bounds.set_height(std::min(work_area_in_parent_.height(), | 140 child_bounds.set_height(std::min(work_area_in_parent_.height(), |
| 186 child_bounds.height())); | 141 child_bounds.height())); |
| 187 AdjustSnappedBounds(window_state, &child_bounds); | 142 window_state->AdjustSnappedBounds(&child_bounds); |
| 188 SetChildBoundsDirect(child, child_bounds); | 143 SetChildBoundsDirect(child, child_bounds); |
| 189 } | 144 } |
| 190 UpdateShelfVisibility(); | 145 UpdateShelfVisibility(); |
| 191 } | 146 } |
| 192 | 147 |
| 193 ////////////////////////////////////////////////////////////////////////////// | 148 ////////////////////////////////////////////////////////////////////////////// |
| 194 // WorkspaceLayoutManager, ash::ShellObserver implementation: | 149 // WorkspaceLayoutManager, ash::ShellObserver implementation: |
| 195 | 150 |
| 196 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { | 151 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { |
| 197 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( | 152 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if (window_state && window_state->IsMinimized() && | 200 if (window_state && window_state->IsMinimized() && |
| 246 !gained_active->IsVisible()) { | 201 !gained_active->IsVisible()) { |
| 247 window_state->Unminimize(); | 202 window_state->Unminimize(); |
| 248 DCHECK(!window_state->IsMinimized()); | 203 DCHECK(!window_state->IsMinimized()); |
| 249 } | 204 } |
| 250 } | 205 } |
| 251 | 206 |
| 252 ////////////////////////////////////////////////////////////////////////////// | 207 ////////////////////////////////////////////////////////////////////////////// |
| 253 // WorkspaceLayoutManager, wm::WindowStateObserver implementation: | 208 // WorkspaceLayoutManager, wm::WindowStateObserver implementation: |
| 254 | 209 |
| 255 void WorkspaceLayoutManager::OnWindowShowTypeChanged( | 210 void WorkspaceLayoutManager::OnPostWindowShowTypeChange( |
| 256 wm::WindowState* window_state, | 211 wm::WindowState* window_state, |
| 257 wm::WindowShowType old_type) { | 212 wm::WindowShowType old_type) { |
| 258 if (old_type != wm::SHOW_TYPE_MINIMIZED && | |
| 259 !window_state->HasRestoreBounds() && | |
| 260 window_state->IsMaximizedOrFullscreen() && | |
| 261 !wm::IsMaximizedOrFullscreenWindowShowType(old_type)) { | |
| 262 window_state->SaveCurrentBoundsForRestore(); | |
| 263 } | |
| 264 // When restoring from a minimized state, we want to restore to the previous | |
| 265 // bounds. However, we want to maintain the restore bounds. (The restore | |
| 266 // bounds are set if a user maximized the window in one axis by double | |
| 267 // clicking the window border for example). | |
| 268 gfx::Rect restore; | |
| 269 if (old_type == wm::SHOW_TYPE_MINIMIZED && | |
| 270 window_state->IsNormalShowState() && | |
| 271 window_state->HasRestoreBounds() && | |
| 272 !window_state->unminimize_to_restore_bounds()) { | |
| 273 restore = window_state->GetRestoreBoundsInScreen(); | |
| 274 window_state->SaveCurrentBoundsForRestore(); | |
| 275 } | |
| 276 | |
| 277 UpdateBoundsFromShowType(window_state, old_type); | |
| 278 ShowTypeChanged(window_state, old_type); | |
| 279 | |
| 280 if (window_state->IsNormalShowState()) | |
| 281 window_state->ClearRestoreBounds(); | |
| 282 | |
| 283 // Set the restore rectangle to the previously set restore rectangle. | |
| 284 if (!restore.IsEmpty()) | |
| 285 window_state->SetRestoreBoundsInScreen(restore); | |
| 286 | 213 |
| 287 // Notify observers that fullscreen state may be changing. | 214 // Notify observers that fullscreen state may be changing. |
| 288 if (window_state->IsFullscreen() || old_type == wm::SHOW_TYPE_FULLSCREEN) | 215 if (window_state->IsFullscreen() || old_type == wm::SHOW_TYPE_FULLSCREEN) |
| 289 UpdateFullscreenState(); | 216 UpdateFullscreenState(); |
| 290 | 217 |
| 291 UpdateShelfVisibility(); | 218 UpdateShelfVisibility(); |
| 292 } | 219 } |
| 293 | 220 |
| 294 void WorkspaceLayoutManager::ShowTypeChanged( | |
| 295 wm::WindowState* window_state, | |
| 296 wm::WindowShowType last_show_type) { | |
| 297 if (window_state->IsMinimized()) { | |
| 298 if (last_show_type == wm::SHOW_TYPE_MINIMIZED) | |
| 299 return; | |
| 300 | |
| 301 // Save the previous show state so that we can correctly restore it. | |
| 302 window_state->window()->SetProperty(aura::client::kRestoreShowStateKey, | |
| 303 wm::ToWindowShowState(last_show_type)); | |
| 304 views::corewm::SetWindowVisibilityAnimationType( | |
| 305 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); | |
| 306 | |
| 307 // Hide the window. | |
| 308 window_state->window()->Hide(); | |
| 309 // Activate another window. | |
| 310 if (window_state->IsActive()) | |
| 311 window_state->Deactivate(); | |
| 312 } else if ((window_state->window()->TargetVisibility() || | |
| 313 last_show_type == wm::SHOW_TYPE_MINIMIZED) && | |
| 314 !window_state->window()->layer()->visible()) { | |
| 315 // The layer may be hidden if the window was previously minimized. Make | |
| 316 // sure it's visible. | |
| 317 window_state->window()->Show(); | |
| 318 if (last_show_type == wm::SHOW_TYPE_MINIMIZED && | |
| 319 !window_state->IsMaximizedOrFullscreen()) { | |
| 320 window_state->set_unminimize_to_restore_bounds(false); | |
| 321 } | |
| 322 } | |
| 323 } | |
| 324 | |
| 325 ////////////////////////////////////////////////////////////////////////////// | 221 ////////////////////////////////////////////////////////////////////////////// |
| 326 // WorkspaceLayoutManager, private: | 222 // WorkspaceLayoutManager, private: |
| 327 | 223 |
| 328 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( | 224 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( |
| 329 AdjustWindowReason reason) { | 225 AdjustWindowReason reason) { |
| 330 work_area_in_parent_ = ScreenUtil::ConvertRectFromScreen( | 226 work_area_in_parent_ = ScreenUtil::ConvertRectFromScreen( |
| 331 window_, | 227 window_, |
| 332 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area()); | 228 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area()); |
| 333 | 229 |
| 334 // Don't do any adjustments of the insets while we are in screen locked mode. | 230 // Don't do any adjustments of the insets while we are in screen locked mode. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 case ADJUST_WINDOW_DISPLAY_SIZE_CHANGED: | 272 case ADJUST_WINDOW_DISPLAY_SIZE_CHANGED: |
| 377 // The work area may be smaller than the full screen. Put as much of the | 273 // The work area may be smaller than the full screen. Put as much of the |
| 378 // window as possible within the display area. | 274 // window as possible within the display area. |
| 379 bounds.AdjustToFit(work_area_in_parent_); | 275 bounds.AdjustToFit(work_area_in_parent_); |
| 380 break; | 276 break; |
| 381 case ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED: | 277 case ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED: |
| 382 ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility( | 278 ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility( |
| 383 work_area_in_parent_, &bounds); | 279 work_area_in_parent_, &bounds); |
| 384 break; | 280 break; |
| 385 } | 281 } |
| 386 AdjustSnappedBounds(window_state, &bounds); | 282 window_state->AdjustSnappedBounds(&bounds); |
| 387 if (window_state->window()->bounds() != bounds) | 283 if (window_state->window()->bounds() != bounds) |
| 388 SetChildBoundsAnimated(window_state->window(), bounds); | 284 window_state->SetBoundsDirectAnimated(bounds); |
| 389 } | 285 } |
| 390 | 286 |
| 391 void WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded( | 287 void WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded( |
| 392 wm::WindowState* window_state) { | 288 wm::WindowState* window_state) { |
| 393 // Don't adjust window bounds if the bounds are empty as this | 289 // Don't adjust window bounds if the bounds are empty as this |
| 394 // happens when a new views::Widget is created. | 290 // happens when a new views::Widget is created. |
| 395 // When a window is dragged and dropped onto a different | 291 // When a window is dragged and dropped onto a different |
| 396 // root window, the bounds will be updated after they are added | 292 // root window, the bounds will be updated after they are added |
| 397 // to the root window. | 293 // to the root window. |
| 398 if (window_state->window()->bounds().IsEmpty() || | 294 if (window_state->window()->bounds().IsEmpty() || |
| 399 window_state->is_dragged() || | 295 window_state->is_dragged() || |
| 400 SetMaximizedOrFullscreenBounds(window_state)) { | 296 SetMaximizedOrFullscreenBounds(window_state)) { |
| 401 return; | 297 return; |
| 402 } | 298 } |
| 403 | 299 |
| 404 Window* window = window_state->window(); | 300 Window* window = window_state->window(); |
| 405 gfx::Rect bounds = window->bounds(); | 301 gfx::Rect bounds = window->bounds(); |
| 406 | 302 |
| 407 // Use entire display instead of workarea because the workarea can | 303 // Use entire display instead of workarea because the workarea can |
| 408 // be further shrunk by the docked area. The logic ensures 30% | 304 // be further shrunk by the docked area. The logic ensures 30% |
| 409 // visibility which should be enough to see where the window gets | 305 // visibility which should be enough to see where the window gets |
| 410 // moved. | 306 // moved. |
| 411 gfx::Rect display_area = ScreenUtil::GetDisplayBoundsInParent(window); | 307 gfx::Rect display_area = ScreenUtil::GetDisplayBoundsInParent(window); |
| 412 | 308 |
| 413 int min_width = bounds.width() * kMinimumPercentOnScreenArea; | 309 int min_width = bounds.width() * kMinimumPercentOnScreenArea; |
| 414 int min_height = bounds.height() * kMinimumPercentOnScreenArea; | 310 int min_height = bounds.height() * kMinimumPercentOnScreenArea; |
| 415 ash::wm::AdjustBoundsToEnsureWindowVisibility( | 311 ash::wm::AdjustBoundsToEnsureWindowVisibility( |
| 416 display_area, min_width, min_height, &bounds); | 312 display_area, min_width, min_height, &bounds); |
| 417 AdjustSnappedBounds(window_state, &bounds); | 313 window_state->AdjustSnappedBounds(&bounds); |
| 418 if (window->bounds() != bounds) | 314 if (window->bounds() != bounds) |
| 419 window->SetBounds(bounds); | 315 window->SetBounds(bounds); |
| 420 } | 316 } |
| 421 | 317 |
| 422 void WorkspaceLayoutManager::UpdateShelfVisibility() { | 318 void WorkspaceLayoutManager::UpdateShelfVisibility() { |
| 423 if (shelf_) | 319 if (shelf_) |
| 424 shelf_->UpdateVisibilityState(); | 320 shelf_->UpdateVisibilityState(); |
| 425 } | 321 } |
| 426 | 322 |
| 427 void WorkspaceLayoutManager::UpdateFullscreenState() { | 323 void WorkspaceLayoutManager::UpdateFullscreenState() { |
| 428 bool is_fullscreen = GetRootWindowController( | 324 bool is_fullscreen = GetRootWindowController( |
| 429 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; | 325 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; |
| 430 if (is_fullscreen != is_fullscreen_) { | 326 if (is_fullscreen != is_fullscreen_) { |
| 431 ash::Shell::GetInstance()->NotifyFullscreenStateChange( | 327 ash::Shell::GetInstance()->NotifyFullscreenStateChange( |
| 432 is_fullscreen, window_->GetRootWindow()); | 328 is_fullscreen, window_->GetRootWindow()); |
| 433 is_fullscreen_ = is_fullscreen; | 329 is_fullscreen_ = is_fullscreen; |
| 434 } | 330 } |
| 435 } | 331 } |
| 436 | 332 |
| 437 void WorkspaceLayoutManager::UpdateBoundsFromShowType( | |
| 438 wm::WindowState* window_state, | |
| 439 wm::WindowShowType old_show_type) { | |
| 440 aura::Window* window = window_state->window(); | |
| 441 if (window_state->IsMaximizedOrFullscreen()) | |
| 442 MoveToDisplayForRestore(window_state); | |
| 443 | |
| 444 wm::WindowShowType show_type = window_state->window_show_type(); | |
| 445 gfx::Rect bounds_in_parent; | |
| 446 switch (show_type) { | |
| 447 case wm::SHOW_TYPE_DEFAULT: | |
| 448 case wm::SHOW_TYPE_NORMAL: | |
| 449 case wm::SHOW_TYPE_LEFT_SNAPPED: | |
| 450 case wm::SHOW_TYPE_RIGHT_SNAPPED: | |
| 451 if (window_state->HasRestoreBounds()) | |
| 452 bounds_in_parent = window_state->GetRestoreBoundsInParent(); | |
| 453 else | |
| 454 bounds_in_parent = window->bounds(); | |
| 455 // Make sure that part of the window is always visible. | |
| 456 wm::AdjustBoundsToEnsureMinimumWindowVisibility( | |
| 457 work_area_in_parent_, &bounds_in_parent); | |
| 458 | |
| 459 if (show_type == wm::SHOW_TYPE_LEFT_SNAPPED || | |
| 460 show_type == wm::SHOW_TYPE_RIGHT_SNAPPED) { | |
| 461 AdjustSnappedBounds(window_state, &bounds_in_parent); | |
| 462 } else { | |
| 463 bounds_in_parent = BoundsWithScreenEdgeVisible( | |
| 464 window, | |
| 465 bounds_in_parent); | |
| 466 } | |
| 467 break; | |
| 468 | |
| 469 case wm::SHOW_TYPE_MAXIMIZED: | |
| 470 bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window); | |
| 471 break; | |
| 472 | |
| 473 case wm::SHOW_TYPE_FULLSCREEN: | |
| 474 bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent(window); | |
| 475 break; | |
| 476 | |
| 477 case wm::SHOW_TYPE_MINIMIZED: | |
| 478 case wm::SHOW_TYPE_INACTIVE: | |
| 479 case wm::SHOW_TYPE_DETACHED: | |
| 480 case wm::SHOW_TYPE_END: | |
| 481 case wm::SHOW_TYPE_AUTO_POSITIONED: | |
| 482 return; | |
| 483 } | |
| 484 | |
| 485 if (old_show_type == wm::SHOW_TYPE_MINIMIZED || | |
| 486 (window_state->IsFullscreen() && | |
| 487 !window_state->animate_to_fullscreen())) { | |
| 488 SetChildBoundsDirect(window, bounds_in_parent); | |
| 489 } else if (window_state->IsMaximizedOrFullscreen() || | |
| 490 IsMaximizedOrFullscreenWindowShowType(old_show_type)) { | |
| 491 CrossFadeToBounds(window, bounds_in_parent); | |
| 492 } else { | |
| 493 SetChildBoundsAnimated(window, bounds_in_parent); | |
| 494 } | |
| 495 } | |
| 496 | |
| 497 bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( | 333 bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( |
| 498 wm::WindowState* window_state) { | 334 wm::WindowState* window_state) { |
| 499 DCHECK(!window_state->is_dragged()); | 335 DCHECK(!window_state->is_dragged()); |
| 500 | 336 |
| 501 if (window_state->IsMaximized()) { | 337 if (window_state->IsMaximized()) { |
| 502 SetChildBoundsDirect( | 338 SetChildBoundsDirect( |
| 503 window_state->window(), ScreenUtil::GetMaximizedWindowBoundsInParent( | 339 window_state->window(), ScreenUtil::GetMaximizedWindowBoundsInParent( |
| 504 window_state->window())); | 340 window_state->window())); |
| 505 return true; | 341 return true; |
| 506 } | 342 } |
| 507 if (window_state->IsFullscreen()) { | 343 if (window_state->IsFullscreen()) { |
| 508 SetChildBoundsDirect( | 344 SetChildBoundsDirect( |
| 509 window_state->window(), | 345 window_state->window(), |
| 510 ScreenUtil::GetDisplayBoundsInParent(window_state->window())); | 346 ScreenUtil::GetDisplayBoundsInParent(window_state->window())); |
| 511 return true; | 347 return true; |
| 512 } | 348 } |
| 513 return false; | 349 return false; |
| 514 } | 350 } |
| 515 | 351 |
| 516 void WorkspaceLayoutManager::AdjustSnappedBounds(wm::WindowState* window_state, | |
| 517 gfx::Rect* bounds) { | |
| 518 if (window_state->is_dragged() || !window_state->IsSnapped()) | |
| 519 return; | |
| 520 gfx::Rect maximized_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent( | |
| 521 window_state->window()); | |
| 522 if (window_state->window_show_type() == wm::SHOW_TYPE_LEFT_SNAPPED) | |
| 523 bounds->set_x(maximized_bounds.x()); | |
| 524 else if (window_state->window_show_type() == wm::SHOW_TYPE_RIGHT_SNAPPED) | |
| 525 bounds->set_x(maximized_bounds.right() - bounds->width()); | |
| 526 bounds->set_y(maximized_bounds.y()); | |
| 527 // TODO(varkha): Set width to 50% here for snapped windows. | |
| 528 bounds->set_height(maximized_bounds.height()); | |
| 529 } | |
| 530 | |
| 531 void WorkspaceLayoutManager::SetChildBoundsAnimated(Window* child, | |
| 532 const gfx::Rect& bounds) { | |
| 533 const int kBoundsChangeSlideDurationMs = 120; | |
| 534 | |
| 535 ui::Layer* layer = child->layer(); | |
| 536 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); | |
| 537 slide_settings.SetPreemptionStrategy( | |
| 538 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 539 slide_settings.SetTransitionDuration( | |
| 540 base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); | |
| 541 SetChildBoundsDirect(child, bounds); | |
| 542 } | |
| 543 | |
| 544 } // namespace internal | 352 } // namespace internal |
| 545 } // namespace ash | 353 } // namespace ash |
| OLD | NEW |