Commit bf3771f1 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Cros splitscreen - Make the shelf fully opaque when splitscreen is active.

Bug: 807106
Change-Id: I8ff4939634f919f7566b499985af89960fd6ab09
Reviewed-on: https://chromium-review.googlesource.com/954346
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542861}
parent 8c7c6985
......@@ -61,6 +61,9 @@ enum ShelfBackgroundType {
// The background when fullscreen app list is visible.
SHELF_BACKGROUND_APP_LIST,
// The background when split view mode is active.
SHELF_BACKGROUND_SPLIT_VIEW,
};
// Source of the launch or activation request, for tracking.
......
......@@ -75,6 +75,10 @@ std::pair<int, int> GetTargetColorAlphaValues(
target_shelf_color_alpha = 0;
target_item_color_alpha = 0;
break;
case SHELF_BACKGROUND_SPLIT_VIEW:
target_shelf_color_alpha = ShelfBackgroundAnimator::kMaxAlpha;
target_item_color_alpha = 0;
break;
default:
NOTREACHED();
}
......@@ -250,6 +254,7 @@ void ShelfBackgroundAnimator::CreateAnimator(
duration_ms = 500;
break;
case SHELF_BACKGROUND_MAXIMIZED:
case SHELF_BACKGROUND_SPLIT_VIEW:
duration_ms = 250;
break;
}
......@@ -304,6 +309,9 @@ void ShelfBackgroundAnimator::GetTargetValues(
case SHELF_BACKGROUND_MAXIMIZED:
darkening_alpha = kShelfOpaqueColorDarkenAlpha;
break;
case SHELF_BACKGROUND_SPLIT_VIEW:
darkening_alpha = ShelfBackgroundAnimator::kMaxAlpha;
break;
}
target_color = color_utils::GetResultingPaintColor(
SkColorSetA(kShelfDefaultBaseColor, darkening_alpha), target_color);
......
......@@ -246,6 +246,15 @@ TEST_F(ShelfBackgroundAnimatorTest, MaximizedBackground) {
EXPECT_EQ(0, observer_.GetItemBackgroundAlpha());
}
// Verify the alpha values for the SHELF_BACKGROUND_SPLIT_VIEW state.
TEST_F(ShelfBackgroundAnimatorTest, SplitViewBackground) {
PaintBackground(SHELF_BACKGROUND_SPLIT_VIEW);
EXPECT_EQ(SHELF_BACKGROUND_SPLIT_VIEW, animator_->target_background_type());
EXPECT_EQ(kMaxAlpha, observer_.GetBackgroundAlpha());
EXPECT_EQ(0, observer_.GetItemBackgroundAlpha());
}
// Verify the alpha values for the SHELF_BACKGROUND_APP_LIST state.
TEST_F(ShelfBackgroundAnimatorTest, FullscreenAppListBackground) {
PaintBackground(SHELF_BACKGROUND_APP_LIST);
......
......@@ -462,6 +462,14 @@ void ShelfLayoutManager::OnAppListVisibilityChanged(bool shown,
MaybeUpdateShelfBackground(AnimationChangeType::IMMEDIATE);
}
void ShelfLayoutManager::OnSplitViewModeStarted() {
MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE);
}
void ShelfLayoutManager::OnSplitViewModeEnded() {
MaybeUpdateShelfBackground(AnimationChangeType::ANIMATE);
}
void ShelfLayoutManager::OnWindowActivated(ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
......@@ -514,6 +522,10 @@ ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
return SHELF_BACKGROUND_OVERLAP;
}
// If split view mode is active, make the shelf fully opapue.
if (Shell::Get()->IsSplitViewModeActive())
return SHELF_BACKGROUND_SPLIT_VIEW;
return SHELF_BACKGROUND_DEFAULT;
}
......
......@@ -154,6 +154,8 @@ class ASH_EXPORT ShelfLayoutManager
aura::Window* root_window) override;
void OnAppListVisibilityChanged(bool shown,
aura::Window* root_window) override;
void OnSplitViewModeStarted() override;
void OnSplitViewModeEnded() override;
// Overridden from wm::ActivationChangeObserver:
void OnWindowActivated(ActivationReason reason,
......
......@@ -28,6 +28,7 @@
#include "ash/system/tray/test_system_tray_item.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/lock_state_controller.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
......@@ -1981,6 +1982,35 @@ TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColor) {
EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
}
// Test the background color for split view mode.
TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorInSplitView) {
// Split view is only enabled in tablet mode.
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
std::unique_ptr<aura::Window> window1(CreateTestWindow());
window1->SetProperty(aura::client::kResizeBehaviorKey,
ui::mojom::kResizeBehaviorCanResize |
ui::mojom::kResizeBehaviorCanMaximize);
window1->Show();
SplitViewController* split_view_controller =
Shell::Get()->split_view_controller();
split_view_controller->SnapWindow(window1.get(), SplitViewController::LEFT);
EXPECT_EQ(SHELF_BACKGROUND_SPLIT_VIEW, GetShelfWidget()->GetBackgroundType());
std::unique_ptr<aura::Window> window2(CreateTestWindow());
window2->SetProperty(aura::client::kResizeBehaviorKey,
ui::mojom::kResizeBehaviorCanResize |
ui::mojom::kResizeBehaviorCanMaximize);
window2->Show();
split_view_controller->SnapWindow(window2.get(), SplitViewController::RIGHT);
EXPECT_EQ(SHELF_BACKGROUND_SPLIT_VIEW, GetShelfWidget()->GetBackgroundType());
// Ending split view mode will maximize the two windows.
split_view_controller->EndSplitView();
EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType());
}
// Verify that the shelf doesn't have the opaque background if it's auto-hide
// status.
TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) {
......
......@@ -535,7 +535,8 @@ void Shell::DoInitialWorkspaceAnimation() {
}
bool Shell::IsSplitViewModeActive() const {
return split_view_controller_->IsSplitViewModeActive();
return split_view_controller_.get() &&
split_view_controller_->IsSplitViewModeActive();
}
void Shell::AddShellObserver(ShellObserver* observer) {
......@@ -571,6 +572,11 @@ void Shell::NotifySplitViewModeStarting() {
observer.OnSplitViewModeStarting();
}
void Shell::NotifySplitViewModeStarted() {
for (auto& observer : shell_observers_)
observer.OnSplitViewModeStarted();
}
void Shell::NotifySplitViewModeEnded() {
for (auto& observer : shell_observers_)
observer.OnSplitViewModeEnded();
......
......@@ -557,6 +557,9 @@ class ASH_EXPORT Shell : public SessionObserver,
// window gets snapped and activated).
void NotifySplitViewModeStarting();
// Notifies observers that split view mode has been started.
void NotifySplitViewModeStarted();
// Notifies observers that split view mode has ended.
void NotifySplitViewModeEnded();
......
......@@ -59,6 +59,9 @@ class ASH_EXPORT ShellObserver {
// gets snapped and activated).
virtual void OnSplitViewModeStarting() {}
// Called when the split view mode has been started.
virtual void OnSplitViewModeStarted() {}
// Called after split view mode has ended.
virtual void OnSplitViewModeEnded() {}
......
......@@ -274,6 +274,8 @@ void SplitViewController::SnapWindow(aura::Window* window,
wm::GetWindowState(window)->OnWMEvent(&event);
}
if (previous_state == NO_SNAP && previous_state != state_)
Shell::Get()->NotifySplitViewModeStarted();
NotifySplitViewStateChanged(previous_state, state_);
base::RecordAction(base::UserMetricsAction("SplitView_SnapWindow"));
}
......
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