X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmojo%2Fservices%2Fview_manager%2Fwindow_tree_host_impl.cc;h=9f201b0845a6a45905710b4198d6f8791f04d8b0;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=c344ba4bfe212224c497b238a3fa52ba676c0f0c;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/mojo/services/view_manager/window_tree_host_impl.cc b/src/mojo/services/view_manager/window_tree_host_impl.cc index c344ba4..9f201b0 100644 --- a/src/mojo/services/view_manager/window_tree_host_impl.cc +++ b/src/mojo/services/view_manager/window_tree_host_impl.cc @@ -1,13 +1,15 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Copyright 2013 The Chromium Authors. All rights reserved. // 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/public/cpp/input_events/input_events_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" @@ -17,7 +19,6 @@ #include "ui/gfx/geometry/rect.h" namespace mojo { -namespace view_manager { namespace service { // TODO(sky): nuke this. It shouldn't be static. @@ -25,14 +26,55 @@ 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( NativeViewportPtr viewport, const gfx::Rect& bounds, - const base::Callback& compositor_created_callback) + const Callback& compositor_created_callback, + const Callback& native_viewport_closed_callback, + const Callback& event_received_callback) : native_viewport_(viewport.Pass()), compositor_created_callback_(compositor_created_callback), + native_viewport_closed_callback_(native_viewport_closed_callback), + event_received_callback_(event_received_callback), bounds_(bounds) { native_viewport_.set_client(this); native_viewport_->Create(Rect::From(bounds)); @@ -48,7 +90,8 @@ WindowTreeHostImpl::WindowTreeHostImpl( } context_factory_ = new ContextFactoryImpl(pipe.handle1.Pass()); aura::Env::GetInstance()->set_context_factory(context_factory_); - CHECK(context_factory_) << "No GL bindings."; + + window()->SetLayoutManager(new RootLayoutManager()); } WindowTreeHostImpl::~WindowTreeHostImpl() { @@ -103,10 +146,6 @@ void WindowTreeHostImpl::PostNativeEvent( NOTIMPLEMENTED(); } -void WindowTreeHostImpl::OnDeviceScaleFactorChanged(float device_scale_factor) { - NOTIMPLEMENTED(); -} - void WindowTreeHostImpl::SetCursorNative(gfx::NativeCursor cursor) { NOTIMPLEMENTED(); } @@ -139,39 +178,18 @@ void WindowTreeHostImpl::OnBoundsChanged(RectPtr bounds) { OnHostResized(bounds_.size()); } -void WindowTreeHostImpl::OnDestroyed() { - base::MessageLoop::current()->Quit(); +void WindowTreeHostImpl::OnDestroyed(const mojo::Callback& callback) { + DestroyCompositor(); + native_viewport_closed_callback_.Run(); + // TODO(beng): quit the message loop once we are on our own thread. + callback.Run(); } void WindowTreeHostImpl::OnEvent(EventPtr event, const mojo::Callback& callback) { - switch (event->action) { - case ui::ET_MOUSE_PRESSED: - case ui::ET_MOUSE_DRAGGED: - case ui::ET_MOUSE_RELEASED: - case ui::ET_MOUSE_MOVED: - case ui::ET_MOUSE_ENTERED: - case ui::ET_MOUSE_EXITED: { - gfx::Point location(event->location->x, event->location->y); - ui::MouseEvent ev(static_cast(event->action), location, - location, event->flags, 0); - SendEventToProcessor(&ev); - break; - } - case ui::ET_KEY_PRESSED: - case ui::ET_KEY_RELEASED: { - ui::KeyEvent ev( - static_cast(event->action), - static_cast(event->key_data->key_code), - event->flags, event->key_data->is_char); - SendEventToProcessor(&ev); - break; - } - // TODO(beng): touch, etc. - } + event_received_callback_.Run(event.Pass()); callback.Run(); }; } // namespace service -} // namespace view_manager } // namespace mojo