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_manager.h" | 5 #include "ash/wm/workspace/workspace_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // own workspace. | 218 // own workspace. |
219 if (!GetTrackedByWorkspace(window) || | 219 if (!GetTrackedByWorkspace(window) || |
220 (GetPersistsAcrossAllWorkspaces(window) && | 220 (GetPersistsAcrossAllWorkspaces(window) && |
221 !wm::IsWindowFullscreen(window) && !WillRestoreToWorkspace(window))) { | 221 !wm::IsWindowFullscreen(window) && !WillRestoreToWorkspace(window))) { |
222 ReparentWindow(window, active_workspace_->window(), NULL); | 222 ReparentWindow(window, active_workspace_->window(), NULL); |
223 } else { | 223 } else { |
224 SetActiveWorkspace(workspace, SWITCH_WINDOW_MADE_ACTIVE, | 224 SetActiveWorkspace(workspace, SWITCH_WINDOW_MADE_ACTIVE, |
225 base::TimeDelta()); | 225 base::TimeDelta()); |
226 } | 226 } |
227 } | 227 } |
| 228 |
228 if (workspace->is_fullscreen() && wm::IsWindowFullscreen(window)) { | 229 if (workspace->is_fullscreen() && wm::IsWindowFullscreen(window)) { |
229 // Clicking on the fullscreen window in a fullscreen workspace. Force all | 230 // Clicking on the fullscreen window in a fullscreen workspace. Force all |
230 // other windows to drop to the desktop. | 231 // other windows to drop to the desktop. |
231 MoveChildrenToDesktop(workspace->window(), NULL); | 232 MoveChildrenToDesktop(workspace->window(), NULL); |
232 } | 233 } |
233 } | 234 } |
234 | 235 |
235 Window* WorkspaceManager::GetActiveWorkspaceWindow() { | 236 Window* WorkspaceManager::GetActiveWorkspaceWindow() { |
236 return active_workspace_->window(); | 237 return active_workspace_->window(); |
237 } | 238 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 base::TimeDelta duration, | 532 base::TimeDelta duration, |
532 bool show) const { | 533 bool show) const { |
533 WorkspaceAnimationDetails details; | 534 WorkspaceAnimationDetails details; |
534 details.direction = show ? WORKSPACE_ANIMATE_UP : WORKSPACE_ANIMATE_DOWN; | 535 details.direction = show ? WORKSPACE_ANIMATE_UP : WORKSPACE_ANIMATE_DOWN; |
535 details.duration = duration; | 536 details.duration = duration; |
536 | 537 |
537 switch (reason) { | 538 switch (reason) { |
538 case SWITCH_WORKSPACE_CYCLER: | 539 case SWITCH_WORKSPACE_CYCLER: |
539 // The workspace cycler has already animated the desktop background's | 540 // The workspace cycler has already animated the desktop background's |
540 // opacity. Do not do any further animation. | 541 // opacity. Do not do any further animation. |
541 case SWITCH_BACKGROUND_ONLY_WITHIN_DESKTOP: | |
542 // The show/hide of background may happen within the desktop workspace | |
543 // for maximized windows. In that case no animation is needed. | |
544 break; | 542 break; |
545 case SWITCH_FULLSCREEN_FROM_FULLSCREEN_WORKSPACE: | 543 case SWITCH_FULLSCREEN_FROM_FULLSCREEN_WORKSPACE: |
546 case SWITCH_MAXIMIZED_OR_RESTORED: | 544 case SWITCH_MAXIMIZED_OR_RESTORED: |
547 // FadeDesktop() fades the desktop background by animating the opacity of | 545 // FadeDesktop() fades the desktop background by animating the opacity of |
548 // a black window immediately above the desktop background. Set the | 546 // a black window immediately above the desktop background. Set the |
549 // workspace as animated to delay hiding the desktop background by | 547 // workspace as animated to delay hiding the desktop background by |
550 // |duration|. | 548 // |duration|. |
551 details.animate = true; | 549 details.animate = true; |
552 break; | 550 break; |
553 case SWITCH_INITIAL: | 551 case SWITCH_INITIAL: |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 672 |
675 void WorkspaceManager::OnWillRemoveWindowFromWorkspace(Workspace* workspace, | 673 void WorkspaceManager::OnWillRemoveWindowFromWorkspace(Workspace* workspace, |
676 Window* child) { | 674 Window* child) { |
677 if (child->TargetVisibility()) | 675 if (child->TargetVisibility()) |
678 RearrangeVisibleWindowOnHideOrRemove(child); | 676 RearrangeVisibleWindowOnHideOrRemove(child); |
679 child->ClearProperty(kWorkspaceKey); | 677 child->ClearProperty(kWorkspaceKey); |
680 } | 678 } |
681 | 679 |
682 void WorkspaceManager::OnWindowRemovedFromWorkspace(Workspace* workspace, | 680 void WorkspaceManager::OnWindowRemovedFromWorkspace(Workspace* workspace, |
683 Window* child) { | 681 Window* child) { |
684 // Reappear the background which was hidden when a window is maximized. | |
685 if (wm::IsWindowMaximized(child) && workspace == active_workspace_ && | |
686 GetWindowState() != WORKSPACE_WINDOW_STATE_MAXIMIZED) { | |
687 RootWindowController* root_controller = GetRootWindowController( | |
688 workspace->window()->GetRootWindow()); | |
689 aura::Window* background = root_controller->GetContainer( | |
690 kShellWindowId_DesktopBackgroundContainer);; | |
691 ShowOrHideDesktopBackground( | |
692 background, | |
693 SWITCH_BACKGROUND_ONLY_WITHIN_DESKTOP, | |
694 base::TimeDelta(), | |
695 true); | |
696 } | |
697 | |
698 if (workspace->ShouldMoveToPending()) | 682 if (workspace->ShouldMoveToPending()) |
699 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_WINDOW_REMOVED); | 683 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_WINDOW_REMOVED); |
700 UpdateShelfVisibility(); | 684 UpdateShelfVisibility(); |
701 } | 685 } |
702 | 686 |
703 void WorkspaceManager::OnWorkspaceChildWindowVisibilityChanged( | 687 void WorkspaceManager::OnWorkspaceChildWindowVisibilityChanged( |
704 Workspace* workspace, | 688 Workspace* workspace, |
705 Window* child) { | 689 Window* child) { |
706 if (workspace->ShouldMoveToPending()) { | 690 if (workspace->ShouldMoveToPending()) { |
707 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_VISIBILITY_CHANGED); | 691 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_VISIBILITY_CHANGED); |
(...skipping 17 matching lines...) Expand all Loading... |
725 } | 709 } |
726 | 710 |
727 void WorkspaceManager::OnWorkspaceWindowShowStateChanged( | 711 void WorkspaceManager::OnWorkspaceWindowShowStateChanged( |
728 Workspace* workspace, | 712 Workspace* workspace, |
729 Window* child, | 713 Window* child, |
730 ui::WindowShowState last_show_state, | 714 ui::WindowShowState last_show_state, |
731 ui::Layer* old_layer) { | 715 ui::Layer* old_layer) { |
732 // |child| better still be in |workspace| else things have gone wrong. | 716 // |child| better still be in |workspace| else things have gone wrong. |
733 DCHECK_EQ(workspace, child->GetProperty(kWorkspaceKey)); | 717 DCHECK_EQ(workspace, child->GetProperty(kWorkspaceKey)); |
734 | 718 |
735 if (active_workspace_ == workspace) { | |
736 // Show/hide state of the background has to be set here since maximized | |
737 // window doesn't create its own workspace anymore. | |
738 RootWindowController* root_controller = GetRootWindowController( | |
739 contents_window_->GetRootWindow()); | |
740 aura::Window* background = root_controller->GetContainer( | |
741 kShellWindowId_DesktopBackgroundContainer); | |
742 if (wm::IsWindowMaximized(child)) { | |
743 ShowOrHideDesktopBackground( | |
744 background, | |
745 last_show_state == ui::SHOW_STATE_MINIMIZED ? | |
746 SWITCH_MAXIMIZED_OR_RESTORED : | |
747 SWITCH_BACKGROUND_ONLY_WITHIN_DESKTOP, | |
748 base::TimeDelta(), | |
749 false); | |
750 } else if (last_show_state == ui::SHOW_STATE_MAXIMIZED && | |
751 GetWindowState() != WORKSPACE_WINDOW_STATE_MAXIMIZED) { | |
752 ShowOrHideDesktopBackground( | |
753 background, | |
754 SWITCH_BACKGROUND_ONLY_WITHIN_DESKTOP, | |
755 base::TimeDelta(), | |
756 true); | |
757 } | |
758 } | |
759 | |
760 if (wm::IsWindowMinimized(child)) { | 719 if (wm::IsWindowMinimized(child)) { |
761 if (workspace->ShouldMoveToPending()) | 720 if (workspace->ShouldMoveToPending()) |
762 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_MINIMIZED); | 721 MoveWorkspaceToPendingOrDelete(workspace, NULL, SWITCH_MINIMIZED); |
763 DCHECK(!old_layer); | 722 DCHECK(!old_layer); |
764 } else { | 723 } else { |
765 // Set of cases to deal with: | 724 // Set of cases to deal with: |
766 // . More than one fullscreen window: move newly fullscreen window into | 725 // . More than one fullscreen window: move newly fullscreen window into |
767 // own workspace. | 726 // own workspace. |
768 // . One fullscreen window and not in a fullscreen workspace: move window | 727 // . One fullscreen window and not in a fullscreen workspace: move window |
769 // into own workspace. | 728 // into own workspace. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 new_workspace->window()->Show(); | 814 new_workspace->window()->Show(); |
856 ReparentWindow(window, new_workspace->window(), NULL); | 815 ReparentWindow(window, new_workspace->window(), NULL); |
857 if (is_active) { | 816 if (is_active) { |
858 SetActiveWorkspace(new_workspace, SWITCH_TRACKED_BY_WORKSPACE_CHANGED, | 817 SetActiveWorkspace(new_workspace, SWITCH_TRACKED_BY_WORKSPACE_CHANGED, |
859 base::TimeDelta()); | 818 base::TimeDelta()); |
860 } | 819 } |
861 } | 820 } |
862 | 821 |
863 } // namespace internal | 822 } // namespace internal |
864 } // namespace ash | 823 } // namespace ash |
OLD | NEW |