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

Desks: Fix desk bar becoming invisible when active desk is removed.

Since https://crrev.com/c/2044644, the desk bar is an activatable
window placed in the active desk's container. Removing the active
desk from overview means hiding its container, and showing another
one. The desk bar should be one of those windows that move to the
newly-activated desk's container when its original (previously-active)
desk is removed.

BUG=1053771
TEST=Manually, expanded an existing test.

Change-Id: Id4bb2084ac0117fab4334819c9d79e40e8a565d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063810Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742793}
parent 3016a020
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/mru_window_tracker.h" #include "ash/wm/mru_window_tracker.h"
...@@ -43,6 +44,12 @@ void UpdateBackdropController(aura::Window* desk_container) { ...@@ -43,6 +44,12 @@ void UpdateBackdropController(aura::Window* desk_container) {
// Returns true if |window| can be managed by the desk, and therefore can be // Returns true if |window| can be managed by the desk, and therefore can be
// moved out of the desk when the desk is removed. // moved out of the desk when the desk is removed.
bool CanMoveWindowOutOfDeskContainer(aura::Window* window) { bool CanMoveWindowOutOfDeskContainer(aura::Window* window) {
// The desks bar widget is an activatable window placed in the active desk's
// container, therefore it should be allowed to move outside of its desk when
// its desk is removed.
if (window->id() == kShellWindowId_DesksBarWindow)
return true;
// We never move transient descendants directly, this is taken care of by // We never move transient descendants directly, this is taken care of by
// `wm::TransientWindowManager::OnWindowHierarchyChanged()`. // `wm::TransientWindowManager::OnWindowHierarchyChanged()`.
auto* transient_root = ::wm::GetTransientRoot(window); auto* transient_root = ::wm::GetTransientRoot(window);
...@@ -312,6 +319,9 @@ void Desk::MoveWindowToDesk(aura::Window* window, Desk* target_desk) { ...@@ -312,6 +319,9 @@ void Desk::MoveWindowToDesk(aura::Window* window, Desk* target_desk) {
DCHECK(window); DCHECK(window);
DCHECK(base::Contains(windows_, window)); DCHECK(base::Contains(windows_, window));
DCHECK(this != target_desk); DCHECK(this != target_desk);
// The desks bar should not be allowed to move individually to another desk.
// Only as part of `MoveWindowsToDesk()` when the desk is removed.
DCHECK_NE(window->id(), kShellWindowId_DesksBarWindow);
{ {
ScopedWindowPositionerDisabler window_positioner_disabler; ScopedWindowPositionerDisabler window_positioner_disabler;
......
...@@ -1019,6 +1019,12 @@ TEST_F(DesksTest, RemoveActiveDeskFromOverview) { ...@@ -1019,6 +1019,12 @@ TEST_F(DesksTest, RemoveActiveDeskFromOverview) {
EXPECT_EQ(1, desk_1_observer.notify_counts()); EXPECT_EQ(1, desk_1_observer.notify_counts());
EXPECT_EQ(0, desk_2_observer.notify_counts()); EXPECT_EQ(0, desk_2_observer.notify_counts());
// Make sure that the desks_bar_view window is still visible, i.e. it moved to
// the newly-activated desk's container.
EXPECT_TRUE(desks_bar_view->GetWidget()->IsVisible());
EXPECT_TRUE(DoesActiveDeskContainWindow(
desks_bar_view->GetWidget()->GetNativeWindow()));
// desk_1 will become active, and windows from desk_2 and desk_1 will merge // desk_1 will become active, and windows from desk_2 and desk_1 will merge
// and added in the overview grid in the order of MRU. // and added in the overview grid in the order of MRU.
ASSERT_EQ(1u, controller->desks().size()); ASSERT_EQ(1u, controller->desks().size());
......
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