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

Side by Side Diff: ash/common/shelf/shelf_layout_manager.cc

Issue 2534953006: Fix shelf auto-hide calculation for app-list visibility. (Closed)
Patch Set: try another approach. Created 4 years 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
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/common/shelf/shelf_layout_manager.h" 5 #include "ash/common/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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // |kMaxAutoHideShowShelfRegionSize| refers to the maximum size of the region 64 // |kMaxAutoHideShowShelfRegionSize| refers to the maximum size of the region
65 // from the right edge of the primary display which can trigger showing the 65 // from the right edge of the primary display which can trigger showing the
66 // auto hidden shelf. The region is used to make it easier to trigger showing 66 // auto hidden shelf. The region is used to make it easier to trigger showing
67 // the auto hidden shelf when the shelf is on the boundary between displays. 67 // the auto hidden shelf when the shelf is on the boundary between displays.
68 const int kMaxAutoHideShowShelfRegionSize = 10; 68 const int kMaxAutoHideShowShelfRegionSize = 10;
69 69
70 ui::Layer* GetLayer(views::Widget* widget) { 70 ui::Layer* GetLayer(views::Widget* widget) {
71 return widget->GetNativeView()->layer(); 71 return widget->GetNativeView()->layer();
72 } 72 }
73 73
74 // Returns true if the window is in the app list window container.
75 bool IsAppListWindow(WmWindow* window) {
76 return window->GetParent() &&
77 window->GetParent()->GetShellWindowId() ==
78 kShellWindowId_AppListContainer;
79 }
80
74 } // namespace 81 } // namespace
75 82
76 // ShelfLayoutManager::UpdateShelfObserver ------------------------------------- 83 // ShelfLayoutManager::UpdateShelfObserver -------------------------------------
77 84
78 // UpdateShelfObserver is used to delay updating the background until the 85 // UpdateShelfObserver is used to delay updating the background until the
79 // animation completes. 86 // animation completes.
80 class ShelfLayoutManager::UpdateShelfObserver 87 class ShelfLayoutManager::UpdateShelfObserver
81 : public ui::ImplicitAnimationObserver { 88 : public ui::ImplicitAnimationObserver {
82 public: 89 public:
83 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) { 90 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) {
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // TODO: Figure out if we need any special handling when the keyboard is 830 // TODO: Figure out if we need any special handling when the keyboard is
824 // visible. 831 // visible.
825 return show_shelf_region_in_screen; 832 return show_shelf_region_in_screen;
826 } 833 }
827 834
828 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( 835 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
829 ShelfVisibilityState visibility_state) const { 836 ShelfVisibilityState visibility_state) const {
830 if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfInitialized()) 837 if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfInitialized())
831 return SHELF_AUTO_HIDE_HIDDEN; 838 return SHELF_AUTO_HIDE_HIDDEN;
832 839
833 const int64_t shelf_display_id = WmLookup::Get() 840 if (shelf_widget_->IsShowingAppList())
834 ->GetWindowForWidget(shelf_widget_) 841 return SHELF_AUTO_HIDE_SHOWN;
835 ->GetDisplayNearestWindow()
836 .id();
837
838 // Unhide the shelf only on the active screen when the AppList is shown
839 // (crbug.com/312445).
840 if (WmShell::Get()->GetAppListTargetVisibility()) {
841 WmWindow* window = WmShell::Get()->GetActiveWindow();
842 if (window && window->GetDisplayNearestWindow().id() == shelf_display_id)
843 return SHELF_AUTO_HIDE_SHOWN;
844 }
845 842
846 if (shelf_widget_->status_area_widget() && 843 if (shelf_widget_->status_area_widget() &&
847 shelf_widget_->status_area_widget()->ShouldShowShelf()) 844 shelf_widget_->status_area_widget()->ShouldShowShelf())
848 return SHELF_AUTO_HIDE_SHOWN; 845 return SHELF_AUTO_HIDE_SHOWN;
849 846
850 if (shelf_widget_->IsShowingContextMenu()) 847 if (shelf_widget_->IsShowingContextMenu())
851 return SHELF_AUTO_HIDE_SHOWN; 848 return SHELF_AUTO_HIDE_SHOWN;
852 849
853 if (shelf_widget_->IsShowingOverflowBubble()) 850 if (shelf_widget_->IsShowingOverflowBubble())
854 return SHELF_AUTO_HIDE_SHOWN; 851 return SHELF_AUTO_HIDE_SHOWN;
855 852
856 if (shelf_widget_->IsActive() || 853 if (shelf_widget_->IsActive() ||
857 (shelf_widget_->status_area_widget() && 854 (shelf_widget_->status_area_widget() &&
858 shelf_widget_->status_area_widget()->IsActive())) 855 shelf_widget_->status_area_widget()->IsActive()))
859 return SHELF_AUTO_HIDE_SHOWN; 856 return SHELF_AUTO_HIDE_SHOWN;
860 857
858 const int64_t shelf_display_id = WmLookup::Get()
859 ->GetWindowForWidget(shelf_widget_)
860 ->GetDisplayNearestWindow()
861 .id();
861 const std::vector<WmWindow*> windows = 862 const std::vector<WmWindow*> windows =
862 WmShell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal(); 863 WmShell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal();
863
864 // Process the window list and check if there are any visible windows. 864 // Process the window list and check if there are any visible windows.
865 // Ignore app list windows that may be animating to hide after dismissal.
865 bool visible_window = false; 866 bool visible_window = false;
866 for (size_t i = 0; i < windows.size(); ++i) { 867 for (size_t i = 0; i < windows.size(); ++i) {
867 if (windows[i] && windows[i]->IsVisible() && 868 if (windows[i] && windows[i]->IsVisible() && !IsAppListWindow(windows[i]) &&
868 !windows[i]->GetWindowState()->IsMinimized() && 869 !windows[i]->GetWindowState()->IsMinimized() &&
869 windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) { 870 windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) {
870 visible_window = true; 871 visible_window = true;
871 break; 872 break;
872 } 873 }
873 } 874 }
874 // If there are no visible windows do not hide the shelf. 875 // If there are no visible windows do not hide the shelf.
875 if (!visible_window) 876 if (!visible_window)
876 return SHELF_AUTO_HIDE_SHOWN; 877 return SHELF_AUTO_HIDE_SHOWN;
877 878
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 gesture_drag_status_ = GESTURE_DRAG_NONE; 1103 gesture_drag_status_ = GESTURE_DRAG_NONE;
1103 } 1104 }
1104 1105
1105 void ShelfLayoutManager::CancelGestureDrag() { 1106 void ShelfLayoutManager::CancelGestureDrag() {
1106 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; 1107 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS;
1107 UpdateVisibilityState(); 1108 UpdateVisibilityState();
1108 gesture_drag_status_ = GESTURE_DRAG_NONE; 1109 gesture_drag_status_ = GESTURE_DRAG_NONE;
1109 } 1110 }
1110 1111
1111 } // namespace ash 1112 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698