| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/aura/window_tree_host_mojo.h" | |
| 6 | |
| 7 #include "mojo/aura/surface_context_factory.h" | |
| 8 #include "mojo/converters/geometry/geometry_type_converters.h" | |
| 9 #include "mojo/public/interfaces/application/shell.mojom.h" | |
| 10 #include "mojo/services/view_manager/public/cpp/view_manager.h" | |
| 11 #include "ui/aura/env.h" | |
| 12 #include "ui/aura/window.h" | |
| 13 #include "ui/aura/window_event_dispatcher.h" | |
| 14 #include "ui/events/event.h" | |
| 15 #include "ui/events/event_constants.h" | |
| 16 | |
| 17 namespace mojo { | |
| 18 | |
| 19 //////////////////////////////////////////////////////////////////////////////// | |
| 20 // WindowTreeHostMojo, public: | |
| 21 | |
| 22 WindowTreeHostMojo::WindowTreeHostMojo(Shell* shell, View* view) | |
| 23 : view_(view), bounds_(view->bounds().To<gfx::Rect>()) { | |
| 24 view_->AddObserver(this); | |
| 25 | |
| 26 context_factory_.reset(new SurfaceContextFactory(shell, view_)); | |
| 27 // WindowTreeHost creates the compositor using the ContextFactory from | |
| 28 // aura::Env. Install |context_factory_| there so that |context_factory_| is | |
| 29 // picked up. | |
| 30 ui::ContextFactory* default_context_factory = | |
| 31 aura::Env::GetInstance()->context_factory(); | |
| 32 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | |
| 33 CreateCompositor(GetAcceleratedWidget()); | |
| 34 aura::Env::GetInstance()->set_context_factory(default_context_factory); | |
| 35 DCHECK_EQ(context_factory_.get(), compositor()->context_factory()); | |
| 36 } | |
| 37 | |
| 38 WindowTreeHostMojo::~WindowTreeHostMojo() { | |
| 39 view_->RemoveObserver(this); | |
| 40 DestroyCompositor(); | |
| 41 DestroyDispatcher(); | |
| 42 } | |
| 43 | |
| 44 //////////////////////////////////////////////////////////////////////////////// | |
| 45 // WindowTreeHostMojo, aura::WindowTreeHost implementation: | |
| 46 | |
| 47 ui::EventSource* WindowTreeHostMojo::GetEventSource() { | |
| 48 return this; | |
| 49 } | |
| 50 | |
| 51 gfx::AcceleratedWidget WindowTreeHostMojo::GetAcceleratedWidget() { | |
| 52 return gfx::kNullAcceleratedWidget; | |
| 53 } | |
| 54 | |
| 55 void WindowTreeHostMojo::Show() { | |
| 56 window()->Show(); | |
| 57 } | |
| 58 | |
| 59 void WindowTreeHostMojo::Hide() { | |
| 60 } | |
| 61 | |
| 62 gfx::Rect WindowTreeHostMojo::GetBounds() const { | |
| 63 return bounds_; | |
| 64 } | |
| 65 | |
| 66 void WindowTreeHostMojo::SetBounds(const gfx::Rect& bounds) { | |
| 67 window()->SetBounds(gfx::Rect(bounds.size())); | |
| 68 } | |
| 69 | |
| 70 gfx::Point WindowTreeHostMojo::GetLocationOnNativeScreen() const { | |
| 71 return gfx::Point(0, 0); | |
| 72 } | |
| 73 | |
| 74 void WindowTreeHostMojo::SetCapture() { | |
| 75 NOTIMPLEMENTED(); | |
| 76 } | |
| 77 | |
| 78 void WindowTreeHostMojo::ReleaseCapture() { | |
| 79 NOTIMPLEMENTED(); | |
| 80 } | |
| 81 | |
| 82 void WindowTreeHostMojo::PostNativeEvent( | |
| 83 const base::NativeEvent& native_event) { | |
| 84 NOTIMPLEMENTED(); | |
| 85 } | |
| 86 | |
| 87 void WindowTreeHostMojo::SetCursorNative(gfx::NativeCursor cursor) { | |
| 88 NOTIMPLEMENTED(); | |
| 89 } | |
| 90 | |
| 91 void WindowTreeHostMojo::MoveCursorToNative(const gfx::Point& location) { | |
| 92 NOTIMPLEMENTED(); | |
| 93 } | |
| 94 | |
| 95 void WindowTreeHostMojo::OnCursorVisibilityChangedNative(bool show) { | |
| 96 NOTIMPLEMENTED(); | |
| 97 } | |
| 98 | |
| 99 //////////////////////////////////////////////////////////////////////////////// | |
| 100 // WindowTreeHostMojo, ui::EventSource implementation: | |
| 101 | |
| 102 ui::EventProcessor* WindowTreeHostMojo::GetEventProcessor() { | |
| 103 return dispatcher(); | |
| 104 } | |
| 105 | |
| 106 //////////////////////////////////////////////////////////////////////////////// | |
| 107 // WindowTreeHostMojo, ViewObserver implementation: | |
| 108 | |
| 109 void WindowTreeHostMojo::OnViewBoundsChanged( | |
| 110 View* view, | |
| 111 const Rect& old_bounds, | |
| 112 const Rect& new_bounds) { | |
| 113 gfx::Rect old_bounds2 = old_bounds.To<gfx::Rect>(); | |
| 114 gfx::Rect new_bounds2 = new_bounds.To<gfx::Rect>(); | |
| 115 bounds_ = new_bounds2; | |
| 116 if (old_bounds2.origin() != new_bounds2.origin()) | |
| 117 OnHostMoved(bounds_.origin()); | |
| 118 if (old_bounds2.size() != new_bounds2.size()) | |
| 119 OnHostResized(bounds_.size()); | |
| 120 } | |
| 121 | |
| 122 } // namespace mojo | |
| OLD | NEW |