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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
861 if (wm_shelf_->IsHorizontalAlignment()) | 861 if (wm_shelf_->IsHorizontalAlignment()) |
862 show_shelf_region_in_screen.set_height(kMaxAutoHideShowShelfRegionSize); | 862 show_shelf_region_in_screen.set_height(kMaxAutoHideShowShelfRegionSize); |
863 else | 863 else |
864 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); | 864 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); |
865 | 865 |
866 // TODO: Figure out if we need any special handling when the keyboard is | 866 // TODO: Figure out if we need any special handling when the keyboard is |
867 // visible. | 867 // visible. |
868 return show_shelf_region_in_screen; | 868 return show_shelf_region_in_screen; |
869 } | 869 } |
870 | 870 |
871 bool ShelfLayoutManager::HasVisibleWindow() const { | |
872 const int64_t shelf_display_id = | |
873 WmWindow::Get(shelf_widget_->GetNativeWindow()) | |
874 ->GetDisplayNearestWindow() | |
875 .id(); | |
876 const std::vector<WmWindow*> windows = | |
877 Shell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal(); | |
878 // Process the window list and check if there are any visible windows. | |
879 // Ignore app list windows that may be animating to hide after dismissal. | |
880 bool visible_window = false; | |
881 for (size_t i = 0; i < windows.size(); ++i) { | |
882 if (windows[i] && windows[i]->IsVisible() && !IsAppListWindow(windows[i]) && | |
883 !windows[i]->GetWindowState()->IsMinimized() && | |
884 windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) { | |
885 visible_window = true; | |
xiaoyinh(OOO Sep 11-29)
2017/04/21 04:13:12
nit: Just return true here, and return false at th
minch1
2017/04/21 16:42:42
good point. Thanks.
| |
886 break; | |
887 } | |
888 } | |
889 return visible_window; | |
890 } | |
891 | |
871 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( | 892 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( |
872 ShelfVisibilityState visibility_state) const { | 893 ShelfVisibilityState visibility_state) const { |
873 if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfInitialized()) | 894 if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfInitialized()) |
874 return SHELF_AUTO_HIDE_HIDDEN; | 895 return SHELF_AUTO_HIDE_HIDDEN; |
875 | 896 |
876 if (shelf_widget_->IsShowingAppList()) | 897 if (shelf_widget_->IsShowingAppList()) |
877 return SHELF_AUTO_HIDE_SHOWN; | 898 return SHELF_AUTO_HIDE_SHOWN; |
878 | 899 |
879 if (shelf_widget_->status_area_widget() && | 900 if (shelf_widget_->status_area_widget() && |
880 shelf_widget_->status_area_widget()->ShouldShowShelf()) | 901 shelf_widget_->status_area_widget()->ShouldShowShelf()) |
881 return SHELF_AUTO_HIDE_SHOWN; | 902 return SHELF_AUTO_HIDE_SHOWN; |
882 | 903 |
883 if (shelf_widget_->IsShowingContextMenu()) | 904 if (shelf_widget_->IsShowingContextMenu()) |
884 return SHELF_AUTO_HIDE_SHOWN; | 905 return SHELF_AUTO_HIDE_SHOWN; |
885 | 906 |
886 if (shelf_widget_->IsShowingOverflowBubble()) | 907 if (shelf_widget_->IsShowingOverflowBubble()) |
887 return SHELF_AUTO_HIDE_SHOWN; | 908 return SHELF_AUTO_HIDE_SHOWN; |
888 | 909 |
889 if (shelf_widget_->IsActive() || | 910 if (shelf_widget_->IsActive() || |
890 (shelf_widget_->status_area_widget() && | 911 (shelf_widget_->status_area_widget() && |
891 shelf_widget_->status_area_widget()->IsActive())) | 912 shelf_widget_->status_area_widget()->IsActive())) |
892 return SHELF_AUTO_HIDE_SHOWN; | 913 return SHELF_AUTO_HIDE_SHOWN; |
893 | 914 |
894 const int64_t shelf_display_id = | |
895 WmWindow::Get(shelf_widget_->GetNativeWindow()) | |
896 ->GetDisplayNearestWindow() | |
897 .id(); | |
898 const std::vector<WmWindow*> windows = | |
899 Shell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal(); | |
900 // Process the window list and check if there are any visible windows. | |
901 // Ignore app list windows that may be animating to hide after dismissal. | |
902 bool visible_window = false; | |
903 for (size_t i = 0; i < windows.size(); ++i) { | |
904 if (windows[i] && windows[i]->IsVisible() && !IsAppListWindow(windows[i]) && | |
905 !windows[i]->GetWindowState()->IsMinimized() && | |
906 windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) { | |
907 visible_window = true; | |
908 break; | |
909 } | |
910 } | |
911 // If there are no visible windows do not hide the shelf. | 915 // If there are no visible windows do not hide the shelf. |
912 if (!visible_window) | 916 if (!HasVisibleWindow()) |
913 return SHELF_AUTO_HIDE_SHOWN; | 917 return SHELF_AUTO_HIDE_SHOWN; |
914 | 918 |
915 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) | 919 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) |
916 return gesture_drag_auto_hide_state_; | 920 return gesture_drag_auto_hide_state_; |
917 | 921 |
918 // Don't show if the user is dragging the mouse. | 922 // Don't show if the user is dragging the mouse. |
919 if (in_mouse_drag_) | 923 if (in_mouse_drag_) |
920 return SHELF_AUTO_HIDE_HIDDEN; | 924 return SHELF_AUTO_HIDE_HIDDEN; |
921 | 925 |
922 // Ignore the mouse position if mouse events are disabled. | 926 // Ignore the mouse position if mouse events are disabled. |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1128 : SHELF_AUTO_HIDE_SHOWN; | 1132 : SHELF_AUTO_HIDE_SHOWN; |
1129 ShelfAutoHideBehavior new_auto_hide_behavior = | 1133 ShelfAutoHideBehavior new_auto_hide_behavior = |
1130 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN | 1134 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN |
1131 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER | 1135 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER |
1132 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | 1136 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
1133 | 1137 |
1134 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide | 1138 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide |
1135 // behavior affects neither the visibility state nor the auto hide state. Set | 1139 // behavior affects neither the visibility state nor the auto hide state. Set |
1136 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto | 1140 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto |
1137 // hide state to |gesture_drag_auto_hide_state_|. | 1141 // hide state to |gesture_drag_auto_hide_state_|. |
1142 // Since the shelf will always be shown when there are no windows opend. There | |
xiaoyinh(OOO Sep 11-29)
2017/04/21 04:13:12
nit: s/opend/opened
| |
1143 // is no point to change the auto hide behavior when swiping down / up on the | |
1144 // shelf. | |
1138 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; | 1145 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; |
1139 if (wm_shelf_->auto_hide_behavior() != new_auto_hide_behavior) | 1146 if (wm_shelf_->auto_hide_behavior() != new_auto_hide_behavior && |
1147 HasVisibleWindow()) | |
1140 wm_shelf_->SetAutoHideBehavior(new_auto_hide_behavior); | 1148 wm_shelf_->SetAutoHideBehavior(new_auto_hide_behavior); |
1141 else | 1149 else |
1142 UpdateVisibilityState(); | 1150 UpdateVisibilityState(); |
1143 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1151 gesture_drag_status_ = GESTURE_DRAG_NONE; |
1144 } | 1152 } |
1145 | 1153 |
1146 void ShelfLayoutManager::CancelGestureDrag() { | 1154 void ShelfLayoutManager::CancelGestureDrag() { |
1147 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; | 1155 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; |
1148 UpdateVisibilityState(); | 1156 UpdateVisibilityState(); |
1149 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1157 gesture_drag_status_ = GESTURE_DRAG_NONE; |
1150 } | 1158 } |
1151 | 1159 |
1152 } // namespace ash | 1160 } // namespace ash |
OLD | NEW |