OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/aura/window_tree_host_mojo.h" | 5 #include "mojo/aura/window_tree_host_mojo.h" |
6 | 6 |
7 #include "mojo/aura/surface_context_factory.h" | 7 #include "mojo/aura/surface_context_factory.h" |
| 8 #include "mojo/converters/geometry/geometry_type_converters.h" |
8 #include "mojo/public/interfaces/application/shell.mojom.h" | 9 #include "mojo/public/interfaces/application/shell.mojom.h" |
9 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 10 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
10 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
11 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
12 #include "ui/aura/window_event_dispatcher.h" | 13 #include "ui/aura/window_event_dispatcher.h" |
13 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
14 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 | 18 |
18 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
19 // WindowTreeHostMojo, public: | 20 // WindowTreeHostMojo, public: |
20 | 21 |
21 WindowTreeHostMojo::WindowTreeHostMojo(Shell* shell, View* view) | 22 WindowTreeHostMojo::WindowTreeHostMojo(Shell* shell, View* view) |
22 : view_(view), bounds_(view->bounds()) { | 23 : view_(view), bounds_(view->bounds().To<gfx::Rect>()) { |
23 view_->AddObserver(this); | 24 view_->AddObserver(this); |
24 | 25 |
25 context_factory_.reset(new SurfaceContextFactory(shell, view_)); | 26 context_factory_.reset(new SurfaceContextFactory(shell, view_)); |
26 // WindowTreeHost creates the compositor using the ContextFactory from | 27 // WindowTreeHost creates the compositor using the ContextFactory from |
27 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 28 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
28 // picked up. | 29 // picked up. |
29 ui::ContextFactory* default_context_factory = | 30 ui::ContextFactory* default_context_factory = |
30 aura::Env::GetInstance()->context_factory(); | 31 aura::Env::GetInstance()->context_factory(); |
31 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 32 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
32 CreateCompositor(GetAcceleratedWidget()); | 33 CreateCompositor(GetAcceleratedWidget()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 101 |
101 ui::EventProcessor* WindowTreeHostMojo::GetEventProcessor() { | 102 ui::EventProcessor* WindowTreeHostMojo::GetEventProcessor() { |
102 return dispatcher(); | 103 return dispatcher(); |
103 } | 104 } |
104 | 105 |
105 //////////////////////////////////////////////////////////////////////////////// | 106 //////////////////////////////////////////////////////////////////////////////// |
106 // WindowTreeHostMojo, ViewObserver implementation: | 107 // WindowTreeHostMojo, ViewObserver implementation: |
107 | 108 |
108 void WindowTreeHostMojo::OnViewBoundsChanged( | 109 void WindowTreeHostMojo::OnViewBoundsChanged( |
109 View* view, | 110 View* view, |
110 const gfx::Rect& old_bounds, | 111 const Rect& old_bounds, |
111 const gfx::Rect& new_bounds) { | 112 const Rect& new_bounds) { |
112 bounds_ = new_bounds; | 113 gfx::Rect old_bounds2 = old_bounds.To<gfx::Rect>(); |
113 if (old_bounds.origin() != new_bounds.origin()) | 114 gfx::Rect new_bounds2 = new_bounds.To<gfx::Rect>(); |
| 115 bounds_ = new_bounds2; |
| 116 if (old_bounds2.origin() != new_bounds2.origin()) |
114 OnHostMoved(bounds_.origin()); | 117 OnHostMoved(bounds_.origin()); |
115 if (old_bounds.size() != new_bounds.size()) | 118 if (old_bounds2.size() != new_bounds2.size()) |
116 OnHostResized(bounds_.size()); | 119 OnHostResized(bounds_.size()); |
117 } | 120 } |
118 | 121 |
119 } // namespace mojo | 122 } // namespace mojo |
OLD | NEW |