Chromium Code Reviews| Index: mojo/services/view_manager/window_tree_host_impl.cc |
| diff --git a/mojo/services/view_manager/window_tree_host_impl.cc b/mojo/services/view_manager/window_tree_host_impl.cc |
| index f6ded7f92a95827499501a3e6f13e498b831f12f..afbe852b0a7a0d4731845ff2a9f0e50ec8eb0d1c 100644 |
| --- a/mojo/services/view_manager/window_tree_host_impl.cc |
| +++ b/mojo/services/view_manager/window_tree_host_impl.cc |
| @@ -2,12 +2,13 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "mojo/services/view_manager/root_node_manager.h" |
| #include "mojo/services/view_manager/window_tree_host_impl.h" |
| - |
| #include "mojo/public/c/gles2/gles2.h" |
| #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
| #include "mojo/services/view_manager/context_factory_impl.h" |
| #include "ui/aura/env.h" |
| +#include "ui/aura/layout_manager.h" |
| #include "ui/aura/window.h" |
| #include "ui/aura/window_event_dispatcher.h" |
| #include "ui/compositor/compositor.h" |
| @@ -25,6 +26,47 @@ namespace service { |
| ContextFactoryImpl* WindowTreeHostImpl::context_factory_ = NULL; |
| //////////////////////////////////////////////////////////////////////////////// |
| +// RootLayoutManager, layout management for the root window's (one) child |
| + |
| +class RootLayoutManager : public aura::LayoutManager { |
| + public: |
| + RootLayoutManager() : child_(NULL) { } |
| + |
| + // Overridden from aura::LayoutManager |
| + virtual void OnWindowResized() OVERRIDE; |
| + virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; |
| + virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} |
| + virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {} |
| + virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
| + bool visible) OVERRIDE {} |
| + virtual void SetChildBounds(aura::Window* child, |
| + const gfx::Rect& requested_bounds) OVERRIDE; |
| + private: |
| + aura::Window* child_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RootLayoutManager); |
| +}; |
| + |
| +void RootLayoutManager::OnWindowResized() { |
| + if (child_) { |
| + gfx::Rect bounds = child_->parent()->bounds(); |
| + child_->SetBounds(gfx::Rect(0, 0, bounds.width(), bounds.height())); |
| + } |
| +} |
| + |
| +void RootLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| + DCHECK(!child_); |
| + child_ = child; |
| +} |
| + |
| +void RootLayoutManager::SetChildBounds(aura::Window* child, |
| + const gfx::Rect& requested_bounds) { |
| + SetChildBoundsDirect(child, gfx::Rect(0, 0, |
|
Ben Goodger (Google)
2014/07/08 22:08:07
You can replace the second param with this:
gfx::
|
| + requested_bounds.width(), |
| + requested_bounds.height())); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| // WindowTreeHostImpl, public: |
| WindowTreeHostImpl::WindowTreeHostImpl( |
| @@ -48,6 +90,8 @@ WindowTreeHostImpl::WindowTreeHostImpl( |
| } |
| context_factory_ = new ContextFactoryImpl(pipe.handle1.Pass()); |
| aura::Env::GetInstance()->set_context_factory(context_factory_); |
| + |
| + window()->SetLayoutManager(new RootLayoutManager()); |
| } |
| WindowTreeHostImpl::~WindowTreeHostImpl() { |