summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
Diffstat (limited to 'ash')
-rw-r--r--ash/shelf/shelf_layout_manager.cc47
-rw-r--r--ash/shelf/shelf_layout_manager.h10
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc43
-rw-r--r--ash/test/ash_test_base.cc1
-rw-r--r--ash/wm/workspace/workspace_layout_manager_unittest.cc9
5 files changed, 85 insertions, 25 deletions
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index 340ab77..7f1667c 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -252,9 +252,9 @@ bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) {
return false;
alignment_ = alignment;
- if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) {
+ if (state_.is_screen_locked || state_.is_adding_user_screen) {
// The shelf will itself move to the bottom while locked. If a request is
- // sent to move while being locked, we postpone the move untill the lock
+ // sent to move while being locked, we postpone the move until the lock
// screen goes away.
return false;
}
@@ -266,8 +266,11 @@ bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) {
}
ShelfAlignment ShelfLayoutManager::GetAlignment() const {
- // When the screen is locked, the shelf is forced into bottom alignment.
- if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked())
+ // When the screen is locked or a user gets added, the shelf is forced into
+ // bottom alignment. Note: We cannot use state_.is_screen_locked here since
+ // that flag gets set later than the SessionStateDelegate reports a locked
+ // screen which leads in
+ if (state_.is_screen_locked || state_.is_adding_user_screen)
return SHELF_ALIGNMENT_BOTTOM;
return alignment_;
}
@@ -319,7 +322,7 @@ void ShelfLayoutManager::UpdateVisibilityState() {
if (!workspace_controller_)
return;
- if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) {
+ if (state_.is_screen_locked || state_.is_adding_user_screen) {
SetState(SHELF_VISIBLE);
} else {
// TODO(zelidrag): Verify shelf drag animation still shows on the device
@@ -538,9 +541,7 @@ void ShelfLayoutManager::OnLockStateChanged(bool locked) {
// Force the shelf to layout for alignment (bottom if locked, restore
// the previous alignment otherwise).
state_.is_screen_locked = locked;
- shelf_->SetAlignment(locked ? SHELF_ALIGNMENT_BOTTOM : alignment_);
- UpdateVisibilityState();
- LayoutShelf();
+ UpdateShelfVisibilityAfterLoginUIChange();
}
void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active,
@@ -574,6 +575,9 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
state.auto_hide_state = CalculateAutoHideState(visibility_state);
state.window_state = workspace_controller_ ?
workspace_controller_->GetWindowState() : WORKSPACE_WINDOW_STATE_DEFAULT;
+ // Preserve the log in screen states.
+ state.is_adding_user_screen = state_.is_adding_user_screen;
+ state.is_screen_locked = state_.is_screen_locked;
// Force an update because gesture drags affect the shelf bounds and we
// should animate back to the normal bounds at the end of a gesture.
@@ -710,15 +714,12 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity(
ScreenUtil::ConvertRectToScreen(
shelf_->status_area_widget()->GetNativeView()->parent(),
status_bounds));
- SessionStateDelegate* session_state_delegate =
- Shell::GetInstance()->session_state_delegate();
if (!state_.is_screen_locked) {
gfx::Insets insets;
// If user session is blocked (login to new user session or add user to
// the existing session - multi-profile) then give 100% of work area only
// if keyboard is not shown.
- if (!session_state_delegate->IsUserSessionBlocked() ||
- !keyboard_bounds_.IsEmpty()) {
+ if (!state_.is_adding_user_screen || !keyboard_bounds_.IsEmpty()) {
insets = target_bounds.work_area_insets;
}
Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets);
@@ -956,7 +957,8 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
}
if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
- (!state_.is_screen_locked && window_overlaps_shelf_) ||
+ (!state_.is_screen_locked && !state_.is_adding_user_screen &&
+ window_overlaps_shelf_) ||
(state_.visibility_state == SHELF_AUTO_HIDE)) {
return SHELF_BACKGROUND_OVERLAP;
}
@@ -1154,17 +1156,34 @@ void ShelfLayoutManager::OnDockBoundsChanging(
void ShelfLayoutManager::OnLockStateEvent(LockStateObserver::EventType event) {
if (event == EVENT_LOCK_ANIMATION_STARTED) {
- // Enter the screen locked state.
+ // Enter the screen locked state and update the visibility to avoid an odd
+ // animation when transitioning the orientation from L/R to bottom.
state_.is_screen_locked = true;
+ UpdateShelfVisibilityAfterLoginUIChange();
}
}
void ShelfLayoutManager::SessionStateChanged(
SessionStateDelegate::SessionState state) {
+ // Check transition changes to/from the add user to session and change the
+ // shelf alignment accordingly
+ bool add_user = state == SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY;
+ if (add_user != state_.is_adding_user_screen) {
+ state_.is_adding_user_screen = add_user;
+ UpdateShelfVisibilityAfterLoginUIChange();
+ return;
+ }
TargetBounds target_bounds;
CalculateTargetBounds(state_, &target_bounds);
UpdateBoundsAndOpacity(target_bounds, true, NULL);
UpdateVisibilityState();
}
+void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() {
+ shelf_->SetAlignment(state_.is_adding_user_screen || state_.is_screen_locked ?
+ SHELF_ALIGNMENT_BOTTOM : alignment_);
+ UpdateVisibilityState();
+ LayoutShelf();
+}
+
} // namespace ash
diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h
index bb3f34d..05b396c 100644
--- a/ash/shelf/shelf_layout_manager.h
+++ b/ash/shelf/shelf_layout_manager.h
@@ -243,7 +243,8 @@ class ASH_EXPORT ShelfLayoutManager
State() : visibility_state(SHELF_VISIBLE),
auto_hide_state(SHELF_AUTO_HIDE_HIDDEN),
window_state(WORKSPACE_WINDOW_STATE_DEFAULT),
- is_screen_locked(false) {}
+ is_screen_locked(false),
+ is_adding_user_screen(false) {}
// Returns true if the two states are considered equal. As
// |auto_hide_state| only matters if |visibility_state| is
@@ -254,13 +255,15 @@ class ASH_EXPORT ShelfLayoutManager
(visibility_state != SHELF_AUTO_HIDE ||
other.auto_hide_state == auto_hide_state) &&
other.window_state == window_state &&
- other.is_screen_locked == is_screen_locked;
+ other.is_screen_locked == is_screen_locked &&
+ other.is_adding_user_screen == is_adding_user_screen;
}
ShelfVisibilityState visibility_state;
ShelfAutoHideState auto_hide_state;
WorkspaceWindowState window_state;
bool is_screen_locked;
+ bool is_adding_user_screen;
};
// Sets the visibility of the shelf to |state|.
@@ -327,6 +330,9 @@ class ASH_EXPORT ShelfLayoutManager
const gfx::Rect& dock_bounds,
DockedWindowLayoutManagerObserver::Reason reason) override;
+ // Called when the LoginUI changes from visible to invisible.
+ void UpdateShelfVisibilityAfterLoginUIChange();
+
// The RootWindow is cached so that we don't invoke Shell::GetInstance() from
// our destructor. We avoid that as at the time we're deleted Shell is being
// deleted too.
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 7dc9e0a..eefeda7 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -371,6 +371,28 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase {
void RunGestureDragTests(gfx::Vector2d);
+ // Turn on the lock screen.
+ void LockScreen() {
+ Shell::GetInstance()->session_state_delegate()->LockScreen();
+ // The test session state delegate does not fire the lock state change.
+ Shell::GetInstance()->OnLockStateChanged(true);
+ }
+
+ // Turn off the lock screen.
+ void UnlockScreen() {
+ Shell::GetInstance()->session_state_delegate()->UnlockScreen();
+ // The test session state delegate does not fire the lock state change.
+ Shell::GetInstance()->OnLockStateChanged(false);
+ }
+
+ // Open the add user screen if |show| is true, otherwise end it.
+ void ShowAddUserScreen(bool show) {
+ ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
+ manager->SessionStateChanged(
+ show ? SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY :
+ SessionStateDelegate::SESSION_STATE_ACTIVE);
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest);
};
@@ -747,9 +769,20 @@ TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLockScreen) {
ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
- Shell::GetInstance()->session_state_delegate()->LockScreen();
+ LockScreen();
EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment());
- Shell::GetInstance()->session_state_delegate()->UnlockScreen();
+ UnlockScreen();
+ EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
+}
+
+// Makes sure shelf alignment is correct for add user screen.
+TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithAddUserScreen) {
+ ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
+ manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
+ EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
+ ShowAddUserScreen(true);
+ EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment());
+ ShowAddUserScreen(false);
EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
}
@@ -1024,13 +1057,11 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
lock_widget->Show();
// Lock the screen.
- Shell::GetInstance()->session_state_delegate()->LockScreen();
- shelf->UpdateVisibilityState();
+ LockScreen();
// Showing a widget in the lock screen should force the shelf to be visibile.
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
- Shell::GetInstance()->session_state_delegate()->UnlockScreen();
- shelf->UpdateVisibilityState();
+ UnlockScreen();
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
}
diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc
index a208de2..34d14a4 100644
--- a/ash/test/ash_test_base.cc
+++ b/ash/test/ash_test_base.cc
@@ -317,6 +317,7 @@ void AshTestBase::BlockUserSession(UserSessionBlockReason block_reason) {
SetSessionStarted(true);
SetUserAddingScreenRunning(false);
Shell::GetInstance()->session_state_delegate()->LockScreen();
+ Shell::GetInstance()->OnLockStateChanged(true);
break;
case BLOCKED_BY_LOGIN_SCREEN:
SetUserAddingScreenRunning(false);
diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc
index b7e663f6..7bbd685 100644
--- a/ash/wm/workspace/workspace_layout_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc
@@ -769,14 +769,17 @@ TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) {
ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
window_bounds.ToString());
+ // The window size should not get touched while we are in lock screen.
Shell::GetInstance()->session_state_delegate()->LockScreen();
shelf->UpdateVisibilityState();
- EXPECT_NE(
- ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
- window_bounds.ToString());
+ EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
+ // Coming out of the lock screen the window size should still remain.
Shell::GetInstance()->session_state_delegate()->UnlockScreen();
shelf->UpdateVisibilityState();
+ EXPECT_EQ(
+ ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
+ window_bounds.ToString());
EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
}