Commit b868a519 authored by Min Chen's avatar Min Chen Committed by Commit Bot

shelf: Hide AUTO_HIDE_SHOWN shelf if switch to tablet mode.

Bug: 890531
Change-Id: Iacf0199ed5b41dce8557d8f9daaf79ad8fa29c27
Reviewed-on: https://chromium-review.googlesource.com/c/1351578Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611219}
parent bb5980e0
...@@ -999,8 +999,9 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( ...@@ -999,8 +999,9 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
return SHELF_AUTO_HIDE_SHOWN; return SHELF_AUTO_HIDE_SHOWN;
if (shelf_widget_->status_area_widget() && if (shelf_widget_->status_area_widget() &&
shelf_widget_->status_area_widget()->ShouldShowShelf()) shelf_widget_->status_area_widget()->ShouldShowShelf()) {
return SHELF_AUTO_HIDE_SHOWN; return SHELF_AUTO_HIDE_SHOWN;
}
if (shelf_widget_->IsShowingContextMenu()) if (shelf_widget_->IsShowingContextMenu())
return SHELF_AUTO_HIDE_SHOWN; return SHELF_AUTO_HIDE_SHOWN;
...@@ -1052,8 +1053,12 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( ...@@ -1052,8 +1053,12 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
gfx::Point cursor_position_in_screen = gfx::Point cursor_position_in_screen =
display::Screen::GetScreen()->GetCursorScreenPoint(); display::Screen::GetScreen()->GetCursorScreenPoint();
if (shelf_region.Contains(cursor_position_in_screen)) // Cursor is invisible in talbet mode and plug in an external mouse in tablet
// mode will switch to clamshell mode.
if (shelf_region.Contains(cursor_position_in_screen) &&
!IsTabletModeEnabled()) {
return SHELF_AUTO_HIDE_SHOWN; return SHELF_AUTO_HIDE_SHOWN;
}
// When the shelf is auto hidden and the shelf is on the boundary between two // When the shelf is auto hidden and the shelf is on the boundary between two
// displays, it is hard to trigger showing the shelf. For instance, if a // displays, it is hard to trigger showing the shelf. For instance, if a
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "ash/wm/lock_state_controller.h" #include "ash/wm/lock_state_controller.h"
#include "ash/wm/overview/window_selector_controller.h" #include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/splitview/split_view_controller.h" #include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller_test_api.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "ash/wm/wm_event.h" #include "ash/wm/wm_event.h"
...@@ -978,6 +978,13 @@ TEST_F(ShelfLayoutManagerTest, AutoHide) { ...@@ -978,6 +978,13 @@ TEST_F(ShelfLayoutManagerTest, AutoHide) {
generator->MoveMouseTo(1, display_bottom - 1); generator->MoveMouseTo(1, display_bottom - 1);
UpdateAutoHideStateNow(); UpdateAutoHideStateNow();
EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
// Switch to tablet mode should hide the AUTO_HIDE_SHOWN shelf even the mouse
// cursor is inside the shelf area.
EXPECT_FALSE(TabletModeControllerTestApi().IsTabletModeStarted());
TabletModeControllerTestApi().EnterTabletMode();
EXPECT_TRUE(TabletModeControllerTestApi().IsTabletModeStarted());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
} }
// Test the behavior of the shelf when it is auto hidden and it is on the // Test the behavior of the shelf when it is auto hidden and it is on the
...@@ -2203,7 +2210,7 @@ TEST_F(ShelfLayoutManagerTest, TabletModeTransitionWithAppListVisible) { ...@@ -2203,7 +2210,7 @@ TEST_F(ShelfLayoutManagerTest, TabletModeTransitionWithAppListVisible) {
GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId());
// Transition to tablet mode. // Transition to tablet mode.
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); TabletModeControllerTestApi().EnterTabletMode();
// |window| should be maximized, and the shelf background should match the // |window| should be maximized, and the shelf background should match the
// maximized state. // maximized state.
...@@ -2214,7 +2221,7 @@ TEST_F(ShelfLayoutManagerTest, TabletModeTransitionWithAppListVisible) { ...@@ -2214,7 +2221,7 @@ TEST_F(ShelfLayoutManagerTest, TabletModeTransitionWithAppListVisible) {
// Test the background color for split view mode. // Test the background color for split view mode.
TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorInSplitView) { TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorInSplitView) {
// Split view is only enabled in tablet mode. // Split view is only enabled in tablet mode.
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); TabletModeControllerTestApi().EnterTabletMode();
std::unique_ptr<aura::Window> window1(CreateTestWindow()); std::unique_ptr<aura::Window> window1(CreateTestWindow());
window1->SetProperty(aura::client::kResizeBehaviorKey, window1->SetProperty(aura::client::kResizeBehaviorKey,
...@@ -2347,7 +2354,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) { ...@@ -2347,7 +2354,7 @@ TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) {
// gesture handler to handle. // gesture handler to handle.
TEST_F(ShelfLayoutManagerTest, HomeLauncherGestureHandler) { TEST_F(ShelfLayoutManagerTest, HomeLauncherGestureHandler) {
// Home launcher is only available in tablet mode. // Home launcher is only available in tablet mode.
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); TabletModeControllerTestApi().EnterTabletMode();
// Home launcher gesture handler needs at least one window. // Home launcher gesture handler needs at least one window.
std::unique_ptr<aura::Window> window = std::unique_ptr<aura::Window> window =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment