Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Side by Side Diff: ash/wm/default_state.cc

Issue 597683003: Add window states docked; and docked minimized. Add wm window event to set docked and undocked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dock
Patch Set: Address varkha's comments from patch set 4. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
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 IsPanel(aura::Window* window) {
34 return window->parent() && 34 return window->parent() &&
35 window->parent()->id() == kShellWindowId_PanelContainer; 35 window->parent()->id() == kShellWindowId_PanelContainer;
36 } 36 }
37 37
38 bool IsMinimizedWindowState(const WindowStateType state_type) {
39 return (state_type == WINDOW_STATE_TYPE_MINIMIZED ||
40 state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED);
41 }
42
38 void MoveToDisplayForRestore(WindowState* window_state) { 43 void MoveToDisplayForRestore(WindowState* window_state) {
39 if (!window_state->HasRestoreBounds()) 44 if (!window_state->HasRestoreBounds())
40 return; 45 return;
41 const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen(); 46 const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen();
42 47
43 // Move only if the restore bounds is outside of 48 // Move only if the restore bounds is outside of
44 // the display. There is no information about in which 49 // the display. There is no information about in which
45 // display it should be restored, so this is best guess. 50 // display it should be restored, so this is best guess.
46 // TODO(oshima): Restore information should contain the 51 // TODO(oshima): Restore information should contain the
47 // work area information like WindowResizer does for the 52 // work area information like WindowResizer does for the
(...skipping 23 matching lines...) Expand all
71 DefaultState::~DefaultState() {} 76 DefaultState::~DefaultState() {}
72 77
73 void DefaultState::OnWMEvent(WindowState* window_state, 78 void DefaultState::OnWMEvent(WindowState* window_state,
74 const WMEvent* event) { 79 const WMEvent* event) {
75 if (ProcessWorkspaceEvents(window_state, event)) 80 if (ProcessWorkspaceEvents(window_state, event))
76 return; 81 return;
77 82
78 if (ProcessCompoundEvents(window_state, event)) 83 if (ProcessCompoundEvents(window_state, event))
79 return; 84 return;
80 85
86 WindowStateType current_state_type = window_state->GetStateType();
81 WindowStateType next_state_type = WINDOW_STATE_TYPE_NORMAL; 87 WindowStateType next_state_type = WINDOW_STATE_TYPE_NORMAL;
82 switch (event->type()) { 88 switch (event->type()) {
83 case WM_EVENT_NORMAL: 89 case WM_EVENT_NORMAL:
84 next_state_type = WINDOW_STATE_TYPE_NORMAL; 90 next_state_type =
91 current_state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED ?
92 WINDOW_STATE_TYPE_DOCKED : WINDOW_STATE_TYPE_NORMAL;
varkha 2014/09/30 20:15:19 nit: The line after ? should also be indented +4.
dtapuska 2014/10/01 15:01:33 Done.
85 break; 93 break;
86 case WM_EVENT_MAXIMIZE: 94 case WM_EVENT_MAXIMIZE:
87 next_state_type = WINDOW_STATE_TYPE_MAXIMIZED; 95 next_state_type = WINDOW_STATE_TYPE_MAXIMIZED;
88 break; 96 break;
89 case WM_EVENT_MINIMIZE: 97 case WM_EVENT_MINIMIZE:
90 next_state_type = WINDOW_STATE_TYPE_MINIMIZED; 98 next_state_type =
99 current_state_type == WINDOW_STATE_TYPE_DOCKED ?
100 WINDOW_STATE_TYPE_DOCKED_MINIMIZED : WINDOW_STATE_TYPE_MINIMIZED;
varkha 2014/09/30 20:15:19 nit: The line after ? should also be indented +4.
dtapuska 2014/10/01 15:01:33 Done.
91 break; 101 break;
92 case WM_EVENT_FULLSCREEN: 102 case WM_EVENT_FULLSCREEN:
93 next_state_type = WINDOW_STATE_TYPE_FULLSCREEN; 103 next_state_type = WINDOW_STATE_TYPE_FULLSCREEN;
94 break; 104 break;
95 case WM_EVENT_SNAP_LEFT: 105 case WM_EVENT_SNAP_LEFT:
96 next_state_type = WINDOW_STATE_TYPE_LEFT_SNAPPED; 106 next_state_type = WINDOW_STATE_TYPE_LEFT_SNAPPED;
97 break; 107 break;
98 case WM_EVENT_SNAP_RIGHT: 108 case WM_EVENT_SNAP_RIGHT:
99 next_state_type = WINDOW_STATE_TYPE_RIGHT_SNAPPED; 109 next_state_type = WINDOW_STATE_TYPE_RIGHT_SNAPPED;
100 break; 110 break;
111 case WM_EVENT_DOCK:
112 next_state_type = WINDOW_STATE_TYPE_DOCKED;
113 break;
101 case WM_EVENT_SET_BOUNDS: 114 case WM_EVENT_SET_BOUNDS:
102 SetBounds(window_state, static_cast<const SetBoundsEvent*>(event)); 115 SetBounds(window_state, static_cast<const SetBoundsEvent*>(event));
103 return; 116 return;
104 case WM_EVENT_SHOW_INACTIVE: 117 case WM_EVENT_SHOW_INACTIVE:
105 next_state_type = WINDOW_STATE_TYPE_INACTIVE; 118 next_state_type = WINDOW_STATE_TYPE_INACTIVE;
106 break; 119 break;
107 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: 120 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION:
108 case WM_EVENT_TOGGLE_MAXIMIZE: 121 case WM_EVENT_TOGGLE_MAXIMIZE:
109 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: 122 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE:
110 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: 123 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE:
111 case WM_EVENT_TOGGLE_FULLSCREEN: 124 case WM_EVENT_TOGGLE_FULLSCREEN:
112 case WM_EVENT_CENTER: 125 case WM_EVENT_CENTER:
113 NOTREACHED() << "Compound event should not reach here:" << event; 126 NOTREACHED() << "Compound event should not reach here:" << event;
114 return; 127 return;
115 case WM_EVENT_ADDED_TO_WORKSPACE: 128 case WM_EVENT_ADDED_TO_WORKSPACE:
116 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: 129 case WM_EVENT_WORKAREA_BOUNDS_CHANGED:
117 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: 130 case WM_EVENT_DISPLAY_BOUNDS_CHANGED:
118 NOTREACHED() << "Workspace event should not reach here:" << event; 131 NOTREACHED() << "Workspace event should not reach here:" << event;
119 return; 132 return;
120 } 133 }
121 134
122 WindowStateType current = window_state->GetStateType(); 135 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 ? 136 gfx::Rect snapped_bounds = event->type() == WM_EVENT_SNAP_LEFT ?
126 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) : 137 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) :
127 GetDefaultRightSnappedWindowBoundsInParent(window_state->window()); 138 GetDefaultRightSnappedWindowBoundsInParent(window_state->window());
128 window_state->SetBoundsDirectAnimated(snapped_bounds); 139 window_state->SetBoundsDirectAnimated(snapped_bounds);
129 return; 140 return;
130 } 141 }
131 142
132 EnterToNextState(window_state, next_state_type); 143 EnterToNextState(window_state, next_state_type);
133 } 144 }
134 145
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 CenterWindow(window_state); 277 CenterWindow(window_state);
267 return true; 278 return true;
268 case WM_EVENT_NORMAL: 279 case WM_EVENT_NORMAL:
269 case WM_EVENT_MAXIMIZE: 280 case WM_EVENT_MAXIMIZE:
270 case WM_EVENT_MINIMIZE: 281 case WM_EVENT_MINIMIZE:
271 case WM_EVENT_FULLSCREEN: 282 case WM_EVENT_FULLSCREEN:
272 case WM_EVENT_SNAP_LEFT: 283 case WM_EVENT_SNAP_LEFT:
273 case WM_EVENT_SNAP_RIGHT: 284 case WM_EVENT_SNAP_RIGHT:
274 case WM_EVENT_SET_BOUNDS: 285 case WM_EVENT_SET_BOUNDS:
275 case WM_EVENT_SHOW_INACTIVE: 286 case WM_EVENT_SHOW_INACTIVE:
287 case WM_EVENT_DOCK:
276 break; 288 break;
277 case WM_EVENT_ADDED_TO_WORKSPACE: 289 case WM_EVENT_ADDED_TO_WORKSPACE:
278 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: 290 case WM_EVENT_WORKAREA_BOUNDS_CHANGED:
279 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: 291 case WM_EVENT_DISPLAY_BOUNDS_CHANGED:
280 NOTREACHED() << "Workspace event should not reach here:" << event; 292 NOTREACHED() << "Workspace event should not reach here:" << event;
281 break; 293 break;
282 } 294 }
283 return false; 295 return false;
284 } 296 }
285 297
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 case WM_EVENT_TOGGLE_FULLSCREEN: 377 case WM_EVENT_TOGGLE_FULLSCREEN:
366 case WM_EVENT_CENTER: 378 case WM_EVENT_CENTER:
367 case WM_EVENT_NORMAL: 379 case WM_EVENT_NORMAL:
368 case WM_EVENT_MAXIMIZE: 380 case WM_EVENT_MAXIMIZE:
369 case WM_EVENT_MINIMIZE: 381 case WM_EVENT_MINIMIZE:
370 case WM_EVENT_FULLSCREEN: 382 case WM_EVENT_FULLSCREEN:
371 case WM_EVENT_SNAP_LEFT: 383 case WM_EVENT_SNAP_LEFT:
372 case WM_EVENT_SNAP_RIGHT: 384 case WM_EVENT_SNAP_RIGHT:
373 case WM_EVENT_SET_BOUNDS: 385 case WM_EVENT_SET_BOUNDS:
374 case WM_EVENT_SHOW_INACTIVE: 386 case WM_EVENT_SHOW_INACTIVE:
387 case WM_EVENT_DOCK:
375 break; 388 break;
376 } 389 }
377 return false; 390 return false;
378 } 391 }
379 392
380 // static 393 // static
381 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) { 394 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) {
382 DCHECK(!window_state->is_dragged()); 395 DCHECK(!window_state->is_dragged());
383 if (window_state->IsMaximized()) { 396 if (window_state->IsMaximized()) {
384 window_state->SetBoundsDirect( 397 window_state->SetBoundsDirect(
(...skipping 30 matching lines...) Expand all
415 // Do nothing if we're already in the same state. 428 // Do nothing if we're already in the same state.
416 if (state_type_ == next_state_type) 429 if (state_type_ == next_state_type)
417 return; 430 return;
418 431
419 WindowStateType previous_state_type = state_type_; 432 WindowStateType previous_state_type = state_type_;
420 state_type_ = next_state_type; 433 state_type_ = next_state_type;
421 434
422 window_state->UpdateWindowShowStateFromStateType(); 435 window_state->UpdateWindowShowStateFromStateType();
423 window_state->NotifyPreStateTypeChange(previous_state_type); 436 window_state->NotifyPreStateTypeChange(previous_state_type);
424 437
425 // This Docked/Snapped hack is due to the issue that IsDocked returns 438 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() && 439 if (!window_state->HasRestoreBounds() &&
432 (previous_state_type == WINDOW_STATE_TYPE_DEFAULT || 440 (previous_state_type == WINDOW_STATE_TYPE_DEFAULT ||
433 previous_state_type == WINDOW_STATE_TYPE_NORMAL) && 441 previous_state_type == WINDOW_STATE_TYPE_NORMAL) &&
434 !window_state->IsMinimized() && 442 !window_state->IsMinimized() &&
435 !window_state->IsNormalStateType()) { 443 !window_state->IsNormalStateType()) {
436 window_state->SaveCurrentBoundsForRestore(); 444 window_state->SaveCurrentBoundsForRestore();
445 } else if (window_state->HasRestoreBounds() &&
446 window_state->IsNormalStateType() &&
447 previous_state_type == WINDOW_STATE_TYPE_DOCKED) {
448 UpdateBoundsFromState(window_state, previous_state_type);
437 } 449 }
438 450
439 // When restoring from a minimized state, we want to restore to the previous 451 // This Docked/Snapped hack is due to the issue that IsDocked can return
440 // bounds. However, we want to maintain the restore bounds. (The restore 452 // true for dragging window (until it is undocked).
441 // bounds are set if a user maximized the window in one axis by double 453 if (window_state->IsSnapped() ||
442 // clicking the window border for example). 454 (!window_state->IsDocked() && !IsPanel(window_state->window()))) {
443 gfx::Rect restore_bounds_in_screen; 455 // When restoring from a minimized state, we want to restore to the
444 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED && 456 // previous bounds. However, we want to maintain the restore bounds.
445 window_state->IsNormalStateType() && 457 // (The restore bounds are set if a user maximized the window in one
446 window_state->HasRestoreBounds() && 458 // axis by double clicking the window border for example).
447 !window_state->unminimize_to_restore_bounds()) { 459 gfx::Rect restore_bounds_in_screen;
448 restore_bounds_in_screen = window_state->GetRestoreBoundsInScreen(); 460 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED &&
449 window_state->SaveCurrentBoundsForRestore(); 461 window_state->IsNormalStateType() &&
462 window_state->HasRestoreBounds() &&
463 !window_state->unminimize_to_restore_bounds()) {
464 restore_bounds_in_screen = window_state->GetRestoreBoundsInScreen();
465 window_state->SaveCurrentBoundsForRestore();
466 }
467
468 if (window_state->IsMaximizedOrFullscreen())
469 MoveToDisplayForRestore(window_state);
470
471 UpdateBoundsFromState(window_state, previous_state_type);
472
473 // Normal state should have no restore bounds unless it's
474 // unminimized.
475 if (!restore_bounds_in_screen.IsEmpty())
476 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen);
477 else if (window_state->IsNormalStateType())
478 window_state->ClearRestoreBounds();
450 } 479 }
451
452 if (window_state->IsMaximizedOrFullscreen())
453 MoveToDisplayForRestore(window_state);
454
455 UpdateBoundsFromState(window_state, previous_state_type);
456
457 // Normal state should have no restore bounds unless it's
458 // unminimzied.
459 if (!restore_bounds_in_screen.IsEmpty())
460 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen);
461 else if (window_state->IsNormalStateType())
462 window_state->ClearRestoreBounds();
463 } 480 }
464 window_state->NotifyPostStateTypeChange(previous_state_type); 481 window_state->NotifyPostStateTypeChange(previous_state_type);
465 } 482 }
466 483
467 void DefaultState::ReenterToCurrentState( 484 void DefaultState::ReenterToCurrentState(
468 WindowState* window_state, 485 WindowState* window_state,
469 WindowState::State* state_in_previous_mode) { 486 WindowState::State* state_in_previous_mode) {
470 WindowStateType previous_state_type = state_in_previous_mode->GetType(); 487 WindowStateType previous_state_type = state_in_previous_mode->GetType();
471 if (previous_state_type == wm::WINDOW_STATE_TYPE_FULLSCREEN) { 488 if (previous_state_type == wm::WINDOW_STATE_TYPE_FULLSCREEN) {
472 // A state change should not move a window out of full screen since full 489 // A state change should not move a window out of full screen since full
(...skipping 27 matching lines...) Expand all
500 WindowStateType previous_state_type) { 517 WindowStateType previous_state_type) {
501 aura::Window* window = window_state->window(); 518 aura::Window* window = window_state->window();
502 gfx::Rect bounds_in_parent; 519 gfx::Rect bounds_in_parent;
503 switch (state_type_) { 520 switch (state_type_) {
504 case WINDOW_STATE_TYPE_LEFT_SNAPPED: 521 case WINDOW_STATE_TYPE_LEFT_SNAPPED:
505 case WINDOW_STATE_TYPE_RIGHT_SNAPPED: 522 case WINDOW_STATE_TYPE_RIGHT_SNAPPED:
506 bounds_in_parent = state_type_ == WINDOW_STATE_TYPE_LEFT_SNAPPED ? 523 bounds_in_parent = state_type_ == WINDOW_STATE_TYPE_LEFT_SNAPPED ?
507 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) : 524 GetDefaultLeftSnappedWindowBoundsInParent(window_state->window()) :
508 GetDefaultRightSnappedWindowBoundsInParent(window_state->window()); 525 GetDefaultRightSnappedWindowBoundsInParent(window_state->window());
509 break; 526 break;
527 case WINDOW_STATE_TYPE_DOCKED:
510 case WINDOW_STATE_TYPE_DEFAULT: 528 case WINDOW_STATE_TYPE_DEFAULT:
511 case WINDOW_STATE_TYPE_NORMAL: { 529 case WINDOW_STATE_TYPE_NORMAL: {
512 gfx::Rect work_area_in_parent = 530 gfx::Rect work_area_in_parent =
513 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window()); 531 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window());
514 if (window_state->HasRestoreBounds()) { 532 if (window_state->HasRestoreBounds()) {
515 bounds_in_parent = window_state->GetRestoreBoundsInParent(); 533 bounds_in_parent = window_state->GetRestoreBoundsInParent();
516 // Check if the |window|'s restored size is bigger than the working area 534 // 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 535 // This may happen if a window was resized to maximized bounds or if the
518 // display resolution changed while the window was maximized. 536 // display resolution changed while the window was maximized.
519 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED && 537 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED &&
(...skipping 13 matching lines...) Expand all
533 break; 551 break;
534 } 552 }
535 case WINDOW_STATE_TYPE_MAXIMIZED: 553 case WINDOW_STATE_TYPE_MAXIMIZED:
536 bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window); 554 bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window);
537 break; 555 break;
538 556
539 case WINDOW_STATE_TYPE_FULLSCREEN: 557 case WINDOW_STATE_TYPE_FULLSCREEN:
540 bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent(window); 558 bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent(window);
541 break; 559 break;
542 560
561 case WINDOW_STATE_TYPE_DOCKED_MINIMIZED:
543 case WINDOW_STATE_TYPE_MINIMIZED: 562 case WINDOW_STATE_TYPE_MINIMIZED:
544 break; 563 break;
545 case WINDOW_STATE_TYPE_INACTIVE: 564 case WINDOW_STATE_TYPE_INACTIVE:
546 case WINDOW_STATE_TYPE_END: 565 case WINDOW_STATE_TYPE_END:
547 case WINDOW_STATE_TYPE_AUTO_POSITIONED: 566 case WINDOW_STATE_TYPE_AUTO_POSITIONED:
548 return; 567 return;
549 } 568 }
550 569
551 if (state_type_ != WINDOW_STATE_TYPE_MINIMIZED) { 570 if (!window_state->IsMinimized()) {
552 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED || 571 if (IsMinimizedWindowState(previous_state_type) ||
553 window_state->IsFullscreen()) { 572 window_state->IsFullscreen()) {
554 window_state->SetBoundsDirect(bounds_in_parent); 573 window_state->SetBoundsDirect(bounds_in_parent);
555 } else if (window_state->IsMaximized() || 574 } else if (window_state->IsMaximized() ||
556 IsMaximizedOrFullscreenWindowStateType(previous_state_type)) { 575 IsMaximizedOrFullscreenWindowStateType(previous_state_type)) {
557 window_state->SetBoundsDirectCrossFade(bounds_in_parent); 576 window_state->SetBoundsDirectCrossFade(bounds_in_parent);
558 } else if (window_state->is_dragged()) { 577 } else if (window_state->is_dragged()) {
559 // SetBoundsDirectAnimated does not work when the window gets reparented. 578 // SetBoundsDirectAnimated does not work when the window gets reparented.
560 // TODO(oshima): Consider fixing it and reenable the animation. 579 // TODO(oshima): Consider fixing it and reenable the animation.
561 window_state->SetBoundsDirect(bounds_in_parent); 580 window_state->SetBoundsDirect(bounds_in_parent);
562 } else { 581 } else {
563 window_state->SetBoundsDirectAnimated(bounds_in_parent); 582 window_state->SetBoundsDirectAnimated(bounds_in_parent);
564 } 583 }
565 } 584 }
566 585
567 if (window_state->IsMinimized()) { 586 if (window_state->IsMinimized()) {
568 // Save the previous show state so that we can correctly restore it. 587 // Save the previous show state so that we can correctly restore it.
569 window_state->window()->SetProperty(aura::client::kRestoreShowStateKey, 588 window_state->window()->SetProperty(aura::client::kRestoreShowStateKey,
570 ToWindowShowState(previous_state_type)); 589 ToWindowShowState(previous_state_type));
571 ::wm::SetWindowVisibilityAnimationType( 590 ::wm::SetWindowVisibilityAnimationType(
572 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 591 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
573 592
574 // Hide the window. 593 // Hide the window.
575 window_state->window()->Hide(); 594 window_state->window()->Hide();
576 // Activate another window. 595 // Activate another window.
577 if (window_state->IsActive()) 596 if (window_state->IsActive())
578 window_state->Deactivate(); 597 window_state->Deactivate();
579 } else if ((window_state->window()->TargetVisibility() || 598 } else if ((window_state->window()->TargetVisibility() ||
580 previous_state_type == WINDOW_STATE_TYPE_MINIMIZED) && 599 IsMinimizedWindowState(previous_state_type)) &&
581 !window_state->window()->layer()->visible()) { 600 !window_state->window()->layer()->visible()) {
582 // The layer may be hidden if the window was previously minimized. Make 601 // The layer may be hidden if the window was previously minimized. Make
583 // sure it's visible. 602 // sure it's visible.
584 window_state->window()->Show(); 603 window_state->window()->Show();
585 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED && 604 if (IsMinimizedWindowState(previous_state_type) &&
586 !window_state->IsMaximizedOrFullscreen()) { 605 !window_state->IsMaximizedOrFullscreen()) {
587 window_state->set_unminimize_to_restore_bounds(false); 606 window_state->set_unminimize_to_restore_bounds(false);
588 } 607 }
589 } 608 }
590 } 609 }
591 610
592 // static 611 // static
593 void DefaultState::CenterWindow(WindowState* window_state) { 612 void DefaultState::CenterWindow(WindowState* window_state) {
594 if (!window_state->IsNormalOrSnapped()) 613 if (!window_state->IsNormalOrSnapped())
595 return; 614 return;
(...skipping 12 matching lines...) Expand all
608 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); 627 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window);
609 center_in_parent.ClampToCenteredSize(window->bounds().size()); 628 center_in_parent.ClampToCenteredSize(window->bounds().size());
610 window_state->SetBoundsDirectAnimated(center_in_parent); 629 window_state->SetBoundsDirectAnimated(center_in_parent);
611 } 630 }
612 // Centering window is treated as if a user moved and resized the window. 631 // Centering window is treated as if a user moved and resized the window.
613 window_state->set_bounds_changed_by_user(true); 632 window_state->set_bounds_changed_by_user(true);
614 } 633 }
615 634
616 } // namespace wm 635 } // namespace wm
617 } // namespace ash 636 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698