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

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

Issue 2424633002: Revert of Mus+Ash: propagate Surface ID to parents (Closed)
Patch Set: 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"
18 #include "services/ui/public/cpp/window_observer.h" 17 #include "services/ui/public/cpp/window_observer.h"
19 #include "services/ui/public/cpp/window_private.h" 18 #include "services/ui/public/cpp/window_private.h"
20 #include "services/ui/public/cpp/window_property.h" 19 #include "services/ui/public/cpp/window_property.h"
21 #include "services/ui/public/cpp/window_surface.h" 20 #include "services/ui/public/cpp/window_surface.h"
22 #include "services/ui/public/cpp/window_tracker.h" 21 #include "services/ui/public/cpp/window_tracker.h"
23 #include "services/ui/public/cpp/window_tree_client.h" 22 #include "services/ui/public/cpp/window_tree_client.h"
24 #include "services/ui/public/interfaces/window_manager.mojom.h" 23 #include "services/ui/public/interfaces/window_manager.mojom.h"
25 #include "ui/display/display.h" 24 #include "ui/display/display.h"
26 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
27 #include "ui/gfx/geometry/size.h" 26 #include "ui/gfx/geometry/size.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 // 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
528 // 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
529 // server. 528 // server.
530 client_->LocalSetFocus(nullptr); 529 client_->LocalSetFocus(nullptr);
531 } 530 }
532 531
533 // Remove from transient parent. 532 // Remove from transient parent.
534 if (transient_parent_) 533 if (transient_parent_)
535 transient_parent_->LocalRemoveTransientWindow(this); 534 transient_parent_->LocalRemoveTransientWindow(this);
536 535
537 // Return the surface reference if there is one.
538 if (surface_info_)
539 LocalSetSurfaceId(nullptr);
540
541 // Remove transient children. 536 // Remove transient children.
542 while (!transient_children_.empty()) { 537 while (!transient_children_.empty()) {
543 Window* transient_child = transient_children_.front(); 538 Window* transient_child = transient_children_.front();
544 LocalRemoveTransientWindow(transient_child); 539 LocalRemoveTransientWindow(transient_child);
545 transient_child->LocalDestroy(); 540 transient_child->LocalDestroy();
546 DCHECK(transient_children_.empty() || 541 DCHECK(transient_children_.empty() ||
547 transient_children_.front() != transient_child); 542 transient_children_.front() != transient_child);
548 } 543 }
549 544
550 if (parent_) 545 if (parent_)
(...skipping 29 matching lines...) Expand all
580 Window::Window(WindowTreeClient* client, Id id) 575 Window::Window(WindowTreeClient* client, Id id)
581 : client_(client), 576 : client_(client),
582 server_id_(id), 577 server_id_(id),
583 parent_(nullptr), 578 parent_(nullptr),
584 stacking_target_(nullptr), 579 stacking_target_(nullptr),
585 transient_parent_(nullptr), 580 transient_parent_(nullptr),
586 is_modal_(false), 581 is_modal_(false),
587 // Matches aura, see aura::Window for details. 582 // Matches aura, see aura::Window for details.
588 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY), 583 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY),
589 input_event_handler_(nullptr), 584 input_event_handler_(nullptr),
590 surface_id_handler_(nullptr),
591 visible_(false), 585 visible_(false),
592 opacity_(1.0f), 586 opacity_(1.0f),
593 display_id_(display::Display::kInvalidDisplayID), 587 display_id_(display::Display::kInvalidDisplayID),
594 cursor_id_(mojom::Cursor::CURSOR_NULL), 588 cursor_id_(mojom::Cursor::CURSOR_NULL),
595 parent_drawn_(false) {} 589 parent_drawn_(false) {}
596 590
597 void Window::SetSharedPropertyInternal(const std::string& name, 591 void Window::SetSharedPropertyInternal(const std::string& name,
598 const std::vector<uint8_t>* value) { 592 const std::vector<uint8_t>* value) {
599 if (!WasCreatedByThisClientOrIsRoot(this)) 593 if (!WasCreatedByThisClientOrIsRoot(this))
600 return; 594 return;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 properties_[name] = *value; 783 properties_[name] = *value;
790 } else if (it != properties_.end()) { 784 } else if (it != properties_.end()) {
791 properties_.erase(it); 785 properties_.erase(it);
792 } 786 }
793 787
794 FOR_EACH_OBSERVER( 788 FOR_EACH_OBSERVER(
795 WindowObserver, observers_, 789 WindowObserver, observers_,
796 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value)); 790 OnWindowSharedPropertyChanged(this, name, old_value_ptr, value));
797 } 791 }
798 792
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 if (!existing_surface_id.is_null() &&
803 existing_surface_id != surface_info->surface_id) {
804 // Return the existing surface sequence.
805 if (client_) {
806 client_->OnWindowSurfaceDetached(server_id_,
807 surface_info_->surface_sequence);
808 }
809 }
810 }
811 if (parent_ && parent_->surface_id_handler_) {
812 parent_->surface_id_handler_->OnChildWindowSurfaceChanged(this,
813 &surface_info);
814 }
815 surface_info_ = std::move(surface_info);
816 }
817
818 void Window::NotifyWindowStackingChanged() { 793 void Window::NotifyWindowStackingChanged() {
819 if (stacking_target_) { 794 if (stacking_target_) {
820 Children::const_iterator window_i = std::find( 795 Children::const_iterator window_i = std::find(
821 parent()->children().begin(), parent()->children().end(), this); 796 parent()->children().begin(), parent()->children().end(), this);
822 DCHECK(window_i != parent()->children().end()); 797 DCHECK(window_i != parent()->children().end());
823 if (window_i != parent()->children().begin() && 798 if (window_i != parent()->children().begin() &&
824 (*(window_i - 1) == stacking_target_)) 799 (*(window_i - 1) == stacking_target_))
825 return; 800 return;
826 } 801 }
827 RestackTransientDescendants(this, &GetStackingTarget, 802 RestackTransientDescendants(this, &GetStackingTarget,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 notifier->NotifyWindowReordered(); 929 notifier->NotifyWindowReordered();
955 930
956 return true; 931 return true;
957 } 932 }
958 933
959 // static 934 // static
960 Window** Window::GetStackingTarget(Window* window) { 935 Window** Window::GetStackingTarget(Window* window) {
961 return &window->stacking_target_; 936 return &window->stacking_target_;
962 } 937 }
963 } // namespace ui 938 } // 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