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

Side by Side Diff: ui/aura/mus/window_port_mus.cc

Issue 2456843004: Wires up transient windows for aura-mus (Closed)
Patch Set: Created 4 years, 1 month 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 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 "ui/aura/mus/window_port_mus.h" 5 #include "ui/aura/mus/window_port_mus.h"
6 6
7 #include "ui/aura/client/aura_constants.h" 7 #include "ui/aura/client/aura_constants.h"
8 #include "ui/aura/client/transient_window_client.h"
8 #include "ui/aura/mus/property_converter.h" 9 #include "ui/aura/mus/property_converter.h"
9 #include "ui/aura/mus/surface_id_handler.h" 10 #include "ui/aura/mus/surface_id_handler.h"
10 #include "ui/aura/mus/window_tree_client.h" 11 #include "ui/aura/mus/window_tree_client.h"
11 #include "ui/aura/mus/window_tree_client_delegate.h" 12 #include "ui/aura/mus/window_tree_client_delegate.h"
12 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
13 #include "ui/aura/window_observer.h" 14 #include "ui/aura/window_observer.h"
14 #include "ui/aura/window_property.h" 15 #include "ui/aura/window_property.h"
15 16
16 namespace aura { 17 namespace aura {
17 18
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 78
78 bool WindowPortMus::RemoveChangeByTypeAndData(const ServerChangeType type, 79 bool WindowPortMus::RemoveChangeByTypeAndData(const ServerChangeType type,
79 const ServerChangeData& data) { 80 const ServerChangeData& data) {
80 for (auto iter = server_changes_.begin(); iter != server_changes_.end(); 81 for (auto iter = server_changes_.begin(); iter != server_changes_.end();
81 ++iter) { 82 ++iter) {
82 if (iter->type != type) 83 if (iter->type != type)
83 continue; 84 continue;
84 85
85 switch (type) { 86 switch (type) {
86 case ServerChangeType::ADD: 87 case ServerChangeType::ADD:
88 case ServerChangeType::ADD_TRANSIENT:
87 case ServerChangeType::REMOVE: 89 case ServerChangeType::REMOVE:
90 case ServerChangeType::REMOVE_TRANSIENT:
88 case ServerChangeType::REORDER: 91 case ServerChangeType::REORDER:
89 if (iter->data.child_id == data.child_id) 92 if (iter->data.child_id == data.child_id)
90 break; 93 break;
91 continue; 94 continue;
92 case ServerChangeType::BOUNDS: 95 case ServerChangeType::BOUNDS:
93 if (iter->data.bounds == data.bounds) 96 if (iter->data.bounds == data.bounds)
94 break; 97 break;
95 continue; 98 continue;
96 case ServerChangeType::PROPERTY: 99 case ServerChangeType::PROPERTY:
97 if (iter->data.property_name == data.property_name) 100 if (iter->data.property_name == data.property_name)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 208 }
206 } 209 }
207 WindowPortMus* parent = Get(window_->parent()); 210 WindowPortMus* parent = Get(window_->parent());
208 if (parent && parent->surface_id_handler_) { 211 if (parent && parent->surface_id_handler_) {
209 parent->surface_id_handler_->OnChildWindowSurfaceChanged(window_, 212 parent->surface_id_handler_->OnChildWindowSurfaceChanged(window_,
210 &surface_info); 213 &surface_info);
211 } 214 }
212 surface_info_ = std::move(surface_info); 215 surface_info_ = std::move(surface_info);
213 } 216 }
214 217
218 void WindowPortMus::AddTransientChildFromServer(WindowMus* child) {
219 DCHECK(has_server_window());
220 ServerChangeData data;
221 data.child_id = child->server_id();
222 ScopedServerChange change(this, ServerChangeType::ADD_TRANSIENT, data);
223 client::GetTransientWindowClient()->AddTransientChild(window_,
224 child->GetWindow());
225 }
226
227 void WindowPortMus::RemoveTransientChildFromServer(WindowMus* child) {
228 DCHECK(has_server_window());
229 ServerChangeData data;
230 data.child_id = child->server_id();
231 ScopedServerChange change(this, ServerChangeType::REMOVE_TRANSIENT, data);
232 client::GetTransientWindowClient()->RemoveTransientChild(window_,
233 child->GetWindow());
234 }
235
236 WindowPortMus::ChangeSource WindowPortMus::OnTransientChildAdded(
237 WindowMus* child) {
238 DCHECK(has_server_window());
239 ServerChangeData change_data;
240 change_data.child_id = child->server_id();
241 return RemoveChangeByTypeAndData(ServerChangeType::ADD_TRANSIENT, change_data)
242 ? ChangeSource::SERVER
243 : ChangeSource::LOCAL;
244 }
245
246 WindowPortMus::ChangeSource WindowPortMus::OnTransientChildRemoved(
247 WindowMus* child) {
248 DCHECK(has_server_window());
249 ServerChangeData change_data;
250 change_data.child_id = child->server_id();
251 return RemoveChangeByTypeAndData(ServerChangeType::REMOVE_TRANSIENT,
252 change_data)
253 ? ChangeSource::SERVER
254 : ChangeSource::LOCAL;
255 }
256
215 std::unique_ptr<WindowMusChangeData> 257 std::unique_ptr<WindowMusChangeData>
216 WindowPortMus::PrepareForServerBoundsChange(const gfx::Rect& bounds) { 258 WindowPortMus::PrepareForServerBoundsChange(const gfx::Rect& bounds) {
217 std::unique_ptr<WindowMusChangeDataImpl> data( 259 std::unique_ptr<WindowMusChangeDataImpl> data(
218 base::MakeUnique<WindowMusChangeDataImpl>()); 260 base::MakeUnique<WindowMusChangeDataImpl>());
219 ServerChangeData change_data; 261 ServerChangeData change_data;
220 change_data.bounds = bounds; 262 change_data.bounds = bounds;
221 data->change = base::MakeUnique<ScopedServerChange>( 263 data->change = base::MakeUnique<ScopedServerChange>(
222 this, ServerChangeType::BOUNDS, change_data); 264 this, ServerChangeType::BOUNDS, change_data);
223 return std::move(data); 265 return std::move(data);
224 } 266 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 change_data.property_name = 361 change_data.property_name =
320 GetPropertyConverter()->GetTransportNameForPropertyKey(key); 362 GetPropertyConverter()->GetTransportNameForPropertyKey(key);
321 // TODO(sky): investigate to see if we need to compare data. In particular do 363 // TODO(sky): investigate to see if we need to compare data. In particular do
322 // we ever have a case where changing a property cascades into changing the 364 // we ever have a case where changing a property cascades into changing the
323 // same property? 365 // same property?
324 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) 366 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data))
325 window_tree_client_->OnWindowMusPropertyChanged(this, key, std::move(data)); 367 window_tree_client_->OnWindowMusPropertyChanged(this, key, std::move(data));
326 } 368 }
327 369
328 } // namespace aura 370 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698