Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: ash/common/shelf/shelf_layout_manager.cc

Issue 2782223002: Add ability to have active window autohide shelf (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/shelf/shelf_layout_manager.h ('k') | ash/common/wm/window_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/screen_pinning_controller.h" 28 #include "ash/wm/screen_pinning_controller.h"
29 #include "ash/wm/window_state_aura.h"
29 #include "base/auto_reset.h" 30 #include "base/auto_reset.h"
30 #include "base/command_line.h" 31 #include "base/command_line.h"
31 #include "base/i18n/rtl.h" 32 #include "base/i18n/rtl.h"
32 #include "ui/base/ui_base_switches.h" 33 #include "ui/base/ui_base_switches.h"
33 #include "ui/compositor/layer.h" 34 #include "ui/compositor/layer.h"
34 #include "ui/compositor/layer_animation_observer.h" 35 #include "ui/compositor/layer_animation_observer.h"
35 #include "ui/compositor/layer_animator.h" 36 #include "ui/compositor/layer_animator.h"
36 #include "ui/compositor/scoped_layer_animation_settings.h" 37 #include "ui/compositor/scoped_layer_animation_settings.h"
37 #include "ui/display/display.h" 38 #include "ui/display/display.h"
38 #include "ui/display/screen.h" 39 #include "ui/display/screen.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 return; 242 return;
242 if (state_.IsScreenLocked() || state_.IsAddingSecondaryUser()) { 243 if (state_.IsScreenLocked() || state_.IsAddingSecondaryUser()) {
243 SetState(SHELF_VISIBLE); 244 SetState(SHELF_VISIBLE);
244 } else if (Shell::Get()->screen_pinning_controller()->IsPinned()) { 245 } else if (Shell::Get()->screen_pinning_controller()->IsPinned()) {
245 SetState(SHELF_HIDDEN); 246 SetState(SHELF_HIDDEN);
246 } else { 247 } else {
247 // TODO(zelidrag): Verify shelf drag animation still shows on the device 248 // TODO(zelidrag): Verify shelf drag animation still shows on the device
248 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. 249 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN.
249 wm::WorkspaceWindowState window_state( 250 wm::WorkspaceWindowState window_state(
250 shelf_window->GetRootWindowController()->GetWorkspaceWindowState()); 251 shelf_window->GetRootWindowController()->GetWorkspaceWindowState());
252
251 switch (window_state) { 253 switch (window_state) {
252 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { 254 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: {
253 if (IsShelfHiddenForFullscreen()) { 255 if (IsShelfAutoHideForFullscreenMaximized()) {
256 SetState(SHELF_AUTO_HIDE);
257 } else if (IsShelfHiddenForFullscreen()) {
254 SetState(SHELF_HIDDEN); 258 SetState(SHELF_HIDDEN);
255 } else { 259 } else {
256 // The shelf is sometimes not hidden when in immersive fullscreen. 260 // The shelf is sometimes not hidden when in immersive fullscreen.
257 // Force the shelf to be auto hidden in this case. 261 // Force the shelf to be auto hidden in this case.
258 SetState(SHELF_AUTO_HIDE); 262 SetState(SHELF_AUTO_HIDE);
259 } 263 }
260 break; 264 break;
261 } 265 }
262 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED: 266 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED:
263 SetState(CalculateShelfVisibility()); 267 if (IsShelfAutoHideForFullscreenMaximized()) {
268 SetState(SHELF_AUTO_HIDE);
269 } else {
270 SetState(CalculateShelfVisibility());
271 }
264 break; 272 break;
265 273
266 case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: 274 case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
267 case wm::WORKSPACE_WINDOW_STATE_DEFAULT: 275 case wm::WORKSPACE_WINDOW_STATE_DEFAULT:
268 SetState(CalculateShelfVisibility()); 276 SetState(CalculateShelfVisibility());
269 SetWindowOverlapsShelf( 277 SetWindowOverlapsShelf(
270 window_state == wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); 278 window_state == wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF);
271 break; 279 break;
272 } 280 }
273 } 281 }
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 : 0.0f; 1039 : 0.0f;
1032 } 1040 }
1033 1041
1034 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const { 1042 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const {
1035 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode( 1043 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode(
1036 WmWindow::Get(shelf_widget_->GetNativeWindow())); 1044 WmWindow::Get(shelf_widget_->GetNativeWindow()));
1037 return fullscreen_window && 1045 return fullscreen_window &&
1038 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen(); 1046 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen();
1039 } 1047 }
1040 1048
1049 bool ShelfLayoutManager::IsShelfAutoHideForFullscreenMaximized() const {
1050 wm::WindowState* active_window = wm::GetActiveWindowState();
1051 return active_window &&
1052 active_window->autohide_shelf_when_maximized_or_fullscreen();
1053 }
1054
1041 //////////////////////////////////////////////////////////////////////////////// 1055 ////////////////////////////////////////////////////////////////////////////////
1042 // ShelfLayoutManager, Gesture functions: 1056 // ShelfLayoutManager, Gesture functions:
1043 1057
1044 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { 1058 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
1045 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; 1059 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS;
1046 gesture_drag_amount_ = 0.f; 1060 gesture_drag_amount_ = 0.f;
1047 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE 1061 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE
1048 ? auto_hide_state() 1062 ? auto_hide_state()
1049 : SHELF_AUTO_HIDE_SHOWN; 1063 : SHELF_AUTO_HIDE_SHOWN;
1050 MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE); 1064 MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 gesture_drag_status_ = GESTURE_DRAG_NONE; 1140 gesture_drag_status_ = GESTURE_DRAG_NONE;
1127 } 1141 }
1128 1142
1129 void ShelfLayoutManager::CancelGestureDrag() { 1143 void ShelfLayoutManager::CancelGestureDrag() {
1130 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; 1144 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS;
1131 UpdateVisibilityState(); 1145 UpdateVisibilityState();
1132 gesture_drag_status_ = GESTURE_DRAG_NONE; 1146 gesture_drag_status_ = GESTURE_DRAG_NONE;
1133 } 1147 }
1134 1148
1135 } // namespace ash 1149 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_layout_manager.h ('k') | ash/common/wm/window_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698