| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return SHELF_AUTO_HIDE; | 191 return SHELF_AUTO_HIDE; |
| 192 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: | 192 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: |
| 193 return SHELF_VISIBLE; | 193 return SHELF_VISIBLE; |
| 194 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: | 194 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: |
| 195 return SHELF_HIDDEN; | 195 return SHELF_HIDDEN; |
| 196 } | 196 } |
| 197 return SHELF_VISIBLE; | 197 return SHELF_VISIBLE; |
| 198 } | 198 } |
| 199 | 199 |
| 200 void ShelfLayoutManager::UpdateVisibilityState() { | 200 void ShelfLayoutManager::UpdateVisibilityState() { |
| 201 // Bail out early before the shelf is initialized or after it is destroyed. |
| 201 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); | 202 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); |
| 202 WmRootWindowController* controller = shelf_window->GetRootWindowController(); | 203 if (in_shutdown_ || !wm_shelf_->IsShelfInitialized() || !shelf_window) |
| 203 // Bail out early before the shelf is initialized or after it is destroyed. | |
| 204 if (!controller || !wm_shelf_->IsShelfInitialized() || in_shutdown_) | |
| 205 return; | 204 return; |
| 206 bool was_invisible_auto_hide_shelf = invisible_auto_hide_shelf_; | 205 bool was_invisible_auto_hide_shelf = invisible_auto_hide_shelf_; |
| 207 // Always reset to be safe. | 206 // Always reset to be safe. |
| 208 invisible_auto_hide_shelf_ = false; | 207 invisible_auto_hide_shelf_ = false; |
| 209 if (state_.is_screen_locked || state_.is_adding_user_screen) { | 208 if (state_.is_screen_locked || state_.is_adding_user_screen) { |
| 210 SetState(SHELF_VISIBLE); | 209 SetState(SHELF_VISIBLE); |
| 211 } else if (WmShell::Get()->IsPinned()) { | 210 } else if (WmShell::Get()->IsPinned()) { |
| 212 SetState(SHELF_HIDDEN); | 211 SetState(SHELF_HIDDEN); |
| 213 } else { | 212 } else { |
| 214 // TODO(zelidrag): Verify shelf drag animation still shows on the device | 213 // TODO(zelidrag): Verify shelf drag animation still shows on the device |
| 215 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. | 214 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. |
| 216 wm::WorkspaceWindowState window_state( | 215 wm::WorkspaceWindowState window_state( |
| 217 controller->GetWorkspaceWindowState()); | 216 shelf_window->GetRootWindowController()->GetWorkspaceWindowState()); |
| 218 switch (window_state) { | 217 switch (window_state) { |
| 219 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { | 218 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { |
| 220 switch (GetShelfModeForFullscreen()) { | 219 switch (GetShelfModeForFullscreen()) { |
| 221 case wm::WindowState::SHELF_HIDDEN: | 220 case wm::WindowState::SHELF_HIDDEN: |
| 222 SetState(SHELF_HIDDEN); | 221 SetState(SHELF_HIDDEN); |
| 223 break; | 222 break; |
| 224 case wm::WindowState::SHELF_AUTO_HIDE_INVISIBLE: | 223 case wm::WindowState::SHELF_AUTO_HIDE_INVISIBLE: |
| 225 invisible_auto_hide_shelf_ = true; | 224 invisible_auto_hide_shelf_ = true; |
| 226 case wm::WindowState::SHELF_AUTO_HIDE_VISIBLE: | 225 case wm::WindowState::SHELF_AUTO_HIDE_VISIBLE: |
| 227 if (was_invisible_auto_hide_shelf != invisible_auto_hide_shelf_ && | 226 if (was_invisible_auto_hide_shelf != invisible_auto_hide_shelf_ && |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1138 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 1140 } | 1139 } |
| 1141 | 1140 |
| 1142 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const { | 1141 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const { |
| 1143 if (invisible_auto_hide_shelf_) | 1142 if (invisible_auto_hide_shelf_) |
| 1144 return 0; | 1143 return 0; |
| 1145 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); | 1144 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
| 1146 } | 1145 } |
| 1147 | 1146 |
| 1148 } // namespace ash | 1147 } // namespace ash |
| OLD | NEW |