| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 "mandoline/ui/aura/window_tree_host_mojo.h" | |
| 6 | |
| 7 #include "components/mus/public/cpp/view_tree_connection.h" | |
| 8 #include "mandoline/ui/aura/input_method_mandoline.h" | |
| 9 #include "mandoline/ui/aura/surface_context_factory.h" | |
| 10 #include "mojo/application/public/interfaces/shell.mojom.h" | |
| 11 #include "mojo/converters/geometry/geometry_type_converters.h" | |
| 12 #include "ui/aura/env.h" | |
| 13 #include "ui/aura/window.h" | |
| 14 #include "ui/aura/window_event_dispatcher.h" | |
| 15 #include "ui/events/event.h" | |
| 16 #include "ui/events/event_constants.h" | |
| 17 | |
| 18 namespace mandoline { | |
| 19 | |
| 20 //////////////////////////////////////////////////////////////////////////////// | |
| 21 // WindowTreeHostMojo, public: | |
| 22 | |
| 23 WindowTreeHostMojo::WindowTreeHostMojo(mojo::Shell* shell, mus::View* view) | |
| 24 : view_(view), bounds_(view->bounds().To<gfx::Rect>()) { | |
| 25 view_->AddObserver(this); | |
| 26 | |
| 27 context_factory_.reset(new SurfaceContextFactory(shell, view_)); | |
| 28 // WindowTreeHost creates the compositor using the ContextFactory from | |
| 29 // aura::Env. Install |context_factory_| there so that |context_factory_| is | |
| 30 // picked up. | |
| 31 ui::ContextFactory* default_context_factory = | |
| 32 aura::Env::GetInstance()->context_factory(); | |
| 33 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | |
| 34 CreateCompositor(); | |
| 35 OnAcceleratedWidgetAvailable(); | |
| 36 aura::Env::GetInstance()->set_context_factory(default_context_factory); | |
| 37 DCHECK_EQ(context_factory_.get(), compositor()->context_factory()); | |
| 38 | |
| 39 input_method_.reset(new InputMethodMandoline(this, view_)); | |
| 40 SetSharedInputMethod(input_method_.get()); | |
| 41 } | |
| 42 | |
| 43 WindowTreeHostMojo::~WindowTreeHostMojo() { | |
| 44 view_->RemoveObserver(this); | |
| 45 DestroyCompositor(); | |
| 46 DestroyDispatcher(); | |
| 47 } | |
| 48 | |
| 49 //////////////////////////////////////////////////////////////////////////////// | |
| 50 // WindowTreeHostMojo, aura::WindowTreeHost implementation: | |
| 51 | |
| 52 ui::EventSource* WindowTreeHostMojo::GetEventSource() { | |
| 53 return this; | |
| 54 } | |
| 55 | |
| 56 gfx::AcceleratedWidget WindowTreeHostMojo::GetAcceleratedWidget() { | |
| 57 return gfx::kNullAcceleratedWidget; | |
| 58 } | |
| 59 | |
| 60 void WindowTreeHostMojo::ShowImpl() { | |
| 61 window()->Show(); | |
| 62 } | |
| 63 | |
| 64 void WindowTreeHostMojo::HideImpl() { | |
| 65 } | |
| 66 | |
| 67 gfx::Rect WindowTreeHostMojo::GetBounds() const { | |
| 68 return bounds_; | |
| 69 } | |
| 70 | |
| 71 void WindowTreeHostMojo::SetBounds(const gfx::Rect& bounds) { | |
| 72 window()->SetBounds(gfx::Rect(bounds.size())); | |
| 73 } | |
| 74 | |
| 75 gfx::Point WindowTreeHostMojo::GetLocationOnNativeScreen() const { | |
| 76 return gfx::Point(0, 0); | |
| 77 } | |
| 78 | |
| 79 void WindowTreeHostMojo::SetCapture() { | |
| 80 NOTIMPLEMENTED(); | |
| 81 } | |
| 82 | |
| 83 void WindowTreeHostMojo::ReleaseCapture() { | |
| 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, ViewObserver implementation: | |
| 101 | |
| 102 void WindowTreeHostMojo::OnViewBoundsChanged(mus::View* view, | |
| 103 const mojo::Rect& old_bounds, | |
| 104 const mojo::Rect& new_bounds) { | |
| 105 gfx::Rect old_bounds2 = old_bounds.To<gfx::Rect>(); | |
| 106 gfx::Rect new_bounds2 = new_bounds.To<gfx::Rect>(); | |
| 107 bounds_ = new_bounds2; | |
| 108 if (old_bounds2.origin() != new_bounds2.origin()) | |
| 109 OnHostMoved(bounds_.origin()); | |
| 110 if (old_bounds2.size() != new_bounds2.size()) | |
| 111 OnHostResized(bounds_.size()); | |
| 112 } | |
| 113 | |
| 114 } // namespace mandoline | |
| OLD | NEW |