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 "components/mus/ws/server_window.h" | 5 #include "components/mus/ws/server_window.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "components/mus/ws/server_window_delegate.h" | 10 #include "components/mus/ws/server_window_delegate.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 115 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, |
116 OnWindowReordered(this, relative, direction)); | 116 OnWindowReordered(this, relative, direction)); |
117 } | 117 } |
118 | 118 |
119 void ServerWindow::SetBounds(const gfx::Rect& bounds) { | 119 void ServerWindow::SetBounds(const gfx::Rect& bounds) { |
120 if (bounds_ == bounds) | 120 if (bounds_ == bounds) |
121 return; | 121 return; |
122 | 122 |
123 // TODO(fsamuel): figure out how will this work with CompositorFrames. | 123 // TODO(fsamuel): figure out how will this work with CompositorFrames. |
124 | 124 |
125 // |client_area_| is relative to the bounds. If the size of bounds change | |
126 // we have to reset the client area. We assume any size change is quicky | |
127 // followed by a client area change. | |
128 if (bounds_.size() != bounds.size()) | |
129 client_area_ = gfx::Rect(bounds.size()); | |
130 | |
131 const gfx::Rect old_bounds = bounds_; | 125 const gfx::Rect old_bounds = bounds_; |
132 bounds_ = bounds; | 126 bounds_ = bounds; |
133 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 127 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, |
134 OnWindowBoundsChanged(this, old_bounds, bounds)); | 128 OnWindowBoundsChanged(this, old_bounds, bounds)); |
135 } | 129 } |
136 | 130 |
137 void ServerWindow::SetClientArea(const gfx::Rect& bounds) { | 131 void ServerWindow::SetClientArea(const gfx::Insets& insets) { |
138 if (client_area_ == bounds) | 132 if (client_area_ == insets) |
139 return; | 133 return; |
140 | 134 |
141 const gfx::Rect old_client_area = client_area_; | 135 const gfx::Insets old_client_area = client_area_; |
142 client_area_ = bounds; | 136 client_area_ = insets; |
143 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, | 137 FOR_EACH_OBSERVER(ServerWindowObserver, observers_, |
144 OnWindowClientAreaChanged(this, old_client_area, bounds)); | 138 OnWindowClientAreaChanged(this, old_client_area, insets)); |
145 } | 139 } |
146 | 140 |
147 const ServerWindow* ServerWindow::GetRoot() const { | 141 const ServerWindow* ServerWindow::GetRoot() const { |
148 return delegate_->GetRootWindow(this); | 142 return delegate_->GetRootWindow(this); |
149 } | 143 } |
150 | 144 |
151 std::vector<const ServerWindow*> ServerWindow::GetChildren() const { | 145 std::vector<const ServerWindow*> ServerWindow::GetChildren() const { |
152 std::vector<const ServerWindow*> children; | 146 std::vector<const ServerWindow*> children; |
153 children.reserve(children_.size()); | 147 children.reserve(children_.size()); |
154 for (size_t i = 0; i < children_.size(); ++i) | 148 for (size_t i = 0; i < children_.size(); ++i) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 #endif | 271 #endif |
278 | 272 |
279 void ServerWindow::RemoveImpl(ServerWindow* window) { | 273 void ServerWindow::RemoveImpl(ServerWindow* window) { |
280 window->parent_ = NULL; | 274 window->parent_ = NULL; |
281 children_.erase(std::find(children_.begin(), children_.end(), window)); | 275 children_.erase(std::find(children_.begin(), children_.end(), window)); |
282 } | 276 } |
283 | 277 |
284 } // namespace ws | 278 } // namespace ws |
285 | 279 |
286 } // namespace mus | 280 } // namespace mus |
OLD | NEW |