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

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

Issue 2559703003: Converts WindowTreeClientTest to be in terms of aura (Closed)
Patch Set: feedback Created 4 years 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 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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 DCHECK(tree_); 257 DCHECK(tree_);
258 tree_->SetImeVisibility(window->server_id(), visible, std::move(state)); 258 tree_->SetImeVisibility(window->server_id(), visible, std::move(state));
259 } 259 }
260 260
261 void WindowTreeClient::Embed( 261 void WindowTreeClient::Embed(
262 Window* window, 262 Window* window,
263 ui::mojom::WindowTreeClientPtr client, 263 ui::mojom::WindowTreeClientPtr client,
264 uint32_t flags, 264 uint32_t flags,
265 const ui::mojom::WindowTree::EmbedCallback& callback) { 265 const ui::mojom::WindowTree::EmbedCallback& callback) {
266 DCHECK(tree_); 266 DCHECK(tree_);
267 if (!window->children().empty()) {
268 // The window server removes all children before embedding. In other words,
269 // it's generally an error to Embed() with existing children. So, fail
270 // early.
271 callback.Run(false);
272 return;
273 }
274
267 tree_->Embed(WindowMus::Get(window)->server_id(), std::move(client), flags, 275 tree_->Embed(WindowMus::Get(window)->server_id(), std::move(client), flags,
268 callback); 276 callback);
269 } 277 }
270 278
271 void WindowTreeClient::AttachCompositorFrameSink( 279 void WindowTreeClient::AttachCompositorFrameSink(
272 Id window_id, 280 Id window_id,
273 ui::mojom::CompositorFrameSinkType type, 281 ui::mojom::CompositorFrameSinkType type,
274 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink, 282 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink,
275 cc::mojom::MojoCompositorFrameSinkClientPtr client) { 283 cc::mojom::MojoCompositorFrameSinkClientPtr client) {
276 DCHECK(tree_); 284 DCHECK(tree_);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 596
589 // Remove any InFlightChanges associated with the window. 597 // Remove any InFlightChanges associated with the window.
590 std::set<uint32_t> in_flight_change_ids_to_remove; 598 std::set<uint32_t> in_flight_change_ids_to_remove;
591 for (const auto& pair : in_flight_map_) { 599 for (const auto& pair : in_flight_map_) {
592 if (pair.second->window() == window) 600 if (pair.second->window() == window)
593 in_flight_change_ids_to_remove.insert(pair.first); 601 in_flight_change_ids_to_remove.insert(pair.first);
594 } 602 }
595 for (auto change_id : in_flight_change_ids_to_remove) 603 for (auto change_id : in_flight_change_ids_to_remove)
596 in_flight_map_.erase(change_id); 604 in_flight_map_.erase(change_id);
597 605
598 const bool was_root = roots_.erase(window) > 0; 606 roots_.erase(window);
599 if (!in_destructor_ && was_root && roots_.empty() && is_from_embed_)
600 delegate_->OnEmbedRootDestroyed(window->GetWindow());
601 } 607 }
602 608
603 void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window, 609 void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window,
604 const gfx::Rect& old_bounds, 610 const gfx::Rect& old_bounds,
605 const gfx::Rect& new_bounds) { 611 const gfx::Rect& new_bounds) {
606 // Changes to bounds of root windows are routed through 612 // Changes to bounds of root windows are routed through
607 // OnWindowTreeHostBoundsWillChange(). Any bounds that happen here are a side 613 // OnWindowTreeHostBoundsWillChange(). Any bounds that happen here are a side
608 // effect of those and can be ignored. 614 // effect of those and can be ignored.
609 if (IsRoot(window)) 615 if (IsRoot(window))
610 return; 616 return;
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 WindowMus* relative_window = GetWindowByServerId(relative_window_id); 1000 WindowMus* relative_window = GetWindowByServerId(relative_window_id);
995 WindowMus* parent = WindowMus::Get(window->GetWindow()->parent()); 1001 WindowMus* parent = WindowMus::Get(window->GetWindow()->parent());
996 if (window && relative_window && parent && 1002 if (window && relative_window && parent &&
997 parent == WindowMus::Get(relative_window->GetWindow()->parent())) { 1003 parent == WindowMus::Get(relative_window->GetWindow()->parent())) {
998 parent->ReorderFromServer(window, relative_window, direction); 1004 parent->ReorderFromServer(window, relative_window, direction);
999 } 1005 }
1000 } 1006 }
1001 1007
1002 void WindowTreeClient::OnWindowDeleted(Id window_id) { 1008 void WindowTreeClient::OnWindowDeleted(Id window_id) {
1003 WindowMus* window = GetWindowByServerId(window_id); 1009 WindowMus* window = GetWindowByServerId(window_id);
1004 if (window) 1010 if (!window)
1011 return;
1012
1013 if (roots_.count(window)) {
1014 // Roots are associated with WindowTreeHosts. The WindowTreeHost owns the
1015 // root, so we have to delete the WindowTreeHost to indirectly delete the
1016 // Window. Additionally clients may want to do extra processing before the
1017 // delete, so call to the delegate to handle it. Let the window know it is
1018 // going to be deleted so we don't callback to the server.
1019 window->PrepareForDestroy();
1020 delegate_->OnEmbedRootDestroyed(GetWindowTreeHostMus(window));
1021 } else {
1005 window->DestroyFromServer(); 1022 window->DestroyFromServer();
1023 }
1006 } 1024 }
1007 1025
1008 void WindowTreeClient::OnWindowVisibilityChanged(Id window_id, bool visible) { 1026 void WindowTreeClient::OnWindowVisibilityChanged(Id window_id, bool visible) {
1009 WindowMus* window = GetWindowByServerId(window_id); 1027 WindowMus* window = GetWindowByServerId(window_id);
1010 if (!window) 1028 if (!window)
1011 return; 1029 return;
1012 1030
1013 InFlightVisibleChange new_change(this, window, visible); 1031 InFlightVisibleChange new_change(this, window, visible);
1014 if (ApplyServerChangeToExistingInFlightChange(new_change)) 1032 if (ApplyServerChangeToExistingInFlightChange(new_change))
1015 return; 1033 return;
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1639 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1622 this, capture_synchronizer_.get(), window)); 1640 this, capture_synchronizer_.get(), window));
1623 } 1641 }
1624 1642
1625 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1643 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1626 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1644 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1627 this, focus_synchronizer_.get(), window)); 1645 this, focus_synchronizer_.get(), window));
1628 } 1646 }
1629 1647
1630 } // namespace aura 1648 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698