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..5ef5da4af19576bdc6fdf8a7b56e7576f3141de8 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,43 @@ 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_) |
+ child_->SetBounds(gfx::Rect(child_->parent()->bounds().size())); |
+} |
+ |
+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(requested_bounds.size())); |
+} |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
// WindowTreeHostImpl, public: |
WindowTreeHostImpl::WindowTreeHostImpl( |
@@ -48,6 +86,8 @@ WindowTreeHostImpl::WindowTreeHostImpl( |
} |
context_factory_ = new ContextFactoryImpl(pipe.handle1.Pass()); |
aura::Env::GetInstance()->set_context_factory(context_factory_); |
+ |
+ window()->SetLayoutManager(new RootLayoutManager()); |
} |
WindowTreeHostImpl::~WindowTreeHostImpl() { |