Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: ash/shelf/shelf_layout_manager.cc

Issue 2824233003: Disallow toggling of shelf auto-hide with touch when there are no windows open (Closed)
Patch Set: Add UT. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/shelf/shelf_layout_manager.cc
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index a054cc94e6ff9297d5b94c429d4f80cc458062f9..0f1ec6871549ec61403dfc434544e7b26d460bba 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -868,6 +868,27 @@ gfx::Rect ShelfLayoutManager::GetAutoHideShowShelfRegionInScreen() const {
return show_shelf_region_in_screen;
}
+bool ShelfLayoutManager::HasVisibleWindow() const {
+ const int64_t shelf_display_id =
+ WmWindow::Get(shelf_widget_->GetNativeWindow())
+ ->GetDisplayNearestWindow()
+ .id();
+ const std::vector<WmWindow*> windows =
+ Shell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal();
+ // Process the window list and check if there are any visible windows.
+ // Ignore app list windows that may be animating to hide after dismissal.
+ bool visible_window = false;
+ for (size_t i = 0; i < windows.size(); ++i) {
+ if (windows[i] && windows[i]->IsVisible() && !IsAppListWindow(windows[i]) &&
+ !windows[i]->GetWindowState()->IsMinimized() &&
+ windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) {
+ 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.
+ break;
+ }
+ }
+ return visible_window;
+}
+
ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
ShelfVisibilityState visibility_state) const {
if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfInitialized())
@@ -891,25 +912,8 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
shelf_widget_->status_area_widget()->IsActive()))
return SHELF_AUTO_HIDE_SHOWN;
- const int64_t shelf_display_id =
- WmWindow::Get(shelf_widget_->GetNativeWindow())
- ->GetDisplayNearestWindow()
- .id();
- const std::vector<WmWindow*> windows =
- Shell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal();
- // Process the window list and check if there are any visible windows.
- // Ignore app list windows that may be animating to hide after dismissal.
- bool visible_window = false;
- for (size_t i = 0; i < windows.size(); ++i) {
- if (windows[i] && windows[i]->IsVisible() && !IsAppListWindow(windows[i]) &&
- !windows[i]->GetWindowState()->IsMinimized() &&
- windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) {
- visible_window = true;
- break;
- }
- }
// If there are no visible windows do not hide the shelf.
- if (!visible_window)
+ if (!HasVisibleWindow())
return SHELF_AUTO_HIDE_SHOWN;
if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS)
@@ -1135,8 +1139,12 @@ void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
// behavior affects neither the visibility state nor the auto hide state. Set
// |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto
// hide state to |gesture_drag_auto_hide_state_|.
+ // 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
+ // is no point to change the auto hide behavior when swiping down / up on the
+ // shelf.
gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS;
- if (wm_shelf_->auto_hide_behavior() != new_auto_hide_behavior)
+ if (wm_shelf_->auto_hide_behavior() != new_auto_hide_behavior &&
+ HasVisibleWindow())
wm_shelf_->SetAutoHideBehavior(new_auto_hide_behavior);
else
UpdateVisibilityState();

Powered by Google App Engine
This is Rietveld 408576698