Chromium Code Reviews| Index: ash/shelf/shelf_layout_manager.cc |
| diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc |
| index a4f758bb09fb8a1c7c388a4c82a533f309e85851..c83c0c8fd7d1a00f6c343c7268cabe5cd4ee28c9 100644 |
| --- a/ash/shelf/shelf_layout_manager.cc |
| +++ b/ash/shelf/shelf_layout_manager.cc |
| @@ -239,6 +239,8 @@ void ShelfLayoutManager::UpdateVisibilityState() { |
| if (!controller || !shelf_widget_->shelf() || in_shutdown_) |
| return; |
| + // Always reset to be safe. |
| + invisible_auto_hide_shelf_ = false; |
| if (state_.is_screen_locked || state_.is_adding_user_screen) { |
| SetState(SHELF_VISIBLE); |
| } else if (WmShell::Get()->IsPinned()) { |
| @@ -250,12 +252,29 @@ void ShelfLayoutManager::UpdateVisibilityState() { |
| controller->GetWorkspaceWindowState()); |
| switch (window_state) { |
| case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { |
| - if (IsShelfHiddenForFullscreen()) { |
| - SetState(SHELF_HIDDEN); |
| - } else { |
| - // The shelf is sometimes not hidden when in immersive fullscreen. |
| - // Force the shelf to be auto hidden in this case. |
| - SetState(SHELF_AUTO_HIDE); |
| + switch (GetShelfModeForFullscreen()) { |
| + case wm::WindowState::SHELF_HIDDEN: |
| + SetState(SHELF_HIDDEN); |
| + break; |
| + case wm::WindowState::SHELF_AUTO_HIDE_VISIBLE: |
| + // A hack to swtich the visibility state correctly |
| + // between auto hide visible to auto hide invisible. |
| + // TODO(oshima): Remove this once MD ash is launched. |
| + if (state_.visibility_state == SHELF_AUTO_HIDE) |
| + SetState(SHELF_HIDDEN); |
| + |
| + SetState(SHELF_AUTO_HIDE); |
| + break; |
| + case wm::WindowState::SHELF_AUTO_HIDE_INVISIBLE: |
| + // A hack to swtich the visibility state correctly |
| + // between auto hide visible to auto hide invisible. |
| + // TODO(oshima): Remove this once MD ash is launched. |
| + if (state_.visibility_state == SHELF_AUTO_HIDE) |
| + SetState(SHELF_HIDDEN); |
| + |
| + invisible_auto_hide_shelf_ = true; |
| + SetState(SHELF_AUTO_HIDE); |
| + break; |
|
tdanderson
2016/08/15 19:51:37
Is it possible to simplify as follows or do you ne
oshima
2016/08/15 20:01:50
Done.
|
| } |
| break; |
| } |
| @@ -795,7 +814,7 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture( |
| } else { |
| translate = gesture_drag_amount_; |
| } |
| - int shelf_insets = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
| + int shelf_insets = GetShelfInsetsForAutoHide(); |
| if (horizontal) { |
| // Move and size the shelf with the gesture. |
| int shelf_height = target_bounds->shelf_bounds_in_root.height() - translate; |
| @@ -988,7 +1007,7 @@ int ShelfLayoutManager::GetWorkAreaInsets(const State& state, int size) const { |
| if (state.visibility_state == SHELF_VISIBLE) |
| return size; |
| if (state.visibility_state == SHELF_AUTO_HIDE) |
| - return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
| + return GetShelfInsetsForAutoHide(); |
| return 0; |
| } |
| @@ -1045,7 +1064,8 @@ float ShelfLayoutManager::ComputeTargetOpacity(const State& state) { |
| // In Chrome OS Material Design, when shelf is hidden during auto hide state, |
| // target bounds are also hidden. So the window can extend to the edge of |
| // screen. |
| - if (ash::MaterialDesignController::IsShelfMaterial()) { |
| + if (ash::MaterialDesignController::IsShelfMaterial() || |
| + invisible_auto_hide_shelf_) { |
| return (state.visibility_state == SHELF_AUTO_HIDE && |
| state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN) |
| ? 1.0f |
| @@ -1054,11 +1074,19 @@ float ShelfLayoutManager::ComputeTargetOpacity(const State& state) { |
| return (state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; |
| } |
| +ash::wm::WindowState::FullscreenShelfMode |
| +ShelfLayoutManager::GetShelfModeForFullscreen() const { |
| + const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode( |
| + WmLookup::Get()->GetWindowForWidget(shelf_widget_)); |
| + return fullscreen_window->GetWindowState()->shelf_mode_in_fullscreen(); |
| +} |
| + |
| bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const { |
| const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode( |
| WmLookup::Get()->GetWindowForWidget(shelf_widget_)); |
| return fullscreen_window && |
| - fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen(); |
| + fullscreen_window->GetWindowState()->shelf_mode_in_fullscreen() == |
| + ash::wm::WindowState::SHELF_HIDDEN; |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -1156,4 +1184,10 @@ void ShelfLayoutManager::CancelGestureDrag() { |
| gesture_drag_status_ = GESTURE_DRAG_NONE; |
| } |
| +int ShelfLayoutManager::GetShelfInsetsForAutoHide() const { |
| + if (invisible_auto_hide_shelf_) |
| + return 0; |
| + return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
| +} |
| + |
| } // namespace ash |