Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: mandoline/ui/aura/window_tree_host_mojo.cc

Issue 1123643007: Restore aura support from Mojo repo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mandoline/ui/aura/window_tree_host_mojo.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/view_manager/public/cpp/view_manager.h"
8 #include "mandoline/ui/aura/surface_context_factory.h"
9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/public/interfaces/application/shell.mojom.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 mandoline {
18
19 ////////////////////////////////////////////////////////////////////////////////
20 // WindowTreeHostMojo, public:
21
22 WindowTreeHostMojo::WindowTreeHostMojo(mojo::Shell* shell, mojo::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::SetCursorNative(gfx::NativeCursor cursor) {
83 NOTIMPLEMENTED();
84 }
85
86 void WindowTreeHostMojo::MoveCursorToNative(const gfx::Point& location) {
87 NOTIMPLEMENTED();
88 }
89
90 void WindowTreeHostMojo::OnCursorVisibilityChangedNative(bool show) {
91 NOTIMPLEMENTED();
92 }
93
94 ////////////////////////////////////////////////////////////////////////////////
95 // WindowTreeHostMojo, ui::EventSource implementation:
96
97 ui::EventProcessor* WindowTreeHostMojo::GetEventProcessor() {
98 return dispatcher();
99 }
100
101 ////////////////////////////////////////////////////////////////////////////////
102 // WindowTreeHostMojo, ViewObserver implementation:
103
104 void WindowTreeHostMojo::OnViewBoundsChanged(
105 mojo::View* view,
106 const mojo::Rect& old_bounds,
107 const mojo::Rect& new_bounds) {
108 gfx::Rect old_bounds2 = old_bounds.To<gfx::Rect>();
109 gfx::Rect new_bounds2 = new_bounds.To<gfx::Rect>();
110 bounds_ = new_bounds2;
111 if (old_bounds2.origin() != new_bounds2.origin())
112 OnHostMoved(bounds_.origin());
113 if (old_bounds2.size() != new_bounds2.size())
114 OnHostResized(bounds_.size());
115 }
116
117 } // namespace mandoline
OLDNEW
« no previous file with comments | « mandoline/ui/aura/window_tree_host_mojo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698