| 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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/launcher/launcher.h" | 11 #include "ash/launcher/launcher.h" |
| 12 #include "ash/launcher/launcher_types.h" | 12 #include "ash/launcher/launcher_types.h" |
| 13 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 14 #include "ash/screen_ash.h" | 14 #include "ash/screen_ash.h" |
| 15 #include "ash/session_state_delegate.h" | |
| 16 #include "ash/shelf/shelf_widget.h" | 15 #include "ash/shelf/shelf_widget.h" |
| 17 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/shell_delegate.h" |
| 18 #include "ash/shell_window_ids.h" | 18 #include "ash/shell_window_ids.h" |
| 19 #include "ash/system/status_area_widget.h" | 19 #include "ash/system/status_area_widget.h" |
| 20 #include "ash/wm/property_util.h" | 20 #include "ash/wm/property_util.h" |
| 21 #include "ash/wm/window_cycle_controller.h" | 21 #include "ash/wm/window_cycle_controller.h" |
| 22 #include "ash/wm/window_util.h" | 22 #include "ash/wm/window_util.h" |
| 23 #include "ash/wm/workspace_controller.h" | 23 #include "ash/wm/workspace_controller.h" |
| 24 #include "ash/wm/workspace/workspace_animations.h" | 24 #include "ash/wm/workspace/workspace_animations.h" |
| 25 #include "base/auto_reset.h" | 25 #include "base/auto_reset.h" |
| 26 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 27 #include "base/i18n/rtl.h" | 27 #include "base/i18n/rtl.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: | 265 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: |
| 266 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: | 266 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: |
| 267 return SHELF_AUTO_HIDE; | 267 return SHELF_AUTO_HIDE; |
| 268 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: | 268 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: |
| 269 return SHELF_HIDDEN; | 269 return SHELF_HIDDEN; |
| 270 } | 270 } |
| 271 return SHELF_VISIBLE; | 271 return SHELF_VISIBLE; |
| 272 } | 272 } |
| 273 | 273 |
| 274 void ShelfLayoutManager::UpdateVisibilityState() { | 274 void ShelfLayoutManager::UpdateVisibilityState() { |
| 275 if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) { | 275 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 276 if (delegate && delegate->IsScreenLocked()) { |
| 276 SetState(SHELF_VISIBLE); | 277 SetState(SHELF_VISIBLE); |
| 277 } else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) { | 278 } else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) { |
| 278 // TODO(zelidrag): Verify shelf drag animation still shows on the device | 279 // TODO(zelidrag): Verify shelf drag animation still shows on the device |
| 279 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. | 280 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. |
| 280 SetState(CalculateShelfVisibilityWhileDragging()); | 281 SetState(CalculateShelfVisibilityWhileDragging()); |
| 281 } else if (GetRootWindowController(root_window_)->IsImmersiveMode()) { | 282 } else if (GetRootWindowController(root_window_)->IsImmersiveMode()) { |
| 282 // The user choosing immersive mode indicates he or she wants to maximize | 283 // The user choosing immersive mode indicates he or she wants to maximize |
| 283 // screen real-estate for content, so always auto-hide the shelf. | 284 // screen real-estate for content, so always auto-hide the shelf. |
| 284 DCHECK_NE(auto_hide_behavior_, SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 285 DCHECK_NE(auto_hide_behavior_, SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 285 SetState(SHELF_AUTO_HIDE); | 286 SetState(SHELF_AUTO_HIDE); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 return shelf ? shelf->shelf_layout_manager() : NULL; | 507 return shelf ? shelf->shelf_layout_manager() : NULL; |
| 507 } | 508 } |
| 508 | 509 |
| 509 //////////////////////////////////////////////////////////////////////////////// | 510 //////////////////////////////////////////////////////////////////////////////// |
| 510 // ShelfLayoutManager, private: | 511 // ShelfLayoutManager, private: |
| 511 | 512 |
| 512 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} | 513 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} |
| 513 ShelfLayoutManager::TargetBounds::~TargetBounds() {} | 514 ShelfLayoutManager::TargetBounds::~TargetBounds() {} |
| 514 | 515 |
| 515 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { | 516 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { |
| 517 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 516 State state; | 518 State state; |
| 517 state.visibility_state = visibility_state; | 519 state.visibility_state = visibility_state; |
| 518 state.auto_hide_state = CalculateAutoHideState(visibility_state); | 520 state.auto_hide_state = CalculateAutoHideState(visibility_state); |
| 519 state.is_screen_locked = | 521 state.is_screen_locked = delegate && delegate->IsScreenLocked(); |
| 520 Shell::GetInstance()->session_state_delegate()->IsScreenLocked(); | |
| 521 | 522 |
| 522 // It's possible for SetState() when a window becomes maximized but the state | 523 // It's possible for SetState() when a window becomes maximized but the state |
| 523 // won't have changed value. Do the dimming check before the early exit. | 524 // won't have changed value. Do the dimming check before the early exit. |
| 524 if (workspace_controller_) { | 525 if (workspace_controller_) { |
| 525 shelf_->SetDimsShelf( | 526 shelf_->SetDimsShelf( |
| 526 (state.visibility_state == SHELF_VISIBLE) && | 527 (state.visibility_state == SHELF_VISIBLE) && |
| 527 workspace_controller_->GetWindowState() == | 528 workspace_controller_->GetWindowState() == |
| 528 WORKSPACE_WINDOW_STATE_MAXIMIZED); | 529 WORKSPACE_WINDOW_STATE_MAXIMIZED); |
| 529 } | 530 } |
| 530 | 531 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 907 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
| 907 if (state.visibility_state == SHELF_VISIBLE) | 908 if (state.visibility_state == SHELF_VISIBLE) |
| 908 return size; | 909 return size; |
| 909 if (state.visibility_state == SHELF_AUTO_HIDE) | 910 if (state.visibility_state == SHELF_AUTO_HIDE) |
| 910 return kAutoHideSize; | 911 return kAutoHideSize; |
| 911 return 0; | 912 return 0; |
| 912 } | 913 } |
| 913 | 914 |
| 914 } // namespace internal | 915 } // namespace internal |
| 915 } // namespace ash | 916 } // namespace ash |
| OLD | NEW |