diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-18 19:31:45 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-18 19:33:52 +0000 |
commit | 654bc0f5b7d2f3b5bd5de10d713b0d3410f2ed51 (patch) | |
tree | 78a4904aecc60eea92d34ac390e7560dea190573 /athena | |
parent | 2b566ac6bf0c099a63b885d4a856a1583e7eb243 (diff) | |
download | chromium_src-654bc0f5b7d2f3b5bd5de10d713b0d3410f2ed51.zip chromium_src-654bc0f5b7d2f3b5bd5de10d713b0d3410f2ed51.tar.gz chromium_src-654bc0f5b7d2f3b5bd5de10d713b0d3410f2ed51.tar.bz2 |
athena: Fix window-layout in split-view mode.
. When a window is hidden while in split-view mode, do not resize all the windows
to the container size.
. When a new window shows up while in split-view mode, make sure the window is
sized correctly (currently always get the size of the left-split).
BUG=383421, 403945
R=oshima@chromium.org
Review URL: https://codereview.chromium.org/481843002
Cr-Commit-Position: refs/heads/master@{#290330}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290330 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'athena')
-rw-r--r-- | athena/wm/window_manager_impl.cc | 61 | ||||
-rw-r--r-- | athena/wm/window_manager_impl.h | 3 | ||||
-rw-r--r-- | athena/wm/window_manager_unittest.cc | 38 |
3 files changed, 80 insertions, 22 deletions
diff --git a/athena/wm/window_manager_impl.cc b/athena/wm/window_manager_impl.cc index 3dd9612..bbc8673 100644 --- a/athena/wm/window_manager_impl.cc +++ b/athena/wm/window_manager_impl.cc @@ -17,6 +17,8 @@ #include "base/logging.h" #include "ui/aura/layout_manager.h" #include "ui/aura/window.h" +#include "ui/gfx/display.h" +#include "ui/gfx/screen.h" #include "ui/wm/core/shadow_controller.h" #include "ui/wm/core/window_util.h" #include "ui/wm/core/wm_state.h" @@ -25,8 +27,8 @@ namespace athena { namespace { - class WindowManagerImpl* instance = NULL; +} // namespace class AthenaContainerLayoutManager : public aura::LayoutManager { public: @@ -54,11 +56,47 @@ AthenaContainerLayoutManager::~AthenaContainerLayoutManager() { } void AthenaContainerLayoutManager::OnWindowResized() { - instance->Layout(); + // Resize all the existing windows. + aura::Window::Windows list = instance->window_list_provider_->GetWindowList(); + const gfx::Size work_area = + gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); + bool is_splitview = instance->split_view_controller_->IsSplitViewModeActive(); + gfx::Size split_size; + if (is_splitview) { + 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 (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(work_area)); + } else { + window->SetBounds(gfx::Rect(work_area)); + } + } } void AthenaContainerLayoutManager::OnWindowAddedToLayout(aura::Window* child) { - instance->Layout(); + aura::Window::Windows list = instance->window_list_provider_->GetWindowList(); + if (std::find(list.begin(), list.end(), child) == list.end()) + return; + 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 +105,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 +119,6 @@ void AthenaContainerLayoutManager::SetChildBounds( SetChildBoundsDirect(child, requested_bounds); } -} // namespace - WindowManagerImpl::WindowManagerImpl() { ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT); params.can_activate_children = true; @@ -120,19 +154,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); } diff --git a/athena/wm/window_manager_impl.h b/athena/wm/window_manager_impl.h index 1d978a7..2a8d5ac 100644 --- a/athena/wm/window_manager_impl.h +++ b/athena/wm/window_manager_impl.h @@ -34,14 +34,13 @@ class WindowManagerImpl : public WindowManager, WindowManagerImpl(); virtual ~WindowManagerImpl(); - void Layout(); - // WindowManager: virtual void ToggleOverview() OVERRIDE; virtual bool IsOverviewModeActive() OVERRIDE; private: friend class WindowManagerImplTestApi; + friend class AthenaContainerLayoutManager; enum Command { CMD_TOGGLE_OVERVIEW, diff --git a/athena/wm/window_manager_unittest.cc b/athena/wm/window_manager_unittest.cc index 183e8cc..705e730 100644 --- a/athena/wm/window_manager_unittest.cc +++ b/athena/wm/window_manager_unittest.cc @@ -244,4 +244,42 @@ TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { EXPECT_EQ(third.get(), wm_api.split_view_controller()->right_window()); } +TEST_F(WindowManagerTest, NewWindowBounds) { + aura::test::TestWindowDelegate delegate; + scoped_ptr<aura::Window> first(CreateWindow(&delegate)); + + WindowManagerImplTestApi wm_api; + aura::client::ParentWindowWithContext( + first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); + // The window should have the same size as the container. + const gfx::Size work_area = + gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); + EXPECT_EQ(work_area.ToString(), + first->bounds().size().ToString()); + EXPECT_TRUE(first->bounds().origin().IsOrigin()); + + // A second window should have the same bounds as the first one. + scoped_ptr<aura::Window> second(CreateWindow(&delegate)); + aura::client::ParentWindowWithContext( + second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); + EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); + + // Get into split view. + wm_api.split_view_controller()->ActivateSplitMode(NULL, NULL); + const gfx::Rect left_bounds = + wm_api.split_view_controller()->left_window()->bounds(); + EXPECT_NE(work_area.ToString(), + left_bounds.size().ToString()); + + scoped_ptr<aura::Window> third(CreateWindow(&delegate)); + aura::client::ParentWindowWithContext( + third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); + EXPECT_NE(wm_api.split_view_controller()->left_window(), third.get()); + EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); + + third->Hide(); + EXPECT_EQ(left_bounds.ToString(), + wm_api.split_view_controller()->left_window()->bounds().ToString()); +} + } // namespace athena |