| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "cc/surfaces/surface_id.h" |
| 16 #include "cc/surfaces/surface_sequence.h" |
| 15 #include "services/ui/common/transient_window_utils.h" | 17 #include "services/ui/common/transient_window_utils.h" |
| 16 #include "services/ui/public/cpp/property_type_converters.h" | 18 #include "services/ui/public/cpp/property_type_converters.h" |
| 19 #include "services/ui/public/cpp/surface_id_handler.h" |
| 17 #include "services/ui/public/cpp/window_observer.h" | 20 #include "services/ui/public/cpp/window_observer.h" |
| 18 #include "services/ui/public/cpp/window_private.h" | 21 #include "services/ui/public/cpp/window_private.h" |
| 19 #include "services/ui/public/cpp/window_property.h" | 22 #include "services/ui/public/cpp/window_property.h" |
| 20 #include "services/ui/public/cpp/window_surface.h" | 23 #include "services/ui/public/cpp/window_surface.h" |
| 21 #include "services/ui/public/cpp/window_tracker.h" | 24 #include "services/ui/public/cpp/window_tracker.h" |
| 22 #include "services/ui/public/cpp/window_tree_client.h" | 25 #include "services/ui/public/cpp/window_tree_client.h" |
| 23 #include "services/ui/public/interfaces/window_manager.mojom.h" | 26 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 24 #include "ui/display/display.h" | 27 #include "ui/display/display.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 28 #include "ui/gfx/geometry/rect.h" |
| 26 #include "ui/gfx/geometry/size.h" | 29 #include "ui/gfx/geometry/size.h" |
| (...skipping 499 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 | 529 // 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 | 530 // we update local state only, and wait for the next focus change from the |
| 528 // server. | 531 // server. |
| 529 client_->LocalSetFocus(nullptr); | 532 client_->LocalSetFocus(nullptr); |
| 530 } | 533 } |
| 531 | 534 |
| 532 // Remove from transient parent. | 535 // Remove from transient parent. |
| 533 if (transient_parent_) | 536 if (transient_parent_) |
| 534 transient_parent_->LocalRemoveTransientWindow(this); | 537 transient_parent_->LocalRemoveTransientWindow(this); |
| 535 | 538 |
| 539 // Return the surface reference if there is one. |
| 540 if (!surface_info_.surface_id.is_null()) |
| 541 LocalSetSurfaceId(cc::SurfaceId(), cc::SurfaceSequence(), gfx::Size(), |
| 542 1.0f); |
| 543 |
| 536 // Remove transient children. | 544 // Remove transient children. |
| 537 while (!transient_children_.empty()) { | 545 while (!transient_children_.empty()) { |
| 538 Window* transient_child = transient_children_.front(); | 546 Window* transient_child = transient_children_.front(); |
| 539 LocalRemoveTransientWindow(transient_child); | 547 LocalRemoveTransientWindow(transient_child); |
| 540 transient_child->LocalDestroy(); | 548 transient_child->LocalDestroy(); |
| 541 DCHECK(transient_children_.empty() || | 549 DCHECK(transient_children_.empty() || |
| 542 transient_children_.front() != transient_child); | 550 transient_children_.front() != transient_child); |
| 543 } | 551 } |
| 544 | 552 |
| 545 if (parent_) | 553 if (parent_) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 575 Window::Window(WindowTreeClient* client, Id id) | 583 Window::Window(WindowTreeClient* client, Id id) |
| 576 : client_(client), | 584 : client_(client), |
| 577 server_id_(id), | 585 server_id_(id), |
| 578 parent_(nullptr), | 586 parent_(nullptr), |
| 579 stacking_target_(nullptr), | 587 stacking_target_(nullptr), |
| 580 transient_parent_(nullptr), | 588 transient_parent_(nullptr), |
| 581 is_modal_(false), | 589 is_modal_(false), |
| 582 // Matches aura, see aura::Window for details. | 590 // Matches aura, see aura::Window for details. |
| 583 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY), | 591 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY), |
| 584 input_event_handler_(nullptr), | 592 input_event_handler_(nullptr), |
| 593 surface_id_handler_(nullptr), |
| 585 visible_(false), | 594 visible_(false), |
| 586 opacity_(1.0f), | 595 opacity_(1.0f), |
| 587 display_id_(display::Display::kInvalidDisplayID), | 596 display_id_(display::Display::kInvalidDisplayID), |
| 588 cursor_id_(mojom::Cursor::CURSOR_NULL), | 597 cursor_id_(mojom::Cursor::CURSOR_NULL), |
| 589 parent_drawn_(false) {} | 598 parent_drawn_(false) {} |
| 590 | 599 |
| 591 void Window::SetSharedPropertyInternal(const std::string& name, | 600 void Window::SetSharedPropertyInternal(const std::string& name, |
| 592 const std::vector<uint8_t>* value) { | 601 const std::vector<uint8_t>* value) { |
| 593 if (!WasCreatedByThisClientOrIsRoot(this)) | 602 if (!WasCreatedByThisClientOrIsRoot(this)) |
| 594 return; | 603 return; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 properties_[name] = *value; | 792 properties_[name] = *value; |
| 784 } else if (it != properties_.end()) { | 793 } else if (it != properties_.end()) { |
| 785 properties_.erase(it); | 794 properties_.erase(it); |
| 786 } | 795 } |
| 787 | 796 |
| 788 FOR_EACH_OBSERVER( | 797 FOR_EACH_OBSERVER( |
| 789 WindowObserver, observers_, | 798 WindowObserver, observers_, |
| 790 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value)); | 799 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value)); |
| 791 } | 800 } |
| 792 | 801 |
| 802 void Window::LocalSetSurfaceId(const cc::SurfaceId& surface_id, |
| 803 const cc::SurfaceSequence& surface_sequence, |
| 804 const gfx::Size& frame_size, |
| 805 float device_scale_factor) { |
| 806 const cc::SurfaceId& existing_surface_id = surface_info_.surface_id; |
| 807 if (!existing_surface_id.is_null() && existing_surface_id != surface_id) { |
| 808 // Return the existing surface sequence. |
| 809 if (client_) { |
| 810 client_->ReturnSurfaceReference(server_id_, |
| 811 surface_info_.surface_sequence); |
| 812 } |
| 813 } |
| 814 if (parent_ && parent_->surface_id_handler_) { |
| 815 if (parent_->surface_id_handler_->OnChildWindowSurfaceCreated( |
| 816 this, surface_id, surface_sequence, frame_size, |
| 817 device_scale_factor)) { |
| 818 // Don't store it on the window if the SurfaceIdHandler has picked it up. |
| 819 surface_info_ = {cc::SurfaceId(), cc::SurfaceSequence(), gfx::Size(), |
| 820 1.0f}; |
| 821 return; |
| 822 } |
| 823 } |
| 824 surface_info_ = {surface_id, surface_sequence, frame_size, |
| 825 device_scale_factor}; |
| 826 } |
| 827 |
| 793 void Window::NotifyWindowStackingChanged() { | 828 void Window::NotifyWindowStackingChanged() { |
| 794 if (stacking_target_) { | 829 if (stacking_target_) { |
| 795 Children::const_iterator window_i = std::find( | 830 Children::const_iterator window_i = std::find( |
| 796 parent()->children().begin(), parent()->children().end(), this); | 831 parent()->children().begin(), parent()->children().end(), this); |
| 797 DCHECK(window_i != parent()->children().end()); | 832 DCHECK(window_i != parent()->children().end()); |
| 798 if (window_i != parent()->children().begin() && | 833 if (window_i != parent()->children().begin() && |
| 799 (*(window_i - 1) == stacking_target_)) | 834 (*(window_i - 1) == stacking_target_)) |
| 800 return; | 835 return; |
| 801 } | 836 } |
| 802 RestackTransientDescendants(this, &GetStackingTarget, | 837 RestackTransientDescendants(this, &GetStackingTarget, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 notifier->NotifyWindowReordered(); | 964 notifier->NotifyWindowReordered(); |
| 930 | 965 |
| 931 return true; | 966 return true; |
| 932 } | 967 } |
| 933 | 968 |
| 934 // static | 969 // static |
| 935 Window** Window::GetStackingTarget(Window* window) { | 970 Window** Window::GetStackingTarget(Window* window) { |
| 936 return &window->stacking_target_; | 971 return &window->stacking_target_; |
| 937 } | 972 } |
| 938 } // namespace ui | 973 } // namespace ui |
| OLD | NEW |