Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(978)

Unified Diff: athena/wm/window_manager_impl.cc

Issue 481843002: athena: Fix window-layout in split-view mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/wm/window_manager_impl.h ('k') | athena/wm/window_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bbc86735050d849dd93245c9822a90b518377661 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);
}
« no previous file with comments | « athena/wm/window_manager_impl.h ('k') | athena/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698