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/public/cpp/window.h" | 5 #include "components/mus/public/cpp/window.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 const bool can_change = OwnsWindow(connection_, this) || is_root; | 207 const bool can_change = OwnsWindow(connection_, this) || is_root; |
208 if (!can_change) | 208 if (!can_change) |
209 return; | 209 return; |
210 if (bounds_ == bounds) | 210 if (bounds_ == bounds) |
211 return; | 211 return; |
212 if (connection_) | 212 if (connection_) |
213 static_cast<WindowTreeClientImpl*>(connection_)->SetBounds(id_, bounds); | 213 static_cast<WindowTreeClientImpl*>(connection_)->SetBounds(id_, bounds); |
214 LocalSetBounds(bounds_, bounds); | 214 LocalSetBounds(bounds_, bounds); |
215 } | 215 } |
216 | 216 |
217 void Window::SetClientArea(const gfx::Rect& client_area) { | 217 void Window::SetClientArea(const gfx::Insets& client_area) { |
218 if (!OwnsWindow(connection_, this) && !IsConnectionRoot(this)) | 218 if (!OwnsWindow(connection_, this) && !IsConnectionRoot(this)) |
219 return; | 219 return; |
220 | 220 |
221 if (connection_) { | 221 if (connection_) { |
222 static_cast<WindowTreeClientImpl*>(connection_) | 222 static_cast<WindowTreeClientImpl*>(connection_) |
223 ->SetClientArea(id_, client_area); | 223 ->SetClientArea(id_, client_area); |
224 } | 224 } |
225 LocalSetClientArea(client_area); | 225 LocalSetClientArea(client_area); |
226 } | 226 } |
227 | 227 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 bool Window::LocalReorder(Window* relative, mojom::OrderDirection direction) { | 528 bool Window::LocalReorder(Window* relative, mojom::OrderDirection direction) { |
529 return ReorderImpl(&parent_->children_, this, relative, direction); | 529 return ReorderImpl(&parent_->children_, this, relative, direction); |
530 } | 530 } |
531 | 531 |
532 void Window::LocalSetBounds(const gfx::Rect& old_bounds, | 532 void Window::LocalSetBounds(const gfx::Rect& old_bounds, |
533 const gfx::Rect& new_bounds) { | 533 const gfx::Rect& new_bounds) { |
534 // If this client owns the window, then it should be the only one to change | 534 // If this client owns the window, then it should be the only one to change |
535 // the bounds. | 535 // the bounds. |
536 DCHECK(!OwnsWindow(connection_, this) || old_bounds == bounds_); | 536 DCHECK(!OwnsWindow(connection_, this) || old_bounds == bounds_); |
537 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); | 537 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); |
538 if (bounds_.size() != new_bounds.size()) | |
539 client_area_ = gfx::Rect(new_bounds.size()); | |
540 bounds_ = new_bounds; | 538 bounds_ = new_bounds; |
541 } | 539 } |
542 | 540 |
543 void Window::LocalSetClientArea(const gfx::Rect& new_client_area) { | 541 void Window::LocalSetClientArea(const gfx::Insets& new_client_area) { |
544 const gfx::Rect old_client_area = client_area_; | 542 const gfx::Insets old_client_area = client_area_; |
545 client_area_ = new_client_area; | 543 client_area_ = new_client_area; |
546 FOR_EACH_OBSERVER(WindowObserver, observers_, | 544 FOR_EACH_OBSERVER(WindowObserver, observers_, |
547 OnWindowClientAreaChanged(this, old_client_area)); | 545 OnWindowClientAreaChanged(this, old_client_area)); |
548 } | 546 } |
549 | 547 |
550 void Window::LocalSetViewportMetrics( | 548 void Window::LocalSetViewportMetrics( |
551 const mojom::ViewportMetrics& old_metrics, | 549 const mojom::ViewportMetrics& old_metrics, |
552 const mojom::ViewportMetrics& new_metrics) { | 550 const mojom::ViewportMetrics& new_metrics) { |
553 // TODO(eseidel): We could check old_metrics against viewport_metrics_. | 551 // TODO(eseidel): We could check old_metrics against viewport_metrics_. |
554 viewport_metrics_ = new_metrics.Clone(); | 552 viewport_metrics_ = new_metrics.Clone(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 !static_cast<WindowTreeClientImpl*>(connection_)->is_embed_root()) { | 662 !static_cast<WindowTreeClientImpl*>(connection_)->is_embed_root()) { |
665 return false; | 663 return false; |
666 } | 664 } |
667 | 665 |
668 while (!children_.empty()) | 666 while (!children_.empty()) |
669 RemoveChild(children_[0]); | 667 RemoveChild(children_[0]); |
670 return true; | 668 return true; |
671 } | 669 } |
672 | 670 |
673 } // namespace mus | 671 } // namespace mus |
OLD | NEW |