| 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/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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: | 233 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: |
| 234 return SHELF_HIDDEN; | 234 return SHELF_HIDDEN; |
| 235 } | 235 } |
| 236 return SHELF_VISIBLE; | 236 return SHELF_VISIBLE; |
| 237 } | 237 } |
| 238 | 238 |
| 239 void ShelfLayoutManager::UpdateVisibilityState() { | 239 void ShelfLayoutManager::UpdateVisibilityState() { |
| 240 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); | 240 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); |
| 241 WmRootWindowController* controller = shelf_window->GetRootWindowController(); | 241 WmRootWindowController* controller = shelf_window->GetRootWindowController(); |
| 242 // Bail out early before the shelf is initialized or after it is destroyed. | 242 // Bail out early before the shelf is initialized or after it is destroyed. |
| 243 if (!controller || !shelf_widget_->shelf() || in_shutdown_) | 243 if (!controller || !wm_shelf_->IsShelfCreated() || in_shutdown_) |
| 244 return; | 244 return; |
| 245 bool was_invisible_auto_hide_shelf = invisible_auto_hide_shelf_; | 245 bool was_invisible_auto_hide_shelf = invisible_auto_hide_shelf_; |
| 246 // Always reset to be safe. | 246 // Always reset to be safe. |
| 247 invisible_auto_hide_shelf_ = false; | 247 invisible_auto_hide_shelf_ = false; |
| 248 if (state_.is_screen_locked || state_.is_adding_user_screen) { | 248 if (state_.is_screen_locked || state_.is_adding_user_screen) { |
| 249 SetState(SHELF_VISIBLE); | 249 SetState(SHELF_VISIBLE); |
| 250 } else if (WmShell::Get()->IsPinned()) { | 250 } else if (WmShell::Get()->IsPinned()) { |
| 251 SetState(SHELF_HIDDEN); | 251 SetState(SHELF_HIDDEN); |
| 252 } else { | 252 } else { |
| 253 // TODO(zelidrag): Verify shelf drag animation still shows on the device | 253 // TODO(zelidrag): Verify shelf drag animation still shows on the device |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 else | 881 else |
| 882 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); | 882 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); |
| 883 | 883 |
| 884 // TODO: Figure out if we need any special handling when the keyboard is | 884 // TODO: Figure out if we need any special handling when the keyboard is |
| 885 // visible. | 885 // visible. |
| 886 return show_shelf_region_in_screen; | 886 return show_shelf_region_in_screen; |
| 887 } | 887 } |
| 888 | 888 |
| 889 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( | 889 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( |
| 890 ShelfVisibilityState visibility_state) const { | 890 ShelfVisibilityState visibility_state) const { |
| 891 if (visibility_state != SHELF_AUTO_HIDE || !shelf_widget_->shelf()) | 891 if (visibility_state != SHELF_AUTO_HIDE || !wm_shelf_->IsShelfCreated()) |
| 892 return SHELF_AUTO_HIDE_HIDDEN; | 892 return SHELF_AUTO_HIDE_HIDDEN; |
| 893 | 893 |
| 894 const int64_t shelf_display_id = WmLookup::Get() | 894 const int64_t shelf_display_id = WmLookup::Get() |
| 895 ->GetWindowForWidget(shelf_widget_) | 895 ->GetWindowForWidget(shelf_widget_) |
| 896 ->GetDisplayNearestWindow() | 896 ->GetDisplayNearestWindow() |
| 897 .id(); | 897 .id(); |
| 898 | 898 |
| 899 // Unhide the shelf only on the active screen when the AppList is shown | 899 // Unhide the shelf only on the active screen when the AppList is shown |
| 900 // (crbug.com/312445). | 900 // (crbug.com/312445). |
| 901 if (WmShell::Get()->GetAppListTargetVisibility()) { | 901 if (WmShell::Get()->GetAppListTargetVisibility()) { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1178 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 1179 } | 1179 } |
| 1180 | 1180 |
| 1181 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const { | 1181 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const { |
| 1182 if (invisible_auto_hide_shelf_) | 1182 if (invisible_auto_hide_shelf_) |
| 1183 return 0; | 1183 return 0; |
| 1184 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); | 1184 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 } // namespace ash | 1187 } // namespace ash |
| OLD | NEW |