Chromium Code Reviews| 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 "services/ui/public/cpp/window.h" | 5 #include "services/ui/public/cpp/window.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 // advances focus. We don't want to randomly pick a Window to get focus, so | 526 // advances focus. We don't want to randomly pick a Window to get focus, so |
| 527 // we update local state only, and wait for the next focus change from the | 527 // we update local state only, and wait for the next focus change from the |
| 528 // server. | 528 // server. |
| 529 client_->LocalSetFocus(nullptr); | 529 client_->LocalSetFocus(nullptr); |
| 530 } | 530 } |
| 531 | 531 |
| 532 // Remove from transient parent. | 532 // Remove from transient parent. |
| 533 if (transient_parent_) | 533 if (transient_parent_) |
| 534 transient_parent_->LocalRemoveTransientWindow(this); | 534 transient_parent_->LocalRemoveTransientWindow(this); |
| 535 | 535 |
| 536 // Return the surface reference if there is one. | |
| 537 if (!surface_info_.surface_id.is_null()) | |
| 538 LocalSetSurfaceId(cc::SurfaceId(), cc::SurfaceSequence(), gfx::Size(), | |
| 539 1.0f); | |
| 540 | |
| 536 // Remove transient children. | 541 // Remove transient children. |
| 537 while (!transient_children_.empty()) { | 542 while (!transient_children_.empty()) { |
| 538 Window* transient_child = transient_children_.front(); | 543 Window* transient_child = transient_children_.front(); |
| 539 LocalRemoveTransientWindow(transient_child); | 544 LocalRemoveTransientWindow(transient_child); |
| 540 transient_child->LocalDestroy(); | 545 transient_child->LocalDestroy(); |
| 541 DCHECK(transient_children_.empty() || | 546 DCHECK(transient_children_.empty() || |
| 542 transient_children_.front() != transient_child); | 547 transient_children_.front() != transient_child); |
| 543 } | 548 } |
| 544 | 549 |
| 545 if (parent_) | 550 if (parent_) |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 properties_[name] = *value; | 788 properties_[name] = *value; |
| 784 } else if (it != properties_.end()) { | 789 } else if (it != properties_.end()) { |
| 785 properties_.erase(it); | 790 properties_.erase(it); |
| 786 } | 791 } |
| 787 | 792 |
| 788 FOR_EACH_OBSERVER( | 793 FOR_EACH_OBSERVER( |
| 789 WindowObserver, observers_, | 794 WindowObserver, observers_, |
| 790 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value)); | 795 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value)); |
| 791 } | 796 } |
| 792 | 797 |
| 798 void Window::LocalSetSurfaceId(const cc::SurfaceId& surface_id, | |
| 799 const cc::SurfaceSequence& surface_sequence, | |
| 800 const gfx::Size& frame_size, | |
| 801 float device_scale_factor) { | |
| 802 const cc::SurfaceId& existing_surface_id = surface_info_.surface_id; | |
| 803 if (!existing_surface_id.is_null() && existing_surface_id != surface_id) { | |
| 804 // Return the existing surface sequence. | |
| 805 if (client_) { | |
| 806 client_->ReturnSurfaceReference(server_id_, | |
| 807 surface_info_.surface_sequence); | |
| 808 } | |
| 809 } | |
| 810 surface_info_ = {surface_id, surface_sequence, frame_size, | |
| 811 device_scale_factor}; | |
| 812 if (parent_) { | |
| 813 // TODO(fsamuel, sadrul): This assumes that observers just observe. If a | |
| 814 // ui::Layer is an observer here then it takes ownership of the | |
| 815 // SurfaceSequence and returning the refernece. | |
|
sadrul
2016/10/13 04:26:21
Each ui::Window could have some explicit SurfaceSe
Fady Samuel
2016/10/14 17:42:40
Done.
| |
| 816 for (auto& observer : parent_->observers_) { | |
| 817 observer.OnChildWindowSurfaceCreated(this, surface_id, surface_sequence, | |
| 818 frame_size, device_scale_factor); | |
| 819 } | |
| 820 } | |
| 821 } | |
| 822 | |
| 793 void Window::NotifyWindowStackingChanged() { | 823 void Window::NotifyWindowStackingChanged() { |
| 794 if (stacking_target_) { | 824 if (stacking_target_) { |
| 795 Children::const_iterator window_i = std::find( | 825 Children::const_iterator window_i = std::find( |
| 796 parent()->children().begin(), parent()->children().end(), this); | 826 parent()->children().begin(), parent()->children().end(), this); |
| 797 DCHECK(window_i != parent()->children().end()); | 827 DCHECK(window_i != parent()->children().end()); |
| 798 if (window_i != parent()->children().begin() && | 828 if (window_i != parent()->children().begin() && |
| 799 (*(window_i - 1) == stacking_target_)) | 829 (*(window_i - 1) == stacking_target_)) |
| 800 return; | 830 return; |
| 801 } | 831 } |
| 802 RestackTransientDescendants(this, &GetStackingTarget, | 832 RestackTransientDescendants(this, &GetStackingTarget, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 929 notifier->NotifyWindowReordered(); | 959 notifier->NotifyWindowReordered(); |
| 930 | 960 |
| 931 return true; | 961 return true; |
| 932 } | 962 } |
| 933 | 963 |
| 934 // static | 964 // static |
| 935 Window** Window::GetStackingTarget(Window* window) { | 965 Window** Window::GetStackingTarget(Window* window) { |
| 936 return &window->stacking_target_; | 966 return &window->stacking_target_; |
| 937 } | 967 } |
| 938 } // namespace ui | 968 } // namespace ui |
| OLD | NEW |