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

Side by Side 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: Fix comments. Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 WmWindow* root =
869 WmWindow::Get(shelf_widget_->GetNativeWindow())->GetRootWindow();
870 const std::vector<WmWindow*> windows =
871 Shell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal();
872 // Process the window list and check if there are any visible windows.
873 // Ignore app list windows that may be animating to hide after dismissal.
874 for (auto* window : windows) {
875 if (window->IsVisible() && !IsAppListWindow(window) &&
876 root->Contains(window)) {
877 return true;
878 }
879 }
880 return false;
881 }
882
867 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( 883 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
868 ShelfVisibilityState visibility_state) const { 884 ShelfVisibilityState visibility_state) const {
869 if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfInitialized()) 885 if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfInitialized())
870 return SHELF_AUTO_HIDE_HIDDEN; 886 return SHELF_AUTO_HIDE_HIDDEN;
871 887
872 if (shelf_widget_->IsShowingAppList()) 888 if (shelf_widget_->IsShowingAppList())
873 return SHELF_AUTO_HIDE_SHOWN; 889 return SHELF_AUTO_HIDE_SHOWN;
874 890
875 if (shelf_widget_->status_area_widget() && 891 if (shelf_widget_->status_area_widget() &&
876 shelf_widget_->status_area_widget()->ShouldShowShelf()) 892 shelf_widget_->status_area_widget()->ShouldShowShelf())
877 return SHELF_AUTO_HIDE_SHOWN; 893 return SHELF_AUTO_HIDE_SHOWN;
878 894
879 if (shelf_widget_->IsShowingContextMenu()) 895 if (shelf_widget_->IsShowingContextMenu())
880 return SHELF_AUTO_HIDE_SHOWN; 896 return SHELF_AUTO_HIDE_SHOWN;
881 897
882 if (shelf_widget_->IsShowingOverflowBubble()) 898 if (shelf_widget_->IsShowingOverflowBubble())
883 return SHELF_AUTO_HIDE_SHOWN; 899 return SHELF_AUTO_HIDE_SHOWN;
884 900
885 if (shelf_widget_->IsActive() || 901 if (shelf_widget_->IsActive() ||
886 (shelf_widget_->status_area_widget() && 902 (shelf_widget_->status_area_widget() &&
887 shelf_widget_->status_area_widget()->IsActive())) 903 shelf_widget_->status_area_widget()->IsActive()))
888 return SHELF_AUTO_HIDE_SHOWN; 904 return SHELF_AUTO_HIDE_SHOWN;
889 905
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. 906 // If there are no visible windows do not hide the shelf.
908 if (!visible_window) 907 if (!HasVisibleWindow())
909 return SHELF_AUTO_HIDE_SHOWN; 908 return SHELF_AUTO_HIDE_SHOWN;
910 909
911 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) 910 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS)
912 return gesture_drag_auto_hide_state_; 911 return gesture_drag_auto_hide_state_;
913 912
914 // Don't show if the user is dragging the mouse. 913 // Don't show if the user is dragging the mouse.
915 if (in_mouse_drag_) 914 if (in_mouse_drag_)
916 return SHELF_AUTO_HIDE_HIDDEN; 915 return SHELF_AUTO_HIDE_HIDDEN;
917 916
918 // Ignore the mouse position if mouse events are disabled. 917 // Ignore the mouse position if mouse events are disabled.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 ? SHELF_AUTO_HIDE_HIDDEN 1120 ? SHELF_AUTO_HIDE_HIDDEN
1122 : SHELF_AUTO_HIDE_SHOWN; 1121 : SHELF_AUTO_HIDE_SHOWN;
1123 ShelfAutoHideBehavior new_auto_hide_behavior = 1122 ShelfAutoHideBehavior new_auto_hide_behavior =
1124 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN 1123 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN
1125 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER 1124 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER
1126 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; 1125 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
1127 1126
1128 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide 1127 // 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 1128 // 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 1129 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto
1131 // hide state to |gesture_drag_auto_hide_state_|. 1130 // hide state to |gesture_drag_auto_hide_state_|. Only change the auto-hide
1131 // behavior if there is at least one window visible.
1132 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; 1132 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS;
1133 if (wm_shelf_->auto_hide_behavior() != new_auto_hide_behavior) 1133 if (wm_shelf_->auto_hide_behavior() != new_auto_hide_behavior &&
1134 HasVisibleWindow()) {
1134 wm_shelf_->SetAutoHideBehavior(new_auto_hide_behavior); 1135 wm_shelf_->SetAutoHideBehavior(new_auto_hide_behavior);
1135 else 1136 } else {
1136 UpdateVisibilityState(); 1137 UpdateVisibilityState();
1138 }
1137 gesture_drag_status_ = GESTURE_DRAG_NONE; 1139 gesture_drag_status_ = GESTURE_DRAG_NONE;
1138 } 1140 }
1139 1141
1140 void ShelfLayoutManager::CancelGestureDrag() { 1142 void ShelfLayoutManager::CancelGestureDrag() {
1141 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; 1143 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS;
1142 UpdateVisibilityState(); 1144 UpdateVisibilityState();
1143 gesture_drag_status_ = GESTURE_DRAG_NONE; 1145 gesture_drag_status_ = GESTURE_DRAG_NONE;
1144 } 1146 }
1145 1147
1146 } // namespace ash 1148 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698