| 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_manager2.h" | 5 #include "ash/wm/workspace/workspace_manager2.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
| 14 #include "ash/wm/base_layout_manager.h" | 14 #include "ash/wm/base_layout_manager.h" |
| 15 #include "ash/wm/property_util.h" | 15 #include "ash/wm/property_util.h" |
| 16 #include "ash/wm/shelf_layout_manager.h" | 16 #include "ash/wm/shelf_layout_manager.h" |
| 17 #include "ash/wm/window_animations.h" | 17 #include "ash/wm/window_animations.h" |
| 18 #include "ash/wm/window_properties.h" | 18 #include "ash/wm/window_properties.h" |
| 19 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
| 20 #include "ash/wm/workspace/auto_window_management.h" |
| 20 #include "ash/wm/workspace/desktop_background_fade_controller.h" | 21 #include "ash/wm/workspace/desktop_background_fade_controller.h" |
| 21 #include "ash/wm/workspace/workspace_animations.h" | 22 #include "ash/wm/workspace/workspace_animations.h" |
| 22 #include "ash/wm/workspace/workspace_layout_manager2.h" | 23 #include "ash/wm/workspace/workspace_layout_manager2.h" |
| 23 #include "ash/wm/workspace/workspace2.h" | 24 #include "ash/wm/workspace/workspace2.h" |
| 24 #include "base/auto_reset.h" | 25 #include "base/auto_reset.h" |
| 25 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 26 #include "base/logging.h" | 27 #include "base/logging.h" |
| 27 #include "base/stl_util.h" | 28 #include "base/stl_util.h" |
| 28 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
| 29 #include "ui/aura/root_window.h" | 30 #include "ui/aura/root_window.h" |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 } | 587 } |
| 587 | 588 |
| 588 void WorkspaceManager2::OnWindowAddedToWorkspace(Workspace2* workspace, | 589 void WorkspaceManager2::OnWindowAddedToWorkspace(Workspace2* workspace, |
| 589 Window* child) { | 590 Window* child) { |
| 590 child->SetProperty(kWorkspaceKey, workspace); | 591 child->SetProperty(kWorkspaceKey, workspace); |
| 591 // Do nothing (other than updating shelf visibility) as the right parent was | 592 // Do nothing (other than updating shelf visibility) as the right parent was |
| 592 // chosen by way of GetParentForNewWindow() or we explicitly moved the window | 593 // chosen by way of GetParentForNewWindow() or we explicitly moved the window |
| 593 // to the workspace. | 594 // to the workspace. |
| 594 if (workspace == active_workspace_) | 595 if (workspace == active_workspace_) |
| 595 UpdateShelfVisibility(); | 596 UpdateShelfVisibility(); |
| 597 |
| 598 RearrangeVisibleWindowOnShow(child); |
| 596 } | 599 } |
| 597 | 600 |
| 598 void WorkspaceManager2::OnWillRemoveWindowFromWorkspace(Workspace2* workspace, | 601 void WorkspaceManager2::OnWillRemoveWindowFromWorkspace(Workspace2* workspace, |
| 599 Window* child) { | 602 Window* child) { |
| 603 RearrangeVisibleWindowOnHideOrRemove(child); |
| 600 child->ClearProperty(kWorkspaceKey); | 604 child->ClearProperty(kWorkspaceKey); |
| 601 } | 605 } |
| 602 | 606 |
| 603 void WorkspaceManager2::OnWindowRemovedFromWorkspace(Workspace2* workspace, | 607 void WorkspaceManager2::OnWindowRemovedFromWorkspace(Workspace2* workspace, |
| 604 Window* child) { | 608 Window* child) { |
| 605 if (workspace->ShouldMoveToPending()) | 609 if (workspace->ShouldMoveToPending()) |
| 606 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_WINDOW_REMOVED); | 610 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_WINDOW_REMOVED); |
| 607 } | 611 } |
| 608 | 612 |
| 609 void WorkspaceManager2::OnWorkspaceChildWindowVisibilityChanged( | 613 void WorkspaceManager2::OnWorkspaceChildWindowVisibilityChanged( |
| 610 Workspace2* workspace, | 614 Workspace2* workspace, |
| 611 Window* child) { | 615 Window* child) { |
| 612 if (workspace->ShouldMoveToPending()) | 616 if (workspace->ShouldMoveToPending()) { |
| 613 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_VISIBILITY_CHANGED); | 617 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_VISIBILITY_CHANGED); |
| 614 else if (workspace == active_workspace_) | 618 } else { |
| 615 UpdateShelfVisibility(); | 619 if (child->TargetVisibility()) |
| 620 RearrangeVisibleWindowOnShow(child); |
| 621 else |
| 622 RearrangeVisibleWindowOnHideOrRemove(child); |
| 623 if (workspace == active_workspace_) |
| 624 UpdateShelfVisibility(); |
| 625 } |
| 616 } | 626 } |
| 617 | 627 |
| 618 void WorkspaceManager2::OnWorkspaceWindowChildBoundsChanged( | 628 void WorkspaceManager2::OnWorkspaceWindowChildBoundsChanged( |
| 619 Workspace2* workspace, | 629 Workspace2* workspace, |
| 620 Window* child) { | 630 Window* child) { |
| 621 if (workspace == active_workspace_) | 631 if (workspace == active_workspace_) |
| 622 UpdateShelfVisibility(); | 632 UpdateShelfVisibility(); |
| 623 } | 633 } |
| 624 | 634 |
| 625 void WorkspaceManager2::OnWorkspaceWindowShowStateChanged( | 635 void WorkspaceManager2::OnWorkspaceWindowShowStateChanged( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 new_workspace->window()->Show(); | 722 new_workspace->window()->Show(); |
| 713 ReparentWindow(window, new_workspace->window(), NULL); | 723 ReparentWindow(window, new_workspace->window(), NULL); |
| 714 if (is_active) { | 724 if (is_active) { |
| 715 SetActiveWorkspace(new_workspace, SWITCH_TRACKED_BY_WORKSPACE_CHANGED, | 725 SetActiveWorkspace(new_workspace, SWITCH_TRACKED_BY_WORKSPACE_CHANGED, |
| 716 base::TimeDelta()); | 726 base::TimeDelta()); |
| 717 } | 727 } |
| 718 } | 728 } |
| 719 | 729 |
| 720 } // namespace internal | 730 } // namespace internal |
| 721 } // namespace ash | 731 } // namespace ash |
| OLD | NEW |