Chromium Code Reviews| Index: athena/wm/window_manager_impl.cc |
| diff --git a/athena/wm/window_manager_impl.cc b/athena/wm/window_manager_impl.cc |
| index 3dd9612467b06b42c2a23922e7f8a3189708965f..d78233e55cdcf0d7c0a55079dec54c0dda2b3fc4 100644 |
| --- a/athena/wm/window_manager_impl.cc |
| +++ b/athena/wm/window_manager_impl.cc |
| @@ -25,8 +25,8 @@ |
| namespace athena { |
| namespace { |
| - |
| class WindowManagerImpl* instance = NULL; |
| +} // namespace |
| class AthenaContainerLayoutManager : public aura::LayoutManager { |
| public: |
| @@ -54,11 +54,47 @@ AthenaContainerLayoutManager::~AthenaContainerLayoutManager() { |
| } |
| void AthenaContainerLayoutManager::OnWindowResized() { |
| - instance->Layout(); |
| + // Resize all the existing windows. |
| + const aura::Window::Windows& list = instance->container_->children(); |
|
oshima
2014/08/18 16:13:03
can we use WindowListProvider::GetWindowList ?
I'
sadrul
2014/08/18 16:45:43
Done.
|
| + const gfx::Size container_size = instance->container_->bounds().size(); |
|
oshima
2014/08/18 16:13:03
gfx::Screen::GetPrimaryDisplay().work_area()
sadrul
2014/08/18 16:45:43
Done.
|
| + bool is_splitview = instance->split_view_controller_->IsSplitViewModeActive(); |
| + gfx::Size split_size; |
| + if (is_splitview) { |
|
oshima
2014/08/18 16:13:03
I think it's better to let SplitViewController lay
sadrul
2014/08/18 16:45:43
That would work only for two windows: left and rig
oshima
2014/08/18 17:00:41
I'm pretty sure we'll want to separate it, but ide
|
| + CHECK(instance->split_view_controller_->left_window()); |
| + split_size = |
| + instance->split_view_controller_->left_window()->bounds().size(); |
| + } |
| + |
| + for (aura::Window::Windows::const_iterator iter = list.begin(); |
| + iter != list.end(); |
| + ++iter) { |
| + aura::Window* window = *iter; |
| + if (window->type() != ui::wm::WINDOW_TYPE_NORMAL) |
| + return; |
| + if (is_splitview) { |
| + if (window == instance->split_view_controller_->left_window()) |
| + window->SetBounds(gfx::Rect(split_size)); |
| + else if (window == instance->split_view_controller_->right_window()) |
| + window->SetBounds( |
| + gfx::Rect(gfx::Point(split_size.width(), 0), split_size)); |
| + else |
| + window->SetBounds(gfx::Rect(container_size)); |
| + } else { |
| + window->SetBounds(gfx::Rect(container_size)); |
| + } |
| + } |
| } |
| void AthenaContainerLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| - instance->Layout(); |
| + if (child->type() != ui::wm::WINDOW_TYPE_NORMAL) |
| + return; |
|
oshima
2014/08/18 16:13:03
how about checking if the child window is in windo
sadrul
2014/08/18 16:45:43
Done.
|
| + aura::Window* window = NULL; |
| + if (instance->split_view_controller_->IsSplitViewModeActive()) |
| + window = instance->split_view_controller_->left_window(); |
| + else |
| + window = instance->container_.get(); |
| + CHECK(window); |
| + child->SetBounds(gfx::Rect(window->bounds().size())); |
| } |
| void AthenaContainerLayoutManager::OnWillRemoveWindowFromLayout( |
| @@ -67,13 +103,11 @@ void AthenaContainerLayoutManager::OnWillRemoveWindowFromLayout( |
| void AthenaContainerLayoutManager::OnWindowRemovedFromLayout( |
| aura::Window* child) { |
| - instance->Layout(); |
| } |
| void AthenaContainerLayoutManager::OnChildWindowVisibilityChanged( |
| aura::Window* child, |
| bool visible) { |
| - instance->Layout(); |
| } |
| void AthenaContainerLayoutManager::SetChildBounds( |
| @@ -83,8 +117,6 @@ void AthenaContainerLayoutManager::SetChildBounds( |
| SetChildBoundsDirect(child, requested_bounds); |
| } |
| -} // namespace |
| - |
| WindowManagerImpl::WindowManagerImpl() { |
| ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); |
| params.can_activate_children = true; |
| @@ -120,19 +152,6 @@ WindowManagerImpl::~WindowManagerImpl() { |
| instance = NULL; |
| } |
| -void WindowManagerImpl::Layout() { |
| - if (!container_) |
| - return; |
| - gfx::Rect bounds = gfx::Rect(container_->bounds().size()); |
| - const aura::Window::Windows& children = container_->children(); |
| - for (aura::Window::Windows::const_iterator iter = children.begin(); |
| - iter != children.end(); |
| - ++iter) { |
| - if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL) |
| - (*iter)->SetBounds(bounds); |
| - } |
| -} |
| - |
| void WindowManagerImpl::ToggleOverview() { |
| SetInOverview(overview_.get() == NULL); |
| } |