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 #include <cstring> | 9 #include <cstring> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "ash/ash_switches.h" | 13 #include "ash/ash_switches.h" |
14 #include "ash/launcher/launcher.h" | 14 #include "ash/launcher/launcher.h" |
15 #include "ash/launcher/launcher_types.h" | 15 #include "ash/launcher/launcher_types.h" |
16 #include "ash/root_window_controller.h" | 16 #include "ash/root_window_controller.h" |
17 #include "ash/screen_ash.h" | 17 #include "ash/screen_ash.h" |
18 #include "ash/session_state_delegate.h" | 18 #include "ash/session_state_delegate.h" |
19 #include "ash/shelf/shelf_bezel_event_filter.h" | 19 #include "ash/shelf/shelf_bezel_event_filter.h" |
20 #include "ash/shelf/shelf_layout_manager_observer.h" | 20 #include "ash/shelf/shelf_layout_manager_observer.h" |
21 #include "ash/shelf/shelf_widget.h" | 21 #include "ash/shelf/shelf_widget.h" |
22 #include "ash/shell.h" | 22 #include "ash/shell.h" |
23 #include "ash/shell_window_ids.h" | 23 #include "ash/shell_window_ids.h" |
24 #include "ash/system/status_area_widget.h" | 24 #include "ash/system/status_area_widget.h" |
25 #include "ash/wm/gestures/shelf_gesture_handler.h" | 25 #include "ash/wm/gestures/shelf_gesture_handler.h" |
26 #include "ash/wm/lock_state_controller.h" | 26 #include "ash/wm/lock_state_controller.h" |
27 #include "ash/wm/mru_window_tracker.h" | 27 #include "ash/wm/mru_window_tracker.h" |
28 #include "ash/wm/window_animations.h" | 28 #include "ash/wm/window_animations.h" |
29 #include "ash/wm/window_properties.h" | |
30 #include "ash/wm/window_state.h" | 29 #include "ash/wm/window_state.h" |
31 #include "ash/wm/window_util.h" | 30 #include "ash/wm/window_util.h" |
32 #include "ash/wm/workspace_controller.h" | 31 #include "ash/wm/workspace_controller.h" |
33 #include "base/auto_reset.h" | 32 #include "base/auto_reset.h" |
34 #include "base/command_line.h" | 33 #include "base/command_line.h" |
35 #include "base/command_line.h" | 34 #include "base/command_line.h" |
36 #include "base/i18n/rtl.h" | 35 #include "base/i18n/rtl.h" |
37 #include "base/strings/string_number_conversions.h" | 36 #include "base/strings/string_number_conversions.h" |
38 #include "base/strings/string_util.h" | 37 #include "base/strings/string_util.h" |
39 #include "ui/aura/client/activation_client.h" | 38 #include "ui/aura/client/activation_client.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 313 |
315 void ShelfLayoutManager::UpdateVisibilityState() { | 314 void ShelfLayoutManager::UpdateVisibilityState() { |
316 if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) { | 315 if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) { |
317 SetState(SHELF_VISIBLE); | 316 SetState(SHELF_VISIBLE); |
318 } else { | 317 } else { |
319 // TODO(zelidrag): Verify shelf drag animation still shows on the device | 318 // TODO(zelidrag): Verify shelf drag animation still shows on the device |
320 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. | 319 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. |
321 WorkspaceWindowState window_state(workspace_controller_->GetWindowState()); | 320 WorkspaceWindowState window_state(workspace_controller_->GetWindowState()); |
322 switch (window_state) { | 321 switch (window_state) { |
323 case WORKSPACE_WINDOW_STATE_FULL_SCREEN: | 322 case WORKSPACE_WINDOW_STATE_FULL_SCREEN: |
324 if (FullscreenWithMinimalChrome()) { | 323 if (FullscreenWithHiddenShelf()) { |
| 324 SetState(SHELF_HIDDEN); |
| 325 } else { |
| 326 // The shelf is sometimes not hidden when in immersive fullscreen. |
| 327 // Force the shelf to be auto hidden in this case. |
325 SetState(SHELF_AUTO_HIDE); | 328 SetState(SHELF_AUTO_HIDE); |
326 } else { | |
327 SetState(SHELF_HIDDEN); | |
328 } | 329 } |
329 break; | 330 break; |
330 case WORKSPACE_WINDOW_STATE_MAXIMIZED: | 331 case WORKSPACE_WINDOW_STATE_MAXIMIZED: |
331 SetState(CalculateShelfVisibility()); | 332 SetState(CalculateShelfVisibility()); |
332 break; | 333 break; |
333 case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: | 334 case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: |
334 case WORKSPACE_WINDOW_STATE_DEFAULT: | 335 case WORKSPACE_WINDOW_STATE_DEFAULT: |
335 SetState(CalculateShelfVisibility()); | 336 SetState(CalculateShelfVisibility()); |
336 SetWindowOverlapsShelf(window_state == | 337 SetWindowOverlapsShelf(window_state == |
337 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); | 338 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 shelf_->Deactivate(); | 463 shelf_->Deactivate(); |
463 shelf_->status_area_widget()->Deactivate(); | 464 shelf_->status_area_widget()->Deactivate(); |
464 } | 465 } |
465 gesture_drag_auto_hide_state_ = | 466 gesture_drag_auto_hide_state_ = |
466 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ? | 467 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ? |
467 SHELF_AUTO_HIDE_HIDDEN : SHELF_AUTO_HIDE_SHOWN; | 468 SHELF_AUTO_HIDE_HIDDEN : SHELF_AUTO_HIDE_SHOWN; |
468 ShelfAutoHideBehavior new_auto_hide_behavior = | 469 ShelfAutoHideBehavior new_auto_hide_behavior = |
469 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ? | 470 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN ? |
470 SHELF_AUTO_HIDE_BEHAVIOR_NEVER : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | 471 SHELF_AUTO_HIDE_BEHAVIOR_NEVER : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
471 | 472 |
472 // In fullscreen with minimal chrome, the auto hide behavior affects neither | 473 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide |
473 // the visibility state nor the auto hide state. Set |gesture_drag_status_| | 474 // behavior affects neither the visibility state nor the auto hide state. Set |
474 // to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto hide state to | 475 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto |
475 // |gesture_drag_auto_hide_state_|. | 476 // hide state to |gesture_drag_auto_hide_state_|. |
476 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; | 477 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; |
477 if (auto_hide_behavior_ != new_auto_hide_behavior) | 478 if (auto_hide_behavior_ != new_auto_hide_behavior) |
478 SetAutoHideBehavior(new_auto_hide_behavior); | 479 SetAutoHideBehavior(new_auto_hide_behavior); |
479 else | 480 else |
480 UpdateVisibilityState(); | 481 UpdateVisibilityState(); |
481 gesture_drag_status_ = GESTURE_DRAG_NONE; | 482 gesture_drag_status_ = GESTURE_DRAG_NONE; |
482 } | 483 } |
483 | 484 |
484 void ShelfLayoutManager::CancelGestureDrag() { | 485 void ShelfLayoutManager::CancelGestureDrag() { |
485 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; | 486 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active, | 531 void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active, |
531 aura::Window* lost_active) { | 532 aura::Window* lost_active) { |
532 UpdateAutoHideStateNow(); | 533 UpdateAutoHideStateNow(); |
533 } | 534 } |
534 | 535 |
535 bool ShelfLayoutManager::IsHorizontalAlignment() const { | 536 bool ShelfLayoutManager::IsHorizontalAlignment() const { |
536 return GetAlignment() == SHELF_ALIGNMENT_BOTTOM || | 537 return GetAlignment() == SHELF_ALIGNMENT_BOTTOM || |
537 GetAlignment() == SHELF_ALIGNMENT_TOP; | 538 GetAlignment() == SHELF_ALIGNMENT_TOP; |
538 } | 539 } |
539 | 540 |
540 bool ShelfLayoutManager::FullscreenWithMinimalChrome() const { | 541 bool ShelfLayoutManager::FullscreenWithHiddenShelf() const { |
541 RootWindowController* controller = GetRootWindowController(root_window_); | 542 RootWindowController* controller = GetRootWindowController(root_window_); |
542 if (!controller) | 543 if (!controller) |
543 return false; | 544 return false; |
544 const aura::Window* window = controller->GetTopmostFullscreenWindow(); | 545 const aura::Window* window = controller->GetTopmostFullscreenWindow(); |
545 if (!window) | 546 if (!window) |
546 return false; | 547 return false; |
547 if (!window->GetProperty(kFullscreenUsesMinimalChromeKey)) | 548 return wm::GetWindowState(window)->hide_shelf_when_fullscreen(); |
548 return false; | |
549 return true; | |
550 } | 549 } |
551 | 550 |
552 // static | 551 // static |
553 ShelfLayoutManager* ShelfLayoutManager::ForLauncher(aura::Window* window) { | 552 ShelfLayoutManager* ShelfLayoutManager::ForLauncher(aura::Window* window) { |
554 ShelfWidget* shelf = RootWindowController::ForLauncher(window)->shelf(); | 553 ShelfWidget* shelf = RootWindowController::ForLauncher(window)->shelf(); |
555 return shelf ? shelf->shelf_layout_manager() : NULL; | 554 return shelf ? shelf->shelf_layout_manager() : NULL; |
556 } | 555 } |
557 | 556 |
558 //////////////////////////////////////////////////////////////////////////////// | 557 //////////////////////////////////////////////////////////////////////////////// |
559 // ShelfLayoutManager, private: | 558 // ShelfLayoutManager, private: |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 return gfx::Insets(0, distance, 0, 0); | 1158 return gfx::Insets(0, distance, 0, 0); |
1160 case SHELF_ALIGNMENT_TOP: | 1159 case SHELF_ALIGNMENT_TOP: |
1161 return gfx::Insets(0, 0, distance, 0); | 1160 return gfx::Insets(0, 0, distance, 0); |
1162 } | 1161 } |
1163 NOTREACHED(); | 1162 NOTREACHED(); |
1164 return gfx::Insets(); | 1163 return gfx::Insets(); |
1165 } | 1164 } |
1166 | 1165 |
1167 } // namespace internal | 1166 } // namespace internal |
1168 } // namespace ash | 1167 } // namespace ash |
OLD | NEW |