OLD | NEW |
---|---|
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 Loading... | |
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 auar::Window. |
reveman
2016/07/20 18:58:02
nit: aura::Window
xiyuan
2016/07/20 23:19:03
Done.
| |
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 manager_->RemoveSurface(this); |
101 } | 99 } |
102 | 100 |
103 gfx::Size NotificationSurface::GetSize() const { | 101 gfx::Size NotificationSurface::GetSize() const { |
104 return surface_->content_size(); | 102 return surface_->content_size(); |
105 } | 103 } |
106 | 104 |
107 void NotificationSurface::OnSurfaceCommit() { | 105 void NotificationSurface::OnSurfaceCommit() { |
108 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); | 106 surface_->CheckIfSurfaceHierarchyNeedsCommitToNewSurfaces(); |
109 surface_->CommitSurfaceHierarchy(); | 107 surface_->CommitSurfaceHierarchy(); |
110 | 108 |
111 gfx::Rect bounds = window_->bounds(); | 109 gfx::Rect bounds = window_->bounds(); |
112 if (bounds.size() != surface_->content_size()) { | 110 if (bounds.size() != surface_->content_size()) { |
113 bounds.set_size(surface_->content_size()); | 111 bounds.set_size(surface_->content_size()); |
114 window_->SetBounds(bounds); | 112 window_->SetBounds(bounds); |
reveman
2016/07/20 18:58:02
as the bounds can change here, doesn't the manager
xiyuan
2016/07/20 19:52:41
The hosting ArcCustomNotificationView is based on
reveman
2016/07/20 20:57:30
I'm not suggesting we should show it unless bounds
xiyuan
2016/07/20 22:01:20
I prefer not doing remove-then-add on bounds chang
| |
115 } | 113 } |
114 | |
115 if (!added_to_manager_) { | |
116 added_to_manager_ = true; | |
117 manager_->AddSurface(this); | |
118 } | |
116 } | 119 } |
117 | 120 |
118 bool NotificationSurface::IsSurfaceSynchronized() const { | 121 bool NotificationSurface::IsSurfaceSynchronized() const { |
119 return false; | 122 return false; |
120 } | 123 } |
121 | 124 |
122 void NotificationSurface::OnSurfaceDestroying(Surface* surface) { | 125 void NotificationSurface::OnSurfaceDestroying(Surface* surface) { |
123 window_.reset(); | 126 window_.reset(); |
124 surface->RemoveSurfaceObserver(this); | 127 surface->RemoveSurfaceObserver(this); |
125 surface_ = nullptr; | 128 surface_ = nullptr; |
126 } | 129 } |
127 | 130 |
128 } // namespace exo | 131 } // namespace exo |
OLD | NEW |