Commit 7f05b253 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Let RootWindowLayoutManager manages containers explicitly.

Bug: 969829
Test: no functional change. all test should passes.
Change-Id: I51ae9d1fc03b15f20a004d63c4e4c214d18d2652
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1656054
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668515}
parent 1fd5b379
......@@ -269,22 +269,6 @@ void ReparentAllWindows(aura::Window* src, aura::Window* dst) {
}
}
// Creates a new window for use as a container.
aura::Window* CreateContainer(int window_id,
const char* name,
aura::Window* parent) {
aura::Window* window =
window_factory::NewWindow(nullptr, aura::client::WINDOW_TYPE_UNKNOWN)
.release();
window->Init(ui::LAYER_NOT_DRAWN);
window->set_id(window_id);
window->SetName(name);
parent->AddChild(window);
if (window_id != kShellWindowId_UnparentedControlContainer)
window->Show();
return window;
}
bool ShouldDestroyWindowInCloseChildWindows(aura::Window* window) {
return window->owned_by_parent();
}
......@@ -651,6 +635,8 @@ void RootWindowController::CloseChildWindows() {
delete toplevel_windows.Pop();
}
// Reset layout manager so that it won't fire unnecessary layout evetns.
root->SetLayoutManager(nullptr);
// And then remove the containers.
while (!root->children().empty()) {
aura::Window* child = root->children()[0];
......@@ -844,7 +830,6 @@ void RootWindowController::InitLayoutManagers() {
aura::Window* root = GetRootWindow();
shelf_->CreateShelfWidget(root);
root_window_layout_manager_ = new wm::RootWindowLayoutManager(root);
root->SetLayoutManager(root_window_layout_manager_);
for (auto* container : desks_util::GetDesksContainers(root)) {
......@@ -901,6 +886,8 @@ void RootWindowController::InitLayoutManagers() {
void RootWindowController::CreateContainers() {
aura::Window* root = GetRootWindow();
root_window_layout_manager_ = new wm::RootWindowLayoutManager(root);
// For screen rotation animation: add a NOT_DRAWN layer in between the
// root_window's layer and its current children so that we only need to
// initiate two LayerAnimationSequences. One for the new layers and one for
......@@ -1141,6 +1128,22 @@ void RootWindowController::CreateContainers() {
"PowerButtonAnimationContainer", magnified_container);
}
aura::Window* RootWindowController::CreateContainer(int window_id,
const char* name,
aura::Window* parent) {
aura::Window* window =
window_factory::NewWindow(nullptr, aura::client::WINDOW_TYPE_UNKNOWN)
.release();
window->Init(ui::LAYER_NOT_DRAWN);
window->set_id(window_id);
window->SetName(name);
parent->AddChild(window);
if (window_id != kShellWindowId_UnparentedControlContainer)
window->Show();
root_window_layout_manager_->AddContainer(window);
return window;
}
void RootWindowController::CreateSystemWallpaper(
RootWindowType root_window_type) {
SkColor color = SK_ColorBLACK;
......
......@@ -248,6 +248,11 @@ class ASH_EXPORT RootWindowController {
// Creates the containers (aura::Windows) used by the shell.
void CreateContainers();
// Creates a new window for use as a container.
aura::Window* CreateContainer(int window_id,
const char* name,
aura::Window* parent);
// Initializes |system_wallpaper_| and possibly also |boot_splash_screen_|.
// The initial color is determined by the |root_window_type| and whether or
// not this is the first boot.
......
......@@ -9,33 +9,6 @@
namespace ash {
namespace {
// Resize all container windows that RootWindowLayoutManager is responsible for.
// That includes all container windows up to depth four except the top level
// windows which have a delegate. We cannot simply check top level windows,
// because we need to skip other windows without a delegate, such as
// ScreenDimmer windows.
// TODO(wutao): The above logic is error prone. Consider using a Shell window id
// to indentify such a container.
void ResizeWindow(const aura::Window::Windows& children,
const gfx::Rect& fullscreen_bounds,
int depth) {
if (depth > 3)
return;
const int child_depth = depth + 1;
aura::WindowTracker children_tracker(children);
while (!children_tracker.windows().empty()) {
aura::Window* child = children_tracker.Pop();
if (child->GetToplevelWindow())
continue;
child->SetBounds(fullscreen_bounds);
ResizeWindow(child->children(), fullscreen_bounds, child_depth);
}
}
} // namespace
namespace wm {
////////////////////////////////////////////////////////////////////////////////
......@@ -50,7 +23,9 @@ RootWindowLayoutManager::~RootWindowLayoutManager() = default;
// RootWindowLayoutManager, aura::LayoutManager implementation:
void RootWindowLayoutManager::OnWindowResized() {
ResizeWindow(owner_->children(), gfx::Rect(owner_->bounds().size()), 0);
gfx::Rect bounds(owner_->bounds().size());
for (auto* container : containers_)
container->SetBounds(bounds);
}
void RootWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) {}
......@@ -70,5 +45,10 @@ void RootWindowLayoutManager::SetChildBounds(
SetChildBoundsDirect(child, requested_bounds);
}
void RootWindowLayoutManager::AddContainer(aura::Window* window) {
DCHECK(!window->GetToplevelWindow());
containers_.push_back(window);
}
} // namespace wm
} // namespace ash
......@@ -5,6 +5,8 @@
#ifndef ASH_WM_ROOT_WINDOW_LAYOUT_MANAGER_H_
#define ASH_WM_ROOT_WINDOW_LAYOUT_MANAGER_H_
#include <vector>
#include "base/macros.h"
#include "ui/aura/layout_manager.h"
......@@ -29,8 +31,11 @@ class RootWindowLayoutManager : public aura::LayoutManager {
void SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) override;
void AddContainer(aura::Window* window);
private:
aura::Window* owner_;
std::vector<aura::Window*> containers_;
DISALLOW_COPY_AND_ASSIGN(RootWindowLayoutManager);
};
......
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