summaryrefslogtreecommitdiffstats
path: root/athena
diff options
context:
space:
mode:
Diffstat (limited to 'athena')
-rw-r--r--athena/wm/window_manager_impl.cc61
-rw-r--r--athena/wm/window_manager_impl.h3
-rw-r--r--athena/wm/window_manager_unittest.cc38
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