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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "mojo/aura/window_tree_host_mojo_delegate.h" | 9 #include "mojo/aura/window_tree_host_mojo_delegate.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 Managers managers_; | 54 Managers managers_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(TreeHosts); | 56 DISALLOW_COPY_AND_ASSIGN(TreeHosts); |
57 }; | 57 }; |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 //////////////////////////////////////////////////////////////////////////////// | 61 //////////////////////////////////////////////////////////////////////////////// |
62 // WindowTreeHostMojo, public: | 62 // WindowTreeHostMojo, public: |
63 | 63 |
64 WindowTreeHostMojo::WindowTreeHostMojo(const gfx::Rect& bounds, | 64 WindowTreeHostMojo::WindowTreeHostMojo(view_manager::Node* node, |
65 WindowTreeHostMojoDelegate* delegate) | 65 WindowTreeHostMojoDelegate* delegate) |
66 : bounds_(bounds), | 66 : node_(node), |
| 67 bounds_(node->bounds()), |
67 delegate_(delegate) { | 68 delegate_(delegate) { |
| 69 node_->AddObserver(this); |
68 CreateCompositor(GetAcceleratedWidget()); | 70 CreateCompositor(GetAcceleratedWidget()); |
69 | 71 |
70 TreeHosts::Get()->Add(this); | 72 TreeHosts::Get()->Add(this); |
71 } | 73 } |
72 | 74 |
73 WindowTreeHostMojo::~WindowTreeHostMojo() { | 75 WindowTreeHostMojo::~WindowTreeHostMojo() { |
| 76 node_->RemoveObserver(this); |
74 TreeHosts::Get()->Remove(this); | 77 TreeHosts::Get()->Remove(this); |
75 DestroyCompositor(); | 78 DestroyCompositor(); |
76 DestroyDispatcher(); | 79 DestroyDispatcher(); |
77 } | 80 } |
78 | 81 |
79 // static | 82 // static |
80 WindowTreeHostMojo* WindowTreeHostMojo::ForCompositor( | 83 WindowTreeHostMojo* WindowTreeHostMojo::ForCompositor( |
81 ui::Compositor* compositor) { | 84 ui::Compositor* compositor) { |
82 const Managers& managers = TreeHosts::Get()->managers(); | 85 const Managers& managers = TreeHosts::Get()->managers(); |
83 for (size_t i = 0; i < managers.size(); ++i) { | 86 for (size_t i = 0; i < managers.size(); ++i) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 NOTIMPLEMENTED(); | 154 NOTIMPLEMENTED(); |
152 } | 155 } |
153 | 156 |
154 //////////////////////////////////////////////////////////////////////////////// | 157 //////////////////////////////////////////////////////////////////////////////// |
155 // WindowTreeHostMojo, ui::EventSource implementation: | 158 // WindowTreeHostMojo, ui::EventSource implementation: |
156 | 159 |
157 ui::EventProcessor* WindowTreeHostMojo::GetEventProcessor() { | 160 ui::EventProcessor* WindowTreeHostMojo::GetEventProcessor() { |
158 return dispatcher(); | 161 return dispatcher(); |
159 } | 162 } |
160 | 163 |
| 164 //////////////////////////////////////////////////////////////////////////////// |
| 165 // WindowTreeHostMojo, view_manager::NodeObserver implementation: |
| 166 |
| 167 void WindowTreeHostMojo::OnNodeBoundsChange( |
| 168 view_manager::Node* node, |
| 169 const gfx::Rect& old_bounds, |
| 170 const gfx::Rect& new_bounds, |
| 171 view_manager::NodeObserver::DispositionChangePhase phase) { |
| 172 bounds_ = new_bounds; |
| 173 if (old_bounds.origin() != new_bounds.origin()) |
| 174 OnHostMoved(bounds_.origin()); |
| 175 if (old_bounds.size() != new_bounds.size()) |
| 176 OnHostResized(bounds_.size()); |
| 177 } |
| 178 |
161 } // namespace mojo | 179 } // namespace mojo |
OLD | NEW |