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

Side by Side Diff: components/exo/notification_surface.cc

Issue 2169513003: exo: Add notification surface to manager after commit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nit, update dtor and only AddSurface when there are contents Created 4 years, 5 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 | « components/exo/notification_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/exo/notification_surface.h" 5 #include "components/exo/notification_surface.h"
6 6
7 #include "components/exo/notification_surface_manager.h" 7 #include "components/exo/notification_surface_manager.h"
8 #include "components/exo/surface.h" 8 #include "components/exo/surface.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/aura/window_delegate.h" 10 #include "ui/aura/window_delegate.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 notification_id_(notification_id), 78 notification_id_(notification_id),
79 window_(new aura::Window(new CustomWindowDelegate(surface))) { 79 window_(new aura::Window(new CustomWindowDelegate(surface))) {
80 surface_->SetSurfaceDelegate(this); 80 surface_->SetSurfaceDelegate(this);
81 surface_->AddSurfaceObserver(this); 81 surface_->AddSurfaceObserver(this);
82 82
83 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); 83 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL);
84 window_->SetName("ExoNotificationSurface"); 84 window_->SetName("ExoNotificationSurface");
85 window_->Init(ui::LAYER_NOT_DRAWN); 85 window_->Init(ui::LAYER_NOT_DRAWN);
86 window_->set_owned_by_parent(false); 86 window_->set_owned_by_parent(false);
87 87
88 // TODO(xiyuan): Fix after Surface no longer has an auar::Window. 88 // TODO(xiyuan): Fix after Surface no longer has an aura::Window.
89 window_->AddChild(surface_->window()); 89 window_->AddChild(surface_->window());
90 surface_->window()->Show(); 90 surface_->window()->Show();
91
92 manager_->AddSurface(this);
93 } 91 }
94 92
95 NotificationSurface::~NotificationSurface() { 93 NotificationSurface::~NotificationSurface() {
96 if (surface_) { 94 if (surface_) {
97 surface_->SetSurfaceDelegate(nullptr); 95 surface_->SetSurfaceDelegate(nullptr);
98 surface_->RemoveSurfaceObserver(this); 96 surface_->RemoveSurfaceObserver(this);
99 } 97 }
100 manager_->RemoveSurface(this); 98 if (added_to_manager_)
99 manager_->RemoveSurface(this);
101 } 100 }
102 101
103 gfx::Size NotificationSurface::GetSize() const { 102 gfx::Size NotificationSurface::GetSize() const {
104 return surface_->content_size(); 103 return surface_->content_size();
105 } 104 }
106 105
107 void NotificationSurface::OnSurfaceCommit() { 106 void NotificationSurface::OnSurfaceCommit() {
108 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); 107 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces();
109 surface_->CommitSurfaceHierarchy(); 108 surface_->CommitSurfaceHierarchy();
110 109
111 gfx::Rect bounds = window_->bounds(); 110 gfx::Rect bounds = window_->bounds();
112 if (bounds.size() != surface_->content_size()) { 111 if (bounds.size() != surface_->content_size()) {
113 bounds.set_size(surface_->content_size()); 112 bounds.set_size(surface_->content_size());
114 window_->SetBounds(bounds); 113 window_->SetBounds(bounds);
115 } 114 }
115
116 // Defer AddSurface until there are contents to show.
117 if (!added_to_manager_ && !surface_->content_size().IsEmpty()) {
118 added_to_manager_ = true;
119 manager_->AddSurface(this);
120 }
116 } 121 }
117 122
118 bool NotificationSurface::IsSurfaceSynchronized() const { 123 bool NotificationSurface::IsSurfaceSynchronized() const {
119 return false; 124 return false;
120 } 125 }
121 126
122 void NotificationSurface::OnSurfaceDestroying(Surface* surface) { 127 void NotificationSurface::OnSurfaceDestroying(Surface* surface) {
123 window_.reset(); 128 window_.reset();
124 surface->RemoveSurfaceObserver(this); 129 surface->RemoveSurfaceObserver(this);
125 surface_ = nullptr; 130 surface_ = nullptr;
126 } 131 }
127 132
128 } // namespace exo 133 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/notification_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698