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

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: Move parenting of Docked state into default_state.cc 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
« no previous file with comments | « ash/metrics/user_metrics_recorder.cc ('k') | ash/wm/dock/docked_window_layout_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 12 matching lines...) Expand all
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);
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
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
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
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
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
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 }
oshima 2014/10/02 21:36:49 can you add comment why this should return instead
dtapuska 2014/10/02 21:43:41 Done.
522 return;
523 }
510 case WINDOW_STATE_TYPE_DEFAULT: 524 case WINDOW_STATE_TYPE_DEFAULT:
511 case WINDOW_STATE_TYPE_NORMAL: { 525 case WINDOW_STATE_TYPE_NORMAL: {
512 gfx::Rect work_area_in_parent = 526 gfx::Rect work_area_in_parent =
513 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window()); 527 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window());
514 if (window_state->HasRestoreBounds()) { 528 if (window_state->HasRestoreBounds()) {
515 bounds_in_parent = window_state->GetRestoreBoundsInParent(); 529 bounds_in_parent = window_state->GetRestoreBoundsInParent();
516 // Check if the |window|'s restored size is bigger than the working area 530 // 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 531 // This may happen if a window was resized to maximized bounds or if the
518 // display resolution changed while the window was maximized. 532 // display resolution changed while the window was maximized.
519 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED && 533 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED &&
(...skipping 13 matching lines...) Expand all
533 break; 547 break;
534 } 548 }
535 case WINDOW_STATE_TYPE_MAXIMIZED: 549 case WINDOW_STATE_TYPE_MAXIMIZED:
536 bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window); 550 bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window);
537 break; 551 break;
538 552
539 case WINDOW_STATE_TYPE_FULLSCREEN: 553 case WINDOW_STATE_TYPE_FULLSCREEN:
540 bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent(window); 554 bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent(window);
541 break; 555 break;
542 556
557 case WINDOW_STATE_TYPE_DOCKED_MINIMIZED:
543 case WINDOW_STATE_TYPE_MINIMIZED: 558 case WINDOW_STATE_TYPE_MINIMIZED:
544 break; 559 break;
545 case WINDOW_STATE_TYPE_INACTIVE: 560 case WINDOW_STATE_TYPE_INACTIVE:
546 case WINDOW_STATE_TYPE_END: 561 case WINDOW_STATE_TYPE_END:
547 case WINDOW_STATE_TYPE_AUTO_POSITIONED: 562 case WINDOW_STATE_TYPE_AUTO_POSITIONED:
548 return; 563 return;
549 } 564 }
550 565
551 if (state_type_ != WINDOW_STATE_TYPE_MINIMIZED) { 566 if (!window_state->IsMinimized()) {
552 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED || 567 if (IsMinimizedWindowState(previous_state_type) ||
553 window_state->IsFullscreen()) { 568 window_state->IsFullscreen()) {
554 window_state->SetBoundsDirect(bounds_in_parent); 569 window_state->SetBoundsDirect(bounds_in_parent);
555 } else if (window_state->IsMaximized() || 570 } else if (window_state->IsMaximized() ||
556 IsMaximizedOrFullscreenWindowStateType(previous_state_type)) { 571 IsMaximizedOrFullscreenWindowStateType(previous_state_type)) {
557 window_state->SetBoundsDirectCrossFade(bounds_in_parent); 572 window_state->SetBoundsDirectCrossFade(bounds_in_parent);
558 } else if (window_state->is_dragged()) { 573 } else if (window_state->is_dragged()) {
559 // SetBoundsDirectAnimated does not work when the window gets reparented. 574 // SetBoundsDirectAnimated does not work when the window gets reparented.
560 // TODO(oshima): Consider fixing it and reenable the animation. 575 // TODO(oshima): Consider fixing it and reenable the animation.
561 window_state->SetBoundsDirect(bounds_in_parent); 576 window_state->SetBoundsDirect(bounds_in_parent);
562 } else { 577 } else {
563 window_state->SetBoundsDirectAnimated(bounds_in_parent); 578 window_state->SetBoundsDirectAnimated(bounds_in_parent);
564 } 579 }
565 } 580 }
566 581
567 if (window_state->IsMinimized()) { 582 if (window_state->IsMinimized()) {
568 // Save the previous show state so that we can correctly restore it. 583 // Save the previous show state so that we can correctly restore it.
569 window_state->window()->SetProperty(aura::client::kRestoreShowStateKey, 584 window_state->window()->SetProperty(aura::client::kRestoreShowStateKey,
570 ToWindowShowState(previous_state_type)); 585 ToWindowShowState(previous_state_type));
571 ::wm::SetWindowVisibilityAnimationType( 586 ::wm::SetWindowVisibilityAnimationType(
572 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 587 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
573 588
574 // Hide the window. 589 // Hide the window.
575 window_state->window()->Hide(); 590 window_state->window()->Hide();
576 // Activate another window. 591 // Activate another window.
577 if (window_state->IsActive()) 592 if (window_state->IsActive())
578 window_state->Deactivate(); 593 window_state->Deactivate();
579 } else if ((window_state->window()->TargetVisibility() || 594 } else if ((window_state->window()->TargetVisibility() ||
580 previous_state_type == WINDOW_STATE_TYPE_MINIMIZED) && 595 IsMinimizedWindowState(previous_state_type)) &&
581 !window_state->window()->layer()->visible()) { 596 !window_state->window()->layer()->visible()) {
582 // The layer may be hidden if the window was previously minimized. Make 597 // The layer may be hidden if the window was previously minimized. Make
583 // sure it's visible. 598 // sure it's visible.
584 window_state->window()->Show(); 599 window_state->window()->Show();
585 if (previous_state_type == WINDOW_STATE_TYPE_MINIMIZED && 600 if (IsMinimizedWindowState(previous_state_type) &&
586 !window_state->IsMaximizedOrFullscreen()) { 601 !window_state->IsMaximizedOrFullscreen()) {
587 window_state->set_unminimize_to_restore_bounds(false); 602 window_state->set_unminimize_to_restore_bounds(false);
588 } 603 }
589 } 604 }
590 } 605 }
591 606
592 // static 607 // static
593 void DefaultState::CenterWindow(WindowState* window_state) { 608 void DefaultState::CenterWindow(WindowState* window_state) {
594 if (!window_state->IsNormalOrSnapped()) 609 if (!window_state->IsNormalOrSnapped())
595 return; 610 return;
(...skipping 12 matching lines...) Expand all
608 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); 623 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window);
609 center_in_parent.ClampToCenteredSize(window->bounds().size()); 624 center_in_parent.ClampToCenteredSize(window->bounds().size());
610 window_state->SetBoundsDirectAnimated(center_in_parent); 625 window_state->SetBoundsDirectAnimated(center_in_parent);
611 } 626 }
612 // Centering window is treated as if a user moved and resized the window. 627 // Centering window is treated as if a user moved and resized the window.
613 window_state->set_bounds_changed_by_user(true); 628 window_state->set_bounds_changed_by_user(true);
614 } 629 }
615 630
616 } // namespace wm 631 } // namespace wm
617 } // namespace ash 632 } // namespace ash
OLDNEW
« no previous file with comments | « ash/metrics/user_metrics_recorder.cc ('k') | ash/wm/dock/docked_window_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698