| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/common/wm/dock/docked_window_layout_manager.h" | 5 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/shelf/shelf_background_animator.h" | 8 #include "ash/common/shelf/shelf_background_animator.h" |
| 9 #include "ash/common/shelf/shelf_background_animator_observer.h" | 9 #include "ash/common/shelf/shelf_background_animator_observer.h" |
| 10 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 return; | 763 return; |
| 764 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds); | 764 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds); |
| 765 if (IsPopupOrTransient(child)) | 765 if (IsPopupOrTransient(child)) |
| 766 return; | 766 return; |
| 767 // Whenever one of our windows is moved or resized enforce layout. | 767 // Whenever one of our windows is moved or resized enforce layout. |
| 768 if (shelf_) | 768 if (shelf_) |
| 769 shelf_->UpdateVisibilityState(); | 769 shelf_->UpdateVisibilityState(); |
| 770 } | 770 } |
| 771 | 771 |
| 772 //////////////////////////////////////////////////////////////////////////////// | 772 //////////////////////////////////////////////////////////////////////////////// |
| 773 // DockedWindowLayoutManager, ash::ShellObserver implementation: | 773 // DockedWindowLayoutManager, WmRootWindowControllerObserver implementation: |
| 774 | 774 |
| 775 void DockedWindowLayoutManager::OnWorkAreaChanged() { | 775 void DockedWindowLayoutManager::OnWorkAreaChanged() { |
| 776 Relayout(); | 776 Relayout(); |
| 777 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); | 777 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); |
| 778 MaybeMinimizeChildrenExcept(dragged_window_); | 778 MaybeMinimizeChildrenExcept(dragged_window_); |
| 779 } | 779 } |
| 780 | 780 |
| 781 void DockedWindowLayoutManager::OnFullscreenStateChanged(bool is_fullscreen) { | |
| 782 // Entering fullscreen mode (including immersive) hides docked windows. | |
| 783 in_fullscreen_ = root_window_controller_->GetWorkspaceWindowState() == | |
| 784 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; | |
| 785 { | |
| 786 // prevent Relayout from getting called multiple times during this | |
| 787 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | |
| 788 // Use a copy of children array because a call to MinimizeDockedWindow or | |
| 789 // RestoreDockedWindow can change order. | |
| 790 for (WmWindow* window : dock_container_->GetChildren()) { | |
| 791 if (IsPopupOrTransient(window)) | |
| 792 continue; | |
| 793 wm::WindowState* window_state = window->GetWindowState(); | |
| 794 if (in_fullscreen_) { | |
| 795 if (window->IsVisible()) | |
| 796 MinimizeDockedWindow(window_state); | |
| 797 } else { | |
| 798 if (!window_state->IsMinimized()) | |
| 799 RestoreDockedWindow(window_state); | |
| 800 } | |
| 801 } | |
| 802 } | |
| 803 Relayout(); | |
| 804 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | |
| 805 } | |
| 806 | |
| 807 void DockedWindowLayoutManager::OnShelfAlignmentChanged() { | 781 void DockedWindowLayoutManager::OnShelfAlignmentChanged() { |
| 808 if (!shelf_ || alignment_ == DOCKED_ALIGNMENT_NONE) | 782 if (!shelf_ || alignment_ == DOCKED_ALIGNMENT_NONE) |
| 809 return; | 783 return; |
| 810 | 784 |
| 811 // Do not allow shelf and dock on the same side. Switch side that | 785 // Do not allow shelf and dock on the same side. Switch side that |
| 812 // the dock is attached to and move all dock windows to that new side. | 786 // the dock is attached to and move all dock windows to that new side. |
| 813 ShelfAlignment shelf_alignment = shelf_->GetAlignment(); | 787 ShelfAlignment shelf_alignment = shelf_->GetAlignment(); |
| 814 if (alignment_ == DOCKED_ALIGNMENT_LEFT && | 788 if (alignment_ == DOCKED_ALIGNMENT_LEFT && |
| 815 shelf_alignment == SHELF_ALIGNMENT_LEFT) { | 789 shelf_alignment == SHELF_ALIGNMENT_LEFT) { |
| 816 alignment_ = DOCKED_ALIGNMENT_RIGHT; | 790 alignment_ = DOCKED_ALIGNMENT_RIGHT; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 } | 889 } |
| 916 | 890 |
| 917 //////////////////////////////////////////////////////////////////////////////// | 891 //////////////////////////////////////////////////////////////////////////////// |
| 918 // DockedWindowLayoutManager, ShellObserver implementation: | 892 // DockedWindowLayoutManager, ShellObserver implementation: |
| 919 | 893 |
| 920 void DockedWindowLayoutManager::OnShelfAlignmentChanged(WmWindow* root_window) { | 894 void DockedWindowLayoutManager::OnShelfAlignmentChanged(WmWindow* root_window) { |
| 921 } | 895 } |
| 922 | 896 |
| 923 void DockedWindowLayoutManager::OnFullscreenStateChanged( | 897 void DockedWindowLayoutManager::OnFullscreenStateChanged( |
| 924 bool is_fullscreen, | 898 bool is_fullscreen, |
| 925 WmWindow* root_window) {} | 899 WmWindow* root_window) { |
| 900 if (root_window != dock_container_->GetRootWindow()) |
| 901 return; |
| 902 |
| 903 // Entering fullscreen mode (including immersive) hides docked windows. |
| 904 in_fullscreen_ = root_window_controller_->GetWorkspaceWindowState() == |
| 905 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; |
| 906 { |
| 907 // prevent Relayout from getting called multiple times during this |
| 908 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| 909 // Use a copy of children array because a call to MinimizeDockedWindow or |
| 910 // RestoreDockedWindow can change order. |
| 911 for (WmWindow* window : dock_container_->GetChildren()) { |
| 912 if (IsPopupOrTransient(window)) |
| 913 continue; |
| 914 wm::WindowState* window_state = window->GetWindowState(); |
| 915 if (in_fullscreen_) { |
| 916 if (window->IsVisible()) |
| 917 MinimizeDockedWindow(window_state); |
| 918 } else { |
| 919 if (!window_state->IsMinimized()) |
| 920 RestoreDockedWindow(window_state); |
| 921 } |
| 922 } |
| 923 } |
| 924 Relayout(); |
| 925 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| 926 } |
| 926 | 927 |
| 927 void DockedWindowLayoutManager::OnOverviewModeStarting() { | 928 void DockedWindowLayoutManager::OnOverviewModeStarting() { |
| 928 in_overview_ = true; | 929 in_overview_ = true; |
| 929 if (!ash::MaterialDesignController::IsOverviewMaterial()) | 930 if (!ash::MaterialDesignController::IsOverviewMaterial()) |
| 930 return; | 931 return; |
| 931 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 932 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| 932 } | 933 } |
| 933 | 934 |
| 934 void DockedWindowLayoutManager::OnOverviewModeEnded() { | 935 void DockedWindowLayoutManager::OnOverviewModeEnded() { |
| 935 in_overview_ = false; | 936 in_overview_ = false; |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 | 1375 |
| 1375 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1376 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
| 1376 const gfx::Rect& keyboard_bounds) { | 1377 const gfx::Rect& keyboard_bounds) { |
| 1377 // This bounds change will have caused a change to the Shelf which does not | 1378 // This bounds change will have caused a change to the Shelf which does not |
| 1378 // propagate automatically to this class, so manually recalculate bounds. | 1379 // propagate automatically to this class, so manually recalculate bounds. |
| 1379 Relayout(); | 1380 Relayout(); |
| 1380 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1381 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
| 1381 } | 1382 } |
| 1382 | 1383 |
| 1383 } // namespace ash | 1384 } // namespace ash |
| OLD | NEW |