| 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 |
| 11 #include "ash/animation/animation_change_type.h" | 11 #include "ash/animation/animation_change_type.h" |
| 12 #include "ash/common/session/session_controller.h" | 12 #include "ash/common/session/session_controller.h" |
| 13 #include "ash/common/session/session_state_delegate.h" | 13 #include "ash/common/session/session_state_delegate.h" |
| 14 #include "ash/common/shelf/shelf_constants.h" | 14 #include "ash/common/shelf/shelf_constants.h" |
| 15 #include "ash/common/shelf/shelf_layout_manager_observer.h" | 15 #include "ash/common/shelf/shelf_layout_manager_observer.h" |
| 16 #include "ash/common/shelf/shelf_widget.h" | 16 #include "ash/common/shelf/shelf_widget.h" |
| 17 #include "ash/common/shelf/wm_shelf.h" | 17 #include "ash/common/shelf/wm_shelf.h" |
| 18 #include "ash/common/system/status_area_widget.h" | 18 #include "ash/common/system/status_area_widget.h" |
| 19 #include "ash/common/wm/fullscreen_window_finder.h" | 19 #include "ash/common/wm/fullscreen_window_finder.h" |
| 20 #include "ash/common/wm/mru_window_tracker.h" | 20 #include "ash/common/wm/mru_window_tracker.h" |
| 21 #include "ash/common/wm/window_state.h" | 21 #include "ash/common/wm/window_state.h" |
| 22 #include "ash/common/wm/wm_screen_util.h" | 22 #include "ash/common/wm/wm_screen_util.h" |
| 23 #include "ash/common/wm_lookup.h" | 23 #include "ash/common/wm_lookup.h" |
| 24 #include "ash/common/wm_shell.h" | 24 #include "ash/common/wm_shell.h" |
| 25 #include "ash/common/wm_window.h" | 25 #include "ash/common/wm_window.h" |
| 26 #include "ash/public/cpp/shell_window_ids.h" | 26 #include "ash/public/cpp/shell_window_ids.h" |
| 27 #include "ash/root_window_controller.h" | 27 #include "ash/root_window_controller.h" |
| 28 #include "ash/shell.h" |
| 29 #include "ash/wm/window_state_aura.h" |
| 28 #include "base/auto_reset.h" | 30 #include "base/auto_reset.h" |
| 29 #include "base/command_line.h" | 31 #include "base/command_line.h" |
| 30 #include "base/i18n/rtl.h" | 32 #include "base/i18n/rtl.h" |
| 31 #include "ui/base/ui_base_switches.h" | 33 #include "ui/base/ui_base_switches.h" |
| 32 #include "ui/compositor/layer.h" | 34 #include "ui/compositor/layer.h" |
| 33 #include "ui/compositor/layer_animation_observer.h" | 35 #include "ui/compositor/layer_animation_observer.h" |
| 34 #include "ui/compositor/layer_animator.h" | 36 #include "ui/compositor/layer_animator.h" |
| 35 #include "ui/compositor/scoped_layer_animation_settings.h" | 37 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 36 #include "ui/display/display.h" | 38 #include "ui/display/display.h" |
| 37 #include "ui/display/screen.h" | 39 #include "ui/display/screen.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 return; | 241 return; |
| 240 if (state_.IsScreenLocked() || state_.IsAddingSecondaryUser()) { | 242 if (state_.IsScreenLocked() || state_.IsAddingSecondaryUser()) { |
| 241 SetState(SHELF_VISIBLE); | 243 SetState(SHELF_VISIBLE); |
| 242 } else if (WmShell::Get()->IsPinned()) { | 244 } else if (WmShell::Get()->IsPinned()) { |
| 243 SetState(SHELF_HIDDEN); | 245 SetState(SHELF_HIDDEN); |
| 244 } else { | 246 } else { |
| 245 // TODO(zelidrag): Verify shelf drag animation still shows on the device | 247 // TODO(zelidrag): Verify shelf drag animation still shows on the device |
| 246 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. | 248 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. |
| 247 wm::WorkspaceWindowState window_state( | 249 wm::WorkspaceWindowState window_state( |
| 248 shelf_window->GetRootWindowController()->GetWorkspaceWindowState()); | 250 shelf_window->GetRootWindowController()->GetWorkspaceWindowState()); |
| 251 |
| 249 switch (window_state) { | 252 switch (window_state) { |
| 250 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { | 253 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { |
| 251 if (IsShelfHiddenForFullscreen()) { | 254 if (IsShelfAutoHideForFullscreenMaximized()) { |
| 255 SetState(SHELF_AUTO_HIDE); |
| 256 } else if (IsShelfHiddenForFullscreen()) { |
| 252 SetState(SHELF_HIDDEN); | 257 SetState(SHELF_HIDDEN); |
| 253 } else { | 258 } else { |
| 254 // The shelf is sometimes not hidden when in immersive fullscreen. | 259 // The shelf is sometimes not hidden when in immersive fullscreen. |
| 255 // Force the shelf to be auto hidden in this case. | 260 // Force the shelf to be auto hidden in this case. |
| 256 SetState(SHELF_AUTO_HIDE); | 261 SetState(SHELF_AUTO_HIDE); |
| 257 } | 262 } |
| 258 break; | 263 break; |
| 259 } | 264 } |
| 260 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED: | 265 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED: |
| 261 SetState(CalculateShelfVisibility()); | 266 if (IsShelfAutoHideForFullscreenMaximized()) { |
| 267 SetState(SHELF_AUTO_HIDE); |
| 268 } else { |
| 269 SetState(CalculateShelfVisibility()); |
| 270 } |
| 262 break; | 271 break; |
| 263 | 272 |
| 264 case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: | 273 case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: |
| 265 case wm::WORKSPACE_WINDOW_STATE_DEFAULT: | 274 case wm::WORKSPACE_WINDOW_STATE_DEFAULT: |
| 266 SetState(CalculateShelfVisibility()); | 275 SetState(CalculateShelfVisibility()); |
| 267 SetWindowOverlapsShelf( | 276 SetWindowOverlapsShelf( |
| 268 window_state == wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); | 277 window_state == wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); |
| 269 break; | 278 break; |
| 270 } | 279 } |
| 271 } | 280 } |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 : 0.0f; | 1049 : 0.0f; |
| 1041 } | 1050 } |
| 1042 | 1051 |
| 1043 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const { | 1052 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const { |
| 1044 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode( | 1053 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode( |
| 1045 WmLookup::Get()->GetWindowForWidget(shelf_widget_)); | 1054 WmLookup::Get()->GetWindowForWidget(shelf_widget_)); |
| 1046 return fullscreen_window && | 1055 return fullscreen_window && |
| 1047 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen(); | 1056 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen(); |
| 1048 } | 1057 } |
| 1049 | 1058 |
| 1059 bool ShelfLayoutManager::IsShelfAutoHideForFullscreenMaximized() const { |
| 1060 wm::WindowState* active_window = wm::GetActiveWindowState(); |
| 1061 return active_window && |
| 1062 active_window->autohide_shelf_when_maximized_or_fullscreen(); |
| 1063 } |
| 1064 |
| 1050 //////////////////////////////////////////////////////////////////////////////// | 1065 //////////////////////////////////////////////////////////////////////////////// |
| 1051 // ShelfLayoutManager, Gesture functions: | 1066 // ShelfLayoutManager, Gesture functions: |
| 1052 | 1067 |
| 1053 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { | 1068 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { |
| 1054 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; | 1069 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; |
| 1055 gesture_drag_amount_ = 0.f; | 1070 gesture_drag_amount_ = 0.f; |
| 1056 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE | 1071 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE |
| 1057 ? auto_hide_state() | 1072 ? auto_hide_state() |
| 1058 : SHELF_AUTO_HIDE_SHOWN; | 1073 : SHELF_AUTO_HIDE_SHOWN; |
| 1059 MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE); | 1074 MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1150 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 1136 } | 1151 } |
| 1137 | 1152 |
| 1138 void ShelfLayoutManager::CancelGestureDrag() { | 1153 void ShelfLayoutManager::CancelGestureDrag() { |
| 1139 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; | 1154 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; |
| 1140 UpdateVisibilityState(); | 1155 UpdateVisibilityState(); |
| 1141 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1156 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 1142 } | 1157 } |
| 1143 | 1158 |
| 1144 } // namespace ash | 1159 } // namespace ash |
| OLD | NEW |