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

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

Issue 2414683003: Mus+Ash: propagate Surface ID to parents (Closed)
Patch Set: Don't follow null surface_info 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
« no previous file with comments | « services/ui/public/cpp/window.h ('k') | services/ui/public/cpp/window_private.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/ui/common/transient_window_utils.h" 15 #include "services/ui/common/transient_window_utils.h"
16 #include "services/ui/public/cpp/property_type_converters.h" 16 #include "services/ui/public/cpp/property_type_converters.h"
17 #include "services/ui/public/cpp/surface_id_handler.h"
17 #include "services/ui/public/cpp/window_observer.h" 18 #include "services/ui/public/cpp/window_observer.h"
18 #include "services/ui/public/cpp/window_private.h" 19 #include "services/ui/public/cpp/window_private.h"
19 #include "services/ui/public/cpp/window_property.h" 20 #include "services/ui/public/cpp/window_property.h"
20 #include "services/ui/public/cpp/window_surface.h" 21 #include "services/ui/public/cpp/window_surface.h"
21 #include "services/ui/public/cpp/window_tracker.h" 22 #include "services/ui/public/cpp/window_tracker.h"
22 #include "services/ui/public/cpp/window_tree_client.h" 23 #include "services/ui/public/cpp/window_tree_client.h"
23 #include "services/ui/public/interfaces/window_manager.mojom.h" 24 #include "services/ui/public/interfaces/window_manager.mojom.h"
24 #include "ui/display/display.h" 25 #include "ui/display/display.h"
25 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
26 #include "ui/gfx/geometry/size.h" 27 #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 527 // 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 528 // we update local state only, and wait for the next focus change from the
528 // server. 529 // server.
529 client_->LocalSetFocus(nullptr); 530 client_->LocalSetFocus(nullptr);
530 } 531 }
531 532
532 // Remove from transient parent. 533 // Remove from transient parent.
533 if (transient_parent_) 534 if (transient_parent_)
534 transient_parent_->LocalRemoveTransientWindow(this); 535 transient_parent_->LocalRemoveTransientWindow(this);
535 536
537 // Return the surface reference if there is one.
538 if (surface_info_)
539 LocalSetSurfaceId(nullptr);
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 29 matching lines...) Expand all
575 Window::Window(WindowTreeClient* client, Id id) 580 Window::Window(WindowTreeClient* client, Id id)
576 : client_(client), 581 : client_(client),
577 server_id_(id), 582 server_id_(id),
578 parent_(nullptr), 583 parent_(nullptr),
579 stacking_target_(nullptr), 584 stacking_target_(nullptr),
580 transient_parent_(nullptr), 585 transient_parent_(nullptr),
581 is_modal_(false), 586 is_modal_(false),
582 // Matches aura, see aura::Window for details. 587 // Matches aura, see aura::Window for details.
583 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY), 588 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY),
584 input_event_handler_(nullptr), 589 input_event_handler_(nullptr),
590 surface_id_handler_(nullptr),
585 visible_(false), 591 visible_(false),
586 opacity_(1.0f), 592 opacity_(1.0f),
587 display_id_(display::Display::kInvalidDisplayID), 593 display_id_(display::Display::kInvalidDisplayID),
588 cursor_id_(mojom::Cursor::CURSOR_NULL), 594 cursor_id_(mojom::Cursor::CURSOR_NULL),
589 parent_drawn_(false) {} 595 parent_drawn_(false) {}
590 596
591 void Window::SetSharedPropertyInternal(const std::string& name, 597 void Window::SetSharedPropertyInternal(const std::string& name,
592 const std::vector<uint8_t>* value) { 598 const std::vector<uint8_t>* value) {
593 if (!WasCreatedByThisClientOrIsRoot(this)) 599 if (!WasCreatedByThisClientOrIsRoot(this))
594 return; 600 return;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 properties_[name] = *value; 789 properties_[name] = *value;
784 } else if (it != properties_.end()) { 790 } else if (it != properties_.end()) {
785 properties_.erase(it); 791 properties_.erase(it);
786 } 792 }
787 793
788 FOR_EACH_OBSERVER( 794 FOR_EACH_OBSERVER(
789 WindowObserver, observers_, 795 WindowObserver, observers_,
790 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value)); 796 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value));
791 } 797 }
792 798
799 void Window::LocalSetSurfaceId(std::unique_ptr<SurfaceInfo> surface_info) {
800 if (surface_info_) {
801 const cc::SurfaceId& existing_surface_id = surface_info_->surface_id;
802 cc::SurfaceId new_surface_id =
803 surface_info ? surface_info->surface_id : cc::SurfaceId();
804 if (!existing_surface_id.is_null() &&
805 existing_surface_id != new_surface_id) {
806 // Return the existing surface sequence.
807 if (client_) {
808 client_->OnWindowSurfaceDetached(server_id_,
809 surface_info_->surface_sequence);
810 }
811 }
812 }
813 if (parent_ && parent_->surface_id_handler_) {
814 parent_->surface_id_handler_->OnChildWindowSurfaceChanged(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
« no previous file with comments | « services/ui/public/cpp/window.h ('k') | services/ui/public/cpp/window_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698