Commit e61d2af3 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Virtual Desks: Unminimize a minimized window when dragged to another desk

Per PM/UX request, when a minimized window is dragged to another desk,
it should show up in the mini_view, and should be unminimized in the
target desk after it has been move to it. Otherwise, the experience
will be confusing since it will just disappear once dropped.

Demo: https://bugs.chromium.org/p/chromium/issues/detail?id=971417#c2

BUG=971417
TEST=Manually, added test.

Change-Id: I9da54f39cad662080a54c4e234254fb7ef651c29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1647187
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666547}
parent 0332cdde
...@@ -245,6 +245,12 @@ void Desk::MoveWindowToDesk(aura::Window* window, Desk* target_desk) { ...@@ -245,6 +245,12 @@ void Desk::MoveWindowToDesk(aura::Window* window, Desk* target_desk) {
MoveWindowToDeskInternal(window, target_desk); MoveWindowToDeskInternal(window, target_desk);
windows_.erase(window); windows_.erase(window);
// Unminimize the window so that it shows up in the mini_view after it had
// been dragged and moved to another desk.
auto* window_state = wm::GetWindowState(window);
if (window_state->IsMinimized())
window_state->Unminimize();
} }
NotifyContentChanged(); NotifyContentChanged();
......
...@@ -93,7 +93,8 @@ class ASH_EXPORT DesksController ...@@ -93,7 +93,8 @@ class ASH_EXPORT DesksController
void ActivateDesk(const Desk* desk); void ActivateDesk(const Desk* desk);
// Moves |window| (which must belong to the currently active desk) to // Moves |window| (which must belong to the currently active desk) to
// |target_desk| (which must be a different desk). // |target_desk| (which must be a different desk). If |window| is minimized,
// it will be unminimized after it's moved to |target_desk|.
void MoveWindowFromActiveDeskTo(aura::Window* window, Desk* target_desk); void MoveWindowFromActiveDeskTo(aura::Window* window, Desk* target_desk);
// Called explicitly by the RootWindowController when a root window has been // Called explicitly by the RootWindowController when a root window has been
......
...@@ -936,6 +936,57 @@ TEST_F(DesksTest, DragWindowToDesk) { ...@@ -936,6 +936,57 @@ TEST_F(DesksTest, DragWindowToDesk) {
EXPECT_TRUE(shadow->layer()->GetTargetVisibility()); EXPECT_TRUE(shadow->layer()->GetTargetVisibility());
} }
TEST_F(DesksTest, DragMinimizedWindowToDesk) {
auto* controller = DesksController::Get();
controller->NewDesk();
ASSERT_EQ(2u, controller->desks().size());
const Desk* desk_2 = controller->desks()[1].get();
auto window = CreateTestWindow(gfx::Rect(0, 0, 250, 100));
wm::ActivateWindow(window.get());
EXPECT_EQ(window.get(), wm::GetActiveWindow());
// Minimize the window before entering Overview Mode.
auto* window_state = wm::GetWindowState(window.get());
window_state->Minimize();
ASSERT_TRUE(window_state->IsMinimized());
auto* overview_controller = Shell::Get()->overview_controller();
overview_controller->ToggleOverview();
EXPECT_TRUE(overview_controller->InOverviewSession());
auto* overview_grid = GetOverviewGridForRoot(Shell::GetPrimaryRootWindow());
auto* overview_session = overview_controller->overview_session();
auto* overview_item =
overview_session->GetOverviewItemForWindow(window.get());
ASSERT_TRUE(overview_item);
const auto* desks_bar_view = overview_grid->GetDesksBarViewForTesting();
ASSERT_TRUE(desks_bar_view);
ASSERT_EQ(2u, desks_bar_view->mini_views().size());
// Drag the window to desk_2's mini_view and activate desk_2. Expect that the
// window will be in an unminimized state and all its visibility and layer
// opacity attributes are correct.
auto* desk_2_mini_view = desks_bar_view->mini_views()[1].get();
EXPECT_EQ(desk_2, desk_2_mini_view->desk());
DragItemToPoint(overview_item,
desk_2_mini_view->GetBoundsInScreen().CenterPoint(),
GetEventGenerator());
EXPECT_TRUE(overview_controller->InOverviewSession());
EXPECT_TRUE(overview_grid->empty());
EXPECT_TRUE(desk_2->windows().contains(window.get()));
EXPECT_FALSE(overview_grid->drop_target_widget());
DeskSwitchAnimationWaiter waiter;
ClickOnMiniView(desk_2_mini_view, GetEventGenerator());
waiter.Wait();
EXPECT_FALSE(overview_controller->InOverviewSession());
EXPECT_TRUE(desk_2->is_active());
EXPECT_FALSE(window_state->IsMinimized());
EXPECT_TRUE(window->IsVisible());
EXPECT_TRUE(window->layer()->GetTargetVisibility());
EXPECT_EQ(1.f, window->layer()->GetTargetOpacity());
}
TEST_F(DesksTest, DragWindowToNonMiniViewPoints) { TEST_F(DesksTest, DragWindowToNonMiniViewPoints) {
auto* controller = DesksController::Get(); auto* controller = DesksController::Get();
controller->NewDesk(); controller->NewDesk();
......
...@@ -534,7 +534,7 @@ void OverviewItem::CloseWindow() { ...@@ -534,7 +534,7 @@ void OverviewItem::CloseWindow() {
void OverviewItem::OnMinimizedStateChanged() { void OverviewItem::OnMinimizedStateChanged() {
const bool minimized = transform_window_.IsMinimized(); const bool minimized = transform_window_.IsMinimized();
caption_container_view_->SetShowPreview(minimized); caption_container_view_->SetShowPreview(minimized);
if (minimized) if (!minimized)
EnsureVisible(); EnsureVisible();
if (window_surface_cache_observers_) { if (window_surface_cache_observers_) {
......
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