Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: services/ui/public/cpp/window.cc

Issue 2414683003: Mus+Ash: propagate Surface ID to parents (Closed)
Patch Set: updated comment Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_)
541 LocalSetSurfaceId(nullptr);
542
536 // Remove transient children. 543 // Remove transient children.
537 while (!transient_children_.empty()) { 544 while (!transient_children_.empty()) {
538 Window* transient_child = transient_children_.front(); 545 Window* transient_child = transient_children_.front();
539 LocalRemoveTransientWindow(transient_child); 546 LocalRemoveTransientWindow(transient_child);
540 transient_child->LocalDestroy(); 547 transient_child->LocalDestroy();
541 DCHECK(transient_children_.empty() || 548 DCHECK(transient_children_.empty() ||
542 transient_children_.front() != transient_child); 549 transient_children_.front() != transient_child);
543 } 550 }
544 551
545 if (parent_) 552 if (parent_)
(...skipping 29 matching lines...) Expand all
575 Window::Window(WindowTreeClient* client, Id id) 582 Window::Window(WindowTreeClient* client, Id id)
576 : client_(client), 583 : client_(client),
577 server_id_(id), 584 server_id_(id),
578 parent_(nullptr), 585 parent_(nullptr),
579 stacking_target_(nullptr), 586 stacking_target_(nullptr),
580 transient_parent_(nullptr), 587 transient_parent_(nullptr),
581 is_modal_(false), 588 is_modal_(false),
582 // Matches aura, see aura::Window for details. 589 // Matches aura, see aura::Window for details.
583 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY), 590 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY),
584 input_event_handler_(nullptr), 591 input_event_handler_(nullptr),
592 surface_id_handler_(nullptr),
585 visible_(false), 593 visible_(false),
586 opacity_(1.0f), 594 opacity_(1.0f),
587 display_id_(display::Display::kInvalidDisplayID), 595 display_id_(display::Display::kInvalidDisplayID),
588 cursor_id_(mojom::Cursor::CURSOR_NULL), 596 cursor_id_(mojom::Cursor::CURSOR_NULL),
589 parent_drawn_(false) {} 597 parent_drawn_(false) {}
590 598
591 void Window::SetSharedPropertyInternal(const std::string& name, 599 void Window::SetSharedPropertyInternal(const std::string& name,
592 const std::vector<uint8_t>* value) { 600 const std::vector<uint8_t>* value) {
593 if (!WasCreatedByThisClientOrIsRoot(this)) 601 if (!WasCreatedByThisClientOrIsRoot(this))
594 return; 602 return;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 properties_[name] = *value; 791 properties_[name] = *value;
784 } else if (it != properties_.end()) { 792 } else if (it != properties_.end()) {
785 properties_.erase(it); 793 properties_.erase(it);
786 } 794 }
787 795
788 FOR_EACH_OBSERVER( 796 FOR_EACH_OBSERVER(
789 WindowObserver, observers_, 797 WindowObserver, observers_,
790 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value)); 798 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value));
791 } 799 }
792 800
801 void Window::LocalSetSurfaceId(std::unique_ptr<SurfaceInfo> surface_info) {
802 if (surface_info_) {
803 const cc::SurfaceId& existing_surface_id = surface_info_->surface_id;
804 if (!existing_surface_id.is_null() &&
805 existing_surface_id != surface_info->surface_id) {
806 // Return the existing surface sequence.
807 if (client_) {
808 client_->ReturnSurfaceReference(server_id_,
809 surface_info_->surface_sequence);
810 }
811 }
812 }
813 if (parent_ && parent_->surface_id_handler_) {
814 parent_->surface_id_handler_->OnChildWindowSurfaceCreated(this,
815 &surface_info);
816 }
817 surface_info_ = std::move(surface_info);
818 }
819
793 void Window::NotifyWindowStackingChanged() { 820 void Window::NotifyWindowStackingChanged() {
794 if (stacking_target_) { 821 if (stacking_target_) {
795 Children::const_iterator window_i = std::find( 822 Children::const_iterator window_i = std::find(
796 parent()->children().begin(), parent()->children().end(), this); 823 parent()->children().begin(), parent()->children().end(), this);
797 DCHECK(window_i != parent()->children().end()); 824 DCHECK(window_i != parent()->children().end());
798 if (window_i != parent()->children().begin() && 825 if (window_i != parent()->children().begin() &&
799 (*(window_i - 1) == stacking_target_)) 826 (*(window_i - 1) == stacking_target_))
800 return; 827 return;
801 } 828 }
802 RestackTransientDescendants(this, &GetStackingTarget, 829 RestackTransientDescendants(this, &GetStackingTarget,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 notifier->NotifyWindowReordered(); 956 notifier->NotifyWindowReordered();
930 957
931 return true; 958 return true;
932 } 959 }
933 960
934 // static 961 // static
935 Window** Window::GetStackingTarget(Window* window) { 962 Window** Window::GetStackingTarget(Window* window) {
936 return &window->stacking_target_; 963 return &window->stacking_target_;
937 } 964 }
938 } // namespace ui 965 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698