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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 if (wm_shelf_->IsHorizontalAlignment()) | 857 if (wm_shelf_->IsHorizontalAlignment()) |
858 show_shelf_region_in_screen.set_height(kMaxAutoHideShowShelfRegionSize); | 858 show_shelf_region_in_screen.set_height(kMaxAutoHideShowShelfRegionSize); |
859 else | 859 else |
860 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); | 860 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); |
861 | 861 |
862 // TODO: Figure out if we need any special handling when the keyboard is | 862 // TODO: Figure out if we need any special handling when the keyboard is |
863 // visible. | 863 // visible. |
864 return show_shelf_region_in_screen; | 864 return show_shelf_region_in_screen; |
865 } | 865 } |
866 | 866 |
867 bool ShelfLayoutManager::HasVisibleWindow() const { | |
868 const int64_t shelf_display_id = | |
869 WmWindow::Get(shelf_widget_->GetNativeWindow()) | |
870 ->GetDisplayNearestWindow() | |
871 .id(); | |
872 const std::vector<WmWindow*> windows = | |
873 Shell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal(); | |
874 // Process the window list and check if there are any visible windows. | |
875 // Ignore app list windows that may be animating to hide after dismissal. | |
876 for (size_t i = 0; i < windows.size(); ++i) { | |
oshima
2017/04/25 18:02:16
auto* window : windows
| |
877 if (windows[i] && windows[i]->IsVisible() && !IsAppListWindow(windows[i]) && | |
oshima
2017/04/25 18:02:16
the list shouldn't contain null. Was this null ch
minch1
2017/04/25 23:43:08
Checked line 873 seems it will not contains null w
oshima
2017/04/27 01:53:55
It shouldn't have, as it only returns activatable
| |
878 !windows[i]->GetWindowState()->IsMinimized() && | |
oshima
2017/04/25 18:02:16
IIRC, minimized window isn't visible, no?
minch1
2017/04/25 23:43:08
Checked BuildWindowListsIgnoredModal() in line 873
oshima
2017/04/27 01:53:54
Yes, a minimized window can be activated.
| |
879 windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) { | |
880 return true; | |
881 } | |
882 } | |
883 return false; | |
884 } | |
885 | |
867 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( | 886 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( |
868 ShelfVisibilityState visibility_state) const { | 887 ShelfVisibilityState visibility_state) const { |
869 if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfInitialized()) | 888 if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfInitialized()) |
870 return SHELF_AUTO_HIDE_HIDDEN; | 889 return SHELF_AUTO_HIDE_HIDDEN; |
871 | 890 |
872 if (shelf_widget_->IsShowingAppList()) | 891 if (shelf_widget_->IsShowingAppList()) |
873 return SHELF_AUTO_HIDE_SHOWN; | 892 return SHELF_AUTO_HIDE_SHOWN; |
874 | 893 |
875 if (shelf_widget_->status_area_widget() && | 894 if (shelf_widget_->status_area_widget() && |
876 shelf_widget_->status_area_widget()->ShouldShowShelf()) | 895 shelf_widget_->status_area_widget()->ShouldShowShelf()) |
877 return SHELF_AUTO_HIDE_SHOWN; | 896 return SHELF_AUTO_HIDE_SHOWN; |
878 | 897 |
879 if (shelf_widget_->IsShowingContextMenu()) | 898 if (shelf_widget_->IsShowingContextMenu()) |
880 return SHELF_AUTO_HIDE_SHOWN; | 899 return SHELF_AUTO_HIDE_SHOWN; |
881 | 900 |
882 if (shelf_widget_->IsShowingOverflowBubble()) | 901 if (shelf_widget_->IsShowingOverflowBubble()) |
883 return SHELF_AUTO_HIDE_SHOWN; | 902 return SHELF_AUTO_HIDE_SHOWN; |
884 | 903 |
885 if (shelf_widget_->IsActive() || | 904 if (shelf_widget_->IsActive() || |
886 (shelf_widget_->status_area_widget() && | 905 (shelf_widget_->status_area_widget() && |
887 shelf_widget_->status_area_widget()->IsActive())) | 906 shelf_widget_->status_area_widget()->IsActive())) |
888 return SHELF_AUTO_HIDE_SHOWN; | 907 return SHELF_AUTO_HIDE_SHOWN; |
889 | 908 |
890 const int64_t shelf_display_id = | |
891 WmWindow::Get(shelf_widget_->GetNativeWindow()) | |
892 ->GetDisplayNearestWindow() | |
893 .id(); | |
894 const std::vector<WmWindow*> windows = | |
895 Shell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal(); | |
896 // Process the window list and check if there are any visible windows. | |
897 // Ignore app list windows that may be animating to hide after dismissal. | |
898 bool visible_window = false; | |
899 for (size_t i = 0; i < windows.size(); ++i) { | |
900 if (windows[i] && windows[i]->IsVisible() && !IsAppListWindow(windows[i]) && | |
901 !windows[i]->GetWindowState()->IsMinimized() && | |
902 windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) { | |
903 visible_window = true; | |
904 break; | |
905 } | |
906 } | |
907 // If there are no visible windows do not hide the shelf. | 909 // If there are no visible windows do not hide the shelf. |
908 if (!visible_window) | 910 if (!HasVisibleWindow()) |
909 return SHELF_AUTO_HIDE_SHOWN; | 911 return SHELF_AUTO_HIDE_SHOWN; |
910 | 912 |
911 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) | 913 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) |
912 return gesture_drag_auto_hide_state_; | 914 return gesture_drag_auto_hide_state_; |
913 | 915 |
914 // Don't show if the user is dragging the mouse. | 916 // Don't show if the user is dragging the mouse. |
915 if (in_mouse_drag_) | 917 if (in_mouse_drag_) |
916 return SHELF_AUTO_HIDE_HIDDEN; | 918 return SHELF_AUTO_HIDE_HIDDEN; |
917 | 919 |
918 // Ignore the mouse position if mouse events are disabled. | 920 // Ignore the mouse position if mouse events are disabled. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1122 : SHELF_AUTO_HIDE_SHOWN; | 1124 : SHELF_AUTO_HIDE_SHOWN; |
1123 ShelfAutoHideBehavior new_auto_hide_behavior = | 1125 ShelfAutoHideBehavior new_auto_hide_behavior = |
1124 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN | 1126 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN |
1125 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER | 1127 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER |
1126 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | 1128 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
1127 | 1129 |
1128 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide | 1130 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide |
1129 // behavior affects neither the visibility state nor the auto hide state. Set | 1131 // behavior affects neither the visibility state nor the auto hide state. Set |
1130 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto | 1132 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto |
1131 // hide state to |gesture_drag_auto_hide_state_|. | 1133 // hide state to |gesture_drag_auto_hide_state_|. |
1134 // Since the shelf will always be shown when there are no windows opened. | |
1135 // There is no point to change the auto hide behavior when swiping down / up | |
1136 // on the shelf. | |
tdanderson
2017/04/24 16:57:23
Based on this comment, shouldn't line 1139 instead
minch1
2017/04/24 17:42:40
Line 1140 will call SetAutoHideBehavior() which wi
tdanderson
2017/04/25 13:43:06
Ah yes, I was mis-reading the code, sorry.
As an
| |
1132 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; | 1137 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; |
1133 if (wm_shelf_->auto_hide_behavior() != new_auto_hide_behavior) | 1138 if (wm_shelf_->auto_hide_behavior() != new_auto_hide_behavior && |
1139 HasVisibleWindow()) | |
tdanderson
2017/04/24 16:57:23
nit: use {} after the if and else since the if con
| |
1134 wm_shelf_->SetAutoHideBehavior(new_auto_hide_behavior); | 1140 wm_shelf_->SetAutoHideBehavior(new_auto_hide_behavior); |
1135 else | 1141 else |
1136 UpdateVisibilityState(); | 1142 UpdateVisibilityState(); |
1137 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1143 gesture_drag_status_ = GESTURE_DRAG_NONE; |
1138 } | 1144 } |
1139 | 1145 |
1140 void ShelfLayoutManager::CancelGestureDrag() { | 1146 void ShelfLayoutManager::CancelGestureDrag() { |
1141 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; | 1147 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; |
1142 UpdateVisibilityState(); | 1148 UpdateVisibilityState(); |
1143 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1149 gesture_drag_status_ = GESTURE_DRAG_NONE; |
1144 } | 1150 } |
1145 | 1151 |
1146 } // namespace ash | 1152 } // namespace ash |
OLD | NEW |