Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/default_state.h" | 5 #include "ash/wm/default_state.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
| 24 | 24 |
| 25 namespace ash { | 25 namespace ash { |
| 26 namespace wm { | 26 namespace wm { |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // This specifies how much percent (30%) of a window rect | 29 // This specifies how much percent (30%) of a window rect |
| 30 // must be visible when the window is added to the workspace. | 30 // must be visible when the window is added to the workspace. |
| 31 const float kMinimumPercentOnScreenArea = 0.3f; | 31 const float kMinimumPercentOnScreenArea = 0.3f; |
| 32 | 32 |
| 33 bool IsPanel(aura::Window* window) { | 33 bool IsMinimizedWindowState(const WindowStateType state_type) { |
| 34 return window->parent() && | 34 return (state_type == WINDOW_STATE_TYPE_MINIMIZED || |
| 35 window->parent()->id() == kShellWindowId_PanelContainer; | 35 state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED); |
|
varkha
2014/10/02 22:03:12
nit: drop brackets and align with state_type above
dtapuska
2014/10/03 15:45:17
clang requires brackets for a function body; but i
varkha
2014/10/03 16:14:05
+4 indent would probably be technically correct as
| |
| 36 } | 36 } |
| 37 | 37 |
| 38 void MoveToDisplayForRestore(WindowState* window_state) { | 38 void MoveToDisplayForRestore(WindowState* window_state) { |
| 39 if (!window_state->HasRestoreBounds()) | 39 if (!window_state->HasRestoreBounds()) |
| 40 return; | 40 return; |
| 41 const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen(); | 41 const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen(); |
| 42 | 42 |
| 43 // Move only if the restore bounds is outside of | 43 // Move only if the restore bounds is outside of |
| 44 // the display. There is no information about in which | 44 // the display. There is no information about in which |
| 45 // display it should be restored, so this is best guess. | 45 // display it should be restored, so this is best guess. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 71 DefaultState::~DefaultState() {} | 71 DefaultState::~DefaultState() {} |
| 72 | 72 |
| 73 void DefaultState::OnWMEvent(WindowState* window_state, | 73 void DefaultState::OnWMEvent(WindowState* window_state, |
| 74 const WMEvent* event) { | 74 const WMEvent* event) { |
| 75 if (ProcessWorkspaceEvents(window_state, event)) | 75 if (ProcessWorkspaceEvents(window_state, event)) |
| 76 return; | 76 return; |
| 77 | 77 |
| 78 if (ProcessCompoundEvents(window_state, event)) | 78 if (ProcessCompoundEvents(window_state, event)) |
| 79 return; | 79 return; |
| 80 | 80 |
| 81 WindowStateType current_state_type = window_state->GetStateType(); | |
| 81 WindowStateType next_state_type = WINDOW_STATE_TYPE_NORMAL; | 82 WindowStateType next_state_type = WINDOW_STATE_TYPE_NORMAL; |
| 82 switch (event->type()) { | 83 switch (event->type()) { |
| 83 case WM_EVENT_NORMAL: | 84 case WM_EVENT_NORMAL: |
| 84 next_state_type = WINDOW_STATE_TYPE_NORMAL; | 85 next_state_type = |
| 86 current_state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED ? | |
| 87 WINDOW_STATE_TYPE_DOCKED : WINDOW_STATE_TYPE_NORMAL; | |
| 85 break; | 88 break; |
| 86 case WM_EVENT_MAXIMIZE: | 89 case WM_EVENT_MAXIMIZE: |
| 87 next_state_type = WINDOW_STATE_TYPE_MAXIMIZED; | 90 next_state_type = WINDOW_STATE_TYPE_MAXIMIZED; |
| 88 break; | 91 break; |
| 89 case WM_EVENT_MINIMIZE: | 92 case WM_EVENT_MINIMIZE: |
| 90 next_state_type = WINDOW_STATE_TYPE_MINIMIZED; | 93 next_state_type = |
| 94 current_state_type == WINDOW_STATE_TYPE_DOCKED ? | |
| 95 WINDOW_STATE_TYPE_DOCKED_MINIMIZED : WINDOW_STATE_TYPE_MINIMIZED; | |
| 91 break; | 96 break; |
| 92 case WM_EVENT_FULLSCREEN: | 97 case WM_EVENT_FULLSCREEN: |
| 93 next_state_type = WINDOW_STATE_TYPE_FULLSCREEN; | 98 next_state_type = WINDOW_STATE_TYPE_FULLSCREEN; |
| 94 break; | 99 break; |
| 95 case WM_EVENT_SNAP_LEFT: | 100 case WM_EVENT_SNAP_LEFT: |
| 96 next_state_type = WINDOW_STATE_TYPE_LEFT_SNAPPED; | 101 next_state_type = WINDOW_STATE_TYPE_LEFT_SNAPPED; |
| 97 break; | 102 break; |
| 98 case WM_EVENT_SNAP_RIGHT: | 103 case WM_EVENT_SNAP_RIGHT: |
| 99 next_state_type = WINDOW_STATE_TYPE_RIGHT_SNAPPED; | 104 next_state_type = WINDOW_STATE_TYPE_RIGHT_SNAPPED; |
| 100 break; | 105 break; |
| 106 case WM_EVENT_DOCK: | |
| 107 next_state_type = WINDOW_STATE_TYPE_DOCKED; | |
| 108 break; | |
| 101 case WM_EVENT_SET_BOUNDS: | 109 case WM_EVENT_SET_BOUNDS: |
| 102 SetBounds(window_state, static_cast<const SetBoundsEvent*>(event)); | 110 SetBounds(window_state, static_cast<const SetBoundsEvent*>(event)); |
| 103 return; | 111 return; |
| 104 case WM_EVENT_SHOW_INACTIVE: | 112 case WM_EVENT_SHOW_INACTIVE: |
| 105 next_state_type = WINDOW_STATE_TYPE_INACTIVE; | 113 next_state_type = WINDOW_STATE_TYPE_INACTIVE; |
| 106 break; | 114 break; |
| 107 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: | 115 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: |
| 108 case WM_EVENT_TOGGLE_MAXIMIZE: | 116 case WM_EVENT_TOGGLE_MAXIMIZE: |
| 109 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: | 117 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: |
| 110 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: | 118 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: |
| 111 case WM_EVENT_TOGGLE_FULLSCREEN: | 119 case WM_EVENT_TOGGLE_FULLSCREEN: |
| 112 case WM_EVENT_CENTER: | 120 case WM_EVENT_CENTER: |
| 113 NOTREACHED() << "Compound event should not reach here:" << event; | 121 NOTREACHED() << "Compound event should not reach here:" << event; |
| 114 return; | 122 return; |
| 115 case WM_EVENT_ADDED_TO_WORKSPACE: | 123 case WM_EVENT_ADDED_TO_WORKSPACE: |
| 116 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: | 124 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: |
| 117 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: | 125 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: |
| 118 NOTREACHED() << "Workspace event should not reach here:" << event; | 126 NOTREACHED() << "Workspace event should not reach here:" << event; |
| 119 return; | 127 return; |
| 120 } | 128 } |
| 121 | 129 |
| 122 WindowStateType current = window_state->GetStateType(); | 130 if (next_state_type == current_state_type && window_state->IsSnapped()) { |
| 123 | |
| 124 if (next_state_type == current && window_state->IsSnapped()) { | |
| 125 gfx::Rect snapped_bounds = event->type() == WM_EVENT_SNAP_LEFT ? | 131 gfx::Rect snapped_bounds = event->type() == WM_EVENT_SNAP_LEFT ? |
| 126 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) : | 132 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) : |
| 127 GetDefaultRightSnappedWindowBoundsInParent(window_state->window()); | 133 GetDefaultRightSnappedWindowBoundsInParent(window_state->window()); |
| 128 window_state->SetBoundsDirectAnimated(snapped_bounds); | 134 window_state->SetBoundsDirectAnimated(snapped_bounds); |
| 129 return; | 135 return; |
| 130 } | 136 } |
| 131 | 137 |
| 132 EnterToNextState(window_state, next_state_type); | 138 EnterToNextState(window_state, next_state_type); |
| 133 } | 139 } |
| 134 | 140 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 CenterWindow(window_state); | 272 CenterWindow(window_state); |
| 267 return true; | 273 return true; |
| 268 case WM_EVENT_NORMAL: | 274 case WM_EVENT_NORMAL: |
| 269 case WM_EVENT_MAXIMIZE: | 275 case WM_EVENT_MAXIMIZE: |
| 270 case WM_EVENT_MINIMIZE: | 276 case WM_EVENT_MINIMIZE: |
| 271 case WM_EVENT_FULLSCREEN: | 277 case WM_EVENT_FULLSCREEN: |
| 272 case WM_EVENT_SNAP_LEFT: | 278 case WM_EVENT_SNAP_LEFT: |
| 273 case WM_EVENT_SNAP_RIGHT: | 279 case WM_EVENT_SNAP_RIGHT: |
| 274 case WM_EVENT_SET_BOUNDS: | 280 case WM_EVENT_SET_BOUNDS: |
| 275 case WM_EVENT_SHOW_INACTIVE: | 281 case WM_EVENT_SHOW_INACTIVE: |
| 282 case WM_EVENT_DOCK: | |
| 276 break; | 283 break; |
| 277 case WM_EVENT_ADDED_TO_WORKSPACE: | 284 case WM_EVENT_ADDED_TO_WORKSPACE: |
| 278 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: | 285 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: |
| 279 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: | 286 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: |
| 280 NOTREACHED() << "Workspace event should not reach here:" << event; | 287 NOTREACHED() << "Workspace event should not reach here:" << event; |
| 281 break; | 288 break; |
| 282 } | 289 } |
| 283 return false; | 290 return false; |
| 284 } | 291 } |
| 285 | 292 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 case WM_EVENT_TOGGLE_FULLSCREEN: | 372 case WM_EVENT_TOGGLE_FULLSCREEN: |
| 366 case WM_EVENT_CENTER: | 373 case WM_EVENT_CENTER: |
| 367 case WM_EVENT_NORMAL: | 374 case WM_EVENT_NORMAL: |
| 368 case WM_EVENT_MAXIMIZE: | 375 case WM_EVENT_MAXIMIZE: |
| 369 case WM_EVENT_MINIMIZE: | 376 case WM_EVENT_MINIMIZE: |
| 370 case WM_EVENT_FULLSCREEN: | 377 case WM_EVENT_FULLSCREEN: |
| 371 case WM_EVENT_SNAP_LEFT: | 378 case WM_EVENT_SNAP_LEFT: |
| 372 case WM_EVENT_SNAP_RIGHT: | 379 case WM_EVENT_SNAP_RIGHT: |
| 373 case WM_EVENT_SET_BOUNDS: | 380 case WM_EVENT_SET_BOUNDS: |
| 374 case WM_EVENT_SHOW_INACTIVE: | 381 case WM_EVENT_SHOW_INACTIVE: |
| 382 case WM_EVENT_DOCK: | |
| 375 break; | 383 break; |
| 376 } | 384 } |
| 377 return false; | 385 return false; |
| 378 } | 386 } |
| 379 | 387 |
| 380 // static | 388 // static |
| 381 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) { | 389 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) { |
| 382 DCHECK(!window_state->is_dragged()); | 390 DCHECK(!window_state->is_dragged()); |
| 383 if (window_state->IsMaximized()) { | 391 if (window_state->IsMaximized()) { |
| 384 window_state->SetBoundsDirect( | 392 window_state->SetBoundsDirect( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 415 // Do nothing if we're already in the same state. | 423 // Do nothing if we're already in the same state. |
| 416 if (state_type_ == next_state_type) | 424 if (state_type_ == next_state_type) |
| 417 return; | 425 return; |
| 418 | 426 |
| 419 WindowStateType previous_state_type = state_type_; | 427 WindowStateType previous_state_type = state_type_; |
| 420 state_type_ = next_state_type; | 428 state_type_ = next_state_type; |
| 421 | 429 |
| 422 window_state->UpdateWindowShowStateFromStateType(); | 430 window_state->UpdateWindowShowStateFromStateType(); |
| 423 window_state->NotifyPreStateTypeChange(previous_state_type); | 431 window_state->NotifyPreStateTypeChange(previous_state_type); |
| 424 | 432 |
| 425 // This Docked/Snapped hack is due to the issue that IsDocked returns | 433 if (window_state->window()->parent()) { |
| 426 // true for dragging window. TODO(oshima): Make docked window a state | |
| 427 // and remove this hack. | |
| 428 if (window_state->window()->parent() && | |
| 429 (window_state->IsSnapped() || | |
| 430 (!window_state->IsDocked() && !IsPanel(window_state->window())))) { | |
| 431 if (!window_state->HasRestoreBounds() && | 434 if (!window_state->HasRestoreBounds() && |
| 432 (previous_state_type == WINDOW_STATE_TYPE_DEFAULT || | 435 (previous_state_type == WINDOW_STATE_TYPE_DEFAULT || |
| 433 previous_state_type == WINDOW_STATE_TYPE_NORMAL) && | 436 previous_state_type == WINDOW_STATE_TYPE_NORMAL) && |
| 434 !window_state->IsMinimized() && | 437 !window_state->IsMinimized() && |
| 435 !window_state->IsNormalStateType()) { | 438 !window_state->IsNormalStateType()) { |
| 436 window_state->SaveCurrentBoundsForRestore(); | 439 window_state->SaveCurrentBoundsForRestore(); |
| 437 } | 440 } |
| 438 | 441 |
| 439 // When restoring from a minimized state, we want to restore to the previous | 442 // When restoring from a minimized state, we want to restore to the |
| 440 // bounds. However, we want to maintain the restore bounds. (The restore | 443 // previous bounds. However, we want to maintain the restore bounds. |
| 441 // bounds are set if a user maximized the window in one axis by double | 444 // (The restore bounds are set if a user maximized the window in one |
| 442 // clicking the window border for example). | 445 // axis by double clicking the window border for example). |
| 443 gfx::Rect restore_bounds_in_screen; | 446 gfx::Rect restore_bounds_in_screen; |
| 444 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED && | 447 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED && |
| 445 window_state->IsNormalStateType() && | 448 window_state->IsNormalStateType() && |
| 446 window_state->HasRestoreBounds() && | 449 window_state->HasRestoreBounds() && |
| 447 !window_state->unminimize_to_restore_bounds()) { | 450 !window_state->unminimize_to_restore_bounds()) { |
| 448 restore_bounds_in_screen = window_state->GetRestoreBoundsInScreen(); | 451 restore_bounds_in_screen = window_state->GetRestoreBoundsInScreen(); |
| 449 window_state->SaveCurrentBoundsForRestore(); | 452 window_state->SaveCurrentBoundsForRestore(); |
| 450 } | 453 } |
| 451 | 454 |
| 452 if (window_state->IsMaximizedOrFullscreen()) | 455 if (window_state->IsMaximizedOrFullscreen()) |
| 453 MoveToDisplayForRestore(window_state); | 456 MoveToDisplayForRestore(window_state); |
| 454 | 457 |
| 455 UpdateBoundsFromState(window_state, previous_state_type); | 458 UpdateBoundsFromState(window_state, previous_state_type); |
| 456 | 459 |
| 457 // Normal state should have no restore bounds unless it's | 460 // Normal state should have no restore bounds unless it's |
| 458 // unminimzied. | 461 // unminimized. |
| 459 if (!restore_bounds_in_screen.IsEmpty()) | 462 if (!restore_bounds_in_screen.IsEmpty()) |
| 460 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen); | 463 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen); |
| 461 else if (window_state->IsNormalStateType()) | 464 else if (window_state->IsNormalStateType()) |
| 462 window_state->ClearRestoreBounds(); | 465 window_state->ClearRestoreBounds(); |
| 463 } | 466 } |
| 464 window_state->NotifyPostStateTypeChange(previous_state_type); | 467 window_state->NotifyPostStateTypeChange(previous_state_type); |
| 465 } | 468 } |
| 466 | 469 |
| 467 void DefaultState::ReenterToCurrentState( | 470 void DefaultState::ReenterToCurrentState( |
| 468 WindowState* window_state, | 471 WindowState* window_state, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 WindowStateType previous_state_type) { | 503 WindowStateType previous_state_type) { |
| 501 aura::Window* window = window_state->window(); | 504 aura::Window* window = window_state->window(); |
| 502 gfx::Rect bounds_in_parent; | 505 gfx::Rect bounds_in_parent; |
| 503 switch (state_type_) { | 506 switch (state_type_) { |
| 504 case WINDOW_STATE_TYPE_LEFT_SNAPPED: | 507 case WINDOW_STATE_TYPE_LEFT_SNAPPED: |
| 505 case WINDOW_STATE_TYPE_RIGHT_SNAPPED: | 508 case WINDOW_STATE_TYPE_RIGHT_SNAPPED: |
| 506 bounds_in_parent = state_type_ == WINDOW_STATE_TYPE_LEFT_SNAPPED ? | 509 bounds_in_parent = state_type_ == WINDOW_STATE_TYPE_LEFT_SNAPPED ? |
| 507 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) : | 510 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) : |
| 508 GetDefaultRightSnappedWindowBoundsInParent(window_state->window()); | 511 GetDefaultRightSnappedWindowBoundsInParent(window_state->window()); |
| 509 break; | 512 break; |
| 513 case WINDOW_STATE_TYPE_DOCKED: { | |
| 514 if (window->parent()->id() != kShellWindowId_DockedContainer) { | |
| 515 aura::Window* docked_container = Shell::GetContainer( | |
| 516 window->GetRootWindow(), | |
| 517 kShellWindowId_DockedContainer); | |
| 518 wm::ReparentChildWithTransientChildren(window, | |
| 519 window->parent(), | |
| 520 docked_container); | |
| 521 } | |
| 522 // Return early because we don't want to update the bounds of the | |
| 523 // window below; as the bounds are managed by the dock layout. | |
| 524 return; | |
| 525 } | |
| 510 case WINDOW_STATE_TYPE_DEFAULT: | 526 case WINDOW_STATE_TYPE_DEFAULT: |
| 511 case WINDOW_STATE_TYPE_NORMAL: { | 527 case WINDOW_STATE_TYPE_NORMAL: { |
| 512 gfx::Rect work_area_in_parent = | 528 gfx::Rect work_area_in_parent = |
| 513 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window()); | 529 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window()); |
| 514 if (window_state->HasRestoreBounds()) { | 530 if (window_state->HasRestoreBounds()) { |
| 515 bounds_in_parent = window_state->GetRestoreBoundsInParent(); | 531 bounds_in_parent = window_state->GetRestoreBoundsInParent(); |
| 516 // Check if the |window|'s restored size is bigger than the working area | 532 // Check if the |window|'s restored size is bigger than the working area |
| 517 // This may happen if a window was resized to maximized bounds or if the | 533 // This may happen if a window was resized to maximized bounds or if the |
| 518 // display resolution changed while the window was maximized. | 534 // display resolution changed while the window was maximized. |
| 519 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED && | 535 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED && |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 533 break; | 549 break; |
| 534 } | 550 } |
| 535 case WINDOW_STATE_TYPE_MAXIMIZED: | 551 case WINDOW_STATE_TYPE_MAXIMIZED: |
| 536 bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window); | 552 bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window); |
| 537 break; | 553 break; |
| 538 | 554 |
| 539 case WINDOW_STATE_TYPE_FULLSCREEN: | 555 case WINDOW_STATE_TYPE_FULLSCREEN: |
| 540 bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent(window); | 556 bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent(window); |
| 541 break; | 557 break; |
| 542 | 558 |
| 559 case WINDOW_STATE_TYPE_DOCKED_MINIMIZED: | |
| 543 case WINDOW_STATE_TYPE_MINIMIZED: | 560 case WINDOW_STATE_TYPE_MINIMIZED: |
| 544 break; | 561 break; |
| 545 case WINDOW_STATE_TYPE_INACTIVE: | 562 case WINDOW_STATE_TYPE_INACTIVE: |
| 546 case WINDOW_STATE_TYPE_END: | 563 case WINDOW_STATE_TYPE_END: |
| 547 case WINDOW_STATE_TYPE_AUTO_POSITIONED: | 564 case WINDOW_STATE_TYPE_AUTO_POSITIONED: |
| 548 return; | 565 return; |
| 549 } | 566 } |
| 550 | 567 |
| 551 if (state_type_ != WINDOW_STATE_TYPE_MINIMIZED) { | 568 if (!window_state->IsMinimized()) { |
| 552 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED || | 569 if (IsMinimizedWindowState(previous_state_type) || |
| 553 window_state->IsFullscreen()) { | 570 window_state->IsFullscreen()) { |
| 554 window_state->SetBoundsDirect(bounds_in_parent); | 571 window_state->SetBoundsDirect(bounds_in_parent); |
| 555 } else if (window_state->IsMaximized() || | 572 } else if (window_state->IsMaximized() || |
| 556 IsMaximizedOrFullscreenWindowStateType(previous_state_type)) { | 573 IsMaximizedOrFullscreenWindowStateType(previous_state_type)) { |
| 557 window_state->SetBoundsDirectCrossFade(bounds_in_parent); | 574 window_state->SetBoundsDirectCrossFade(bounds_in_parent); |
| 558 } else if (window_state->is_dragged()) { | 575 } else if (window_state->is_dragged()) { |
| 559 // SetBoundsDirectAnimated does not work when the window gets reparented. | 576 // SetBoundsDirectAnimated does not work when the window gets reparented. |
| 560 // TODO(oshima): Consider fixing it and reenable the animation. | 577 // TODO(oshima): Consider fixing it and reenable the animation. |
| 561 window_state->SetBoundsDirect(bounds_in_parent); | 578 window_state->SetBoundsDirect(bounds_in_parent); |
| 562 } else { | 579 } else { |
| 563 window_state->SetBoundsDirectAnimated(bounds_in_parent); | 580 window_state->SetBoundsDirectAnimated(bounds_in_parent); |
| 564 } | 581 } |
| 565 } | 582 } |
| 566 | 583 |
| 567 if (window_state->IsMinimized()) { | 584 if (window_state->IsMinimized()) { |
| 568 // Save the previous show state so that we can correctly restore it. | 585 // Save the previous show state so that we can correctly restore it. |
| 569 window_state->window()->SetProperty(aura::client::kRestoreShowStateKey, | 586 window_state->window()->SetProperty(aura::client::kRestoreShowStateKey, |
| 570 ToWindowShowState(previous_state_type)); | 587 ToWindowShowState(previous_state_type)); |
| 571 ::wm::SetWindowVisibilityAnimationType( | 588 ::wm::SetWindowVisibilityAnimationType( |
| 572 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); | 589 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); |
| 573 | 590 |
| 574 // Hide the window. | 591 // Hide the window. |
| 575 window_state->window()->Hide(); | 592 window_state->window()->Hide(); |
| 576 // Activate another window. | 593 // Activate another window. |
| 577 if (window_state->IsActive()) | 594 if (window_state->IsActive()) |
| 578 window_state->Deactivate(); | 595 window_state->Deactivate(); |
| 579 } else if ((window_state->window()->TargetVisibility() || | 596 } else if ((window_state->window()->TargetVisibility() || |
| 580 previous_state_type == WINDOW_STATE_TYPE_MINIMIZED) && | 597 IsMinimizedWindowState(previous_state_type)) && |
| 581 !window_state->window()->layer()->visible()) { | 598 !window_state->window()->layer()->visible()) { |
| 582 // The layer may be hidden if the window was previously minimized. Make | 599 // The layer may be hidden if the window was previously minimized. Make |
| 583 // sure it's visible. | 600 // sure it's visible. |
| 584 window_state->window()->Show(); | 601 window_state->window()->Show(); |
| 585 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED && | 602 if (IsMinimizedWindowState(previous_state_type) && |
| 586 !window_state->IsMaximizedOrFullscreen()) { | 603 !window_state->IsMaximizedOrFullscreen()) { |
| 587 window_state->set_unminimize_to_restore_bounds(false); | 604 window_state->set_unminimize_to_restore_bounds(false); |
| 588 } | 605 } |
| 589 } | 606 } |
| 590 } | 607 } |
| 591 | 608 |
| 592 // static | 609 // static |
| 593 void DefaultState::CenterWindow(WindowState* window_state) { | 610 void DefaultState::CenterWindow(WindowState* window_state) { |
| 594 if (!window_state->IsNormalOrSnapped()) | 611 if (!window_state->IsNormalOrSnapped()) |
| 595 return; | 612 return; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 608 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); | 625 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); |
| 609 center_in_parent.ClampToCenteredSize(window->bounds().size()); | 626 center_in_parent.ClampToCenteredSize(window->bounds().size()); |
| 610 window_state->SetBoundsDirectAnimated(center_in_parent); | 627 window_state->SetBoundsDirectAnimated(center_in_parent); |
| 611 } | 628 } |
| 612 // Centering window is treated as if a user moved and resized the window. | 629 // Centering window is treated as if a user moved and resized the window. |
| 613 window_state->set_bounds_changed_by_user(true); | 630 window_state->set_bounds_changed_by_user(true); |
| 614 } | 631 } |
| 615 | 632 |
| 616 } // namespace wm | 633 } // namespace wm |
| 617 } // namespace ash | 634 } // namespace ash |
| OLD | NEW |