Chromium Code Reviews| 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/keyboard/keyboard_observer_register.h" | 12 #include "ash/common/keyboard/keyboard_observer_register.h" |
| 13 #include "ash/common/session/session_controller.h" | 13 #include "ash/common/session/session_controller.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_shell.h" | 23 #include "ash/common/wm_shell.h" |
| 24 #include "ash/common/wm_window.h" | 24 #include "ash/common/wm_window.h" |
| 25 #include "ash/public/cpp/shell_window_ids.h" | 25 #include "ash/public/cpp/shell_window_ids.h" |
| 26 #include "ash/root_window_controller.h" | 26 #include "ash/root_window_controller.h" |
| 27 #include "ash/shell.h" | 27 #include "ash/shell.h" |
| 28 #include "ash/wm/window_state_aura.h" | |
| 28 #include "base/auto_reset.h" | 29 #include "base/auto_reset.h" |
| 29 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| 30 #include "base/i18n/rtl.h" | 31 #include "base/i18n/rtl.h" |
| 31 #include "ui/base/ui_base_switches.h" | 32 #include "ui/base/ui_base_switches.h" |
| 32 #include "ui/compositor/layer.h" | 33 #include "ui/compositor/layer.h" |
| 33 #include "ui/compositor/layer_animation_observer.h" | 34 #include "ui/compositor/layer_animation_observer.h" |
| 34 #include "ui/compositor/layer_animator.h" | 35 #include "ui/compositor/layer_animator.h" |
| 35 #include "ui/compositor/scoped_layer_animation_settings.h" | 36 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 36 #include "ui/display/display.h" | 37 #include "ui/display/display.h" |
| 37 #include "ui/display/screen.h" | 38 #include "ui/display/screen.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 return; | 241 return; |
| 241 if (state_.IsScreenLocked() || state_.IsAddingSecondaryUser()) { | 242 if (state_.IsScreenLocked() || state_.IsAddingSecondaryUser()) { |
| 242 SetState(SHELF_VISIBLE); | 243 SetState(SHELF_VISIBLE); |
| 243 } else if (WmShell::Get()->IsPinned()) { | 244 } else if (WmShell::Get()->IsPinned()) { |
| 244 SetState(SHELF_HIDDEN); | 245 SetState(SHELF_HIDDEN); |
| 245 } else { | 246 } else { |
| 246 // TODO(zelidrag): Verify shelf drag animation still shows on the device | 247 // TODO(zelidrag): Verify shelf drag animation still shows on the device |
| 247 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. | 248 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. |
| 248 wm::WorkspaceWindowState window_state( | 249 wm::WorkspaceWindowState window_state( |
| 249 shelf_window->GetRootWindowController()->GetWorkspaceWindowState()); | 250 shelf_window->GetRootWindowController()->GetWorkspaceWindowState()); |
| 251 | |
| 252 // SetState(SHELF_AUTO_HIDE); | |
| 253 // return; | |
| 254 //} | |
|
oshima
2017/03/30 19:35:58
clean up?
yorkelee
2017/03/30 19:38:37
Done.
yorkelee
2017/03/30 19:38:37
Done.
| |
| 255 | |
| 250 switch (window_state) { | 256 switch (window_state) { |
| 251 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { | 257 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { |
| 252 if (IsShelfHiddenForFullscreen()) { | 258 if (IsShelfAutoHideForFullscreenMaximized()) { |
| 259 SetState(SHELF_AUTO_HIDE); | |
| 260 } else if (IsShelfHiddenForFullscreen()) { | |
| 253 SetState(SHELF_HIDDEN); | 261 SetState(SHELF_HIDDEN); |
| 254 } else { | 262 } else { |
| 255 // The shelf is sometimes not hidden when in immersive fullscreen. | 263 // The shelf is sometimes not hidden when in immersive fullscreen. |
| 256 // Force the shelf to be auto hidden in this case. | 264 // Force the shelf to be auto hidden in this case. |
| 257 SetState(SHELF_AUTO_HIDE); | 265 SetState(SHELF_AUTO_HIDE); |
| 258 } | 266 } |
| 259 break; | 267 break; |
| 260 } | 268 } |
| 261 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED: | 269 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED: |
| 262 SetState(CalculateShelfVisibility()); | 270 if (IsShelfAutoHideForFullscreenMaximized()) { |
| 271 SetState(SHELF_AUTO_HIDE); | |
| 272 } else { | |
| 273 SetState(CalculateShelfVisibility()); | |
| 274 } | |
| 263 break; | 275 break; |
| 264 | 276 |
| 265 case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: | 277 case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: |
| 266 case wm::WORKSPACE_WINDOW_STATE_DEFAULT: | 278 case wm::WORKSPACE_WINDOW_STATE_DEFAULT: |
| 267 SetState(CalculateShelfVisibility()); | 279 SetState(CalculateShelfVisibility()); |
| 268 SetWindowOverlapsShelf( | 280 SetWindowOverlapsShelf( |
| 269 window_state == wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); | 281 window_state == wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); |
| 270 break; | 282 break; |
| 271 } | 283 } |
| 272 } | 284 } |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1030 : 0.0f; | 1042 : 0.0f; |
| 1031 } | 1043 } |
| 1032 | 1044 |
| 1033 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const { | 1045 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const { |
| 1034 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode( | 1046 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode( |
| 1035 WmWindow::Get(shelf_widget_->GetNativeWindow())); | 1047 WmWindow::Get(shelf_widget_->GetNativeWindow())); |
| 1036 return fullscreen_window && | 1048 return fullscreen_window && |
| 1037 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen(); | 1049 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen(); |
| 1038 } | 1050 } |
| 1039 | 1051 |
| 1052 bool ShelfLayoutManager::IsShelfAutoHideForFullscreenMaximized() const { | |
| 1053 wm::WindowState* active_window = wm::GetActiveWindowState(); | |
| 1054 return active_window && | |
| 1055 active_window->autohide_shelf_when_maximized_or_fullscreen(); | |
| 1056 } | |
| 1057 | |
| 1040 //////////////////////////////////////////////////////////////////////////////// | 1058 //////////////////////////////////////////////////////////////////////////////// |
| 1041 // ShelfLayoutManager, Gesture functions: | 1059 // ShelfLayoutManager, Gesture functions: |
| 1042 | 1060 |
| 1043 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { | 1061 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { |
| 1044 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; | 1062 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; |
| 1045 gesture_drag_amount_ = 0.f; | 1063 gesture_drag_amount_ = 0.f; |
| 1046 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE | 1064 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE |
| 1047 ? auto_hide_state() | 1065 ? auto_hide_state() |
| 1048 : SHELF_AUTO_HIDE_SHOWN; | 1066 : SHELF_AUTO_HIDE_SHOWN; |
| 1049 MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE); | 1067 MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1125 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1143 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 1126 } | 1144 } |
| 1127 | 1145 |
| 1128 void ShelfLayoutManager::CancelGestureDrag() { | 1146 void ShelfLayoutManager::CancelGestureDrag() { |
| 1129 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; | 1147 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; |
| 1130 UpdateVisibilityState(); | 1148 UpdateVisibilityState(); |
| 1131 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1149 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 1132 } | 1150 } |
| 1133 | 1151 |
| 1134 } // namespace ash | 1152 } // namespace ash |
| OLD | NEW |