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

Side by Side Diff: components/mus/public/cpp/lib/window_tree_client_impl.cc

Issue 1567623003: Adds remainder of support for multiple roots to WS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 4 years, 11 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
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 "components/mus/public/cpp/lib/window_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 if (request.is_pending()) 123 if (request.is_pending())
124 binding_.Bind(std::move(request)); 124 binding_.Bind(std::move(request));
125 } 125 }
126 126
127 WindowTreeClientImpl::~WindowTreeClientImpl() { 127 WindowTreeClientImpl::~WindowTreeClientImpl() {
128 in_destructor_ = true; 128 in_destructor_ = true;
129 129
130 std::vector<Window*> non_owned; 130 std::vector<Window*> non_owned;
131 while (!windows_.empty()) { 131 while (!windows_.empty()) {
132 IdToWindowMap::iterator it = windows_.begin(); 132 IdToWindowMap::iterator it = windows_.begin();
133 if (OwnsWindow(it->second->id())) { 133 if (OwnsWindow(it->second)) {
134 it->second->Destroy(); 134 it->second->Destroy();
135 } else { 135 } else {
136 non_owned.push_back(it->second); 136 non_owned.push_back(it->second);
137 windows_.erase(it); 137 windows_.erase(it);
138 } 138 }
139 } 139 }
140 140
141 // Delete the non-owned windows last. In the typical case these are roots. The 141 // Delete the non-owned windows last. In the typical case these are roots. The
142 // exception is the window manager and embed roots, which may know about 142 // exception is the window manager and embed roots, which may know about
143 // other random windows that it doesn't own. 143 // other random windows that it doesn't own.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 void WindowTreeClientImpl::Reorder(Window* window, 195 void WindowTreeClientImpl::Reorder(Window* window,
196 Id relative_window_id, 196 Id relative_window_id,
197 mojom::OrderDirection direction) { 197 mojom::OrderDirection direction) {
198 DCHECK(tree_); 198 DCHECK(tree_);
199 const uint32_t change_id = ScheduleInFlightChange( 199 const uint32_t change_id = ScheduleInFlightChange(
200 make_scoped_ptr(new CrashInFlightChange(window, ChangeType::REORDER))); 200 make_scoped_ptr(new CrashInFlightChange(window, ChangeType::REORDER)));
201 tree_->ReorderWindow(change_id, window->id(), relative_window_id, direction); 201 tree_->ReorderWindow(change_id, window->id(), relative_window_id, direction);
202 } 202 }
203 203
204 bool WindowTreeClientImpl::OwnsWindow(Id id) const { 204 bool WindowTreeClientImpl::OwnsWindow(Window* window) const {
205 return HiWord(id) == connection_id_; 205 // Windows created via CreateTopLevelWindow() are not owned by us, but have
206 // our connection id.
207 return HiWord(window->id()) == connection_id_ && roots_.count(window) == 0;
206 } 208 }
207 209
208 void WindowTreeClientImpl::SetBounds(Window* window, 210 void WindowTreeClientImpl::SetBounds(Window* window,
209 const gfx::Rect& old_bounds, 211 const gfx::Rect& old_bounds,
210 const gfx::Rect& bounds) { 212 const gfx::Rect& bounds) {
211 DCHECK(tree_); 213 DCHECK(tree_);
212 const uint32_t change_id = ScheduleInFlightChange( 214 const uint32_t change_id = ScheduleInFlightChange(
213 make_scoped_ptr(new InFlightBoundsChange(window, old_bounds))); 215 make_scoped_ptr(new InFlightBoundsChange(window, old_bounds)));
214 tree_->SetWindowBounds(change_id, window->id(), mojo::Rect::From(bounds)); 216 tree_->SetWindowBounds(change_id, window->id(), mojo::Rect::From(bounds));
215 } 217 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 bool WindowTreeClientImpl::ApplyServerChangeToExistingInFlightChange( 378 bool WindowTreeClientImpl::ApplyServerChangeToExistingInFlightChange(
377 const InFlightChange& change) { 379 const InFlightChange& change) {
378 InFlightChange* existing_change = GetOldestInFlightChangeMatching(change); 380 InFlightChange* existing_change = GetOldestInFlightChangeMatching(change);
379 if (!existing_change) 381 if (!existing_change)
380 return false; 382 return false;
381 383
382 existing_change->SetRevertValueFrom(change); 384 existing_change->SetRevertValueFrom(change);
383 return true; 385 return true;
384 } 386 }
385 387
388 Window* WindowTreeClientImpl::NewWindowImpl(
389 NewWindowType type,
390 const Window::SharedProperties* properties) {
391 DCHECK(tree_);
392 Window* window =
393 new Window(this, MakeTransportId(connection_id_, next_window_id_++));
394 if (properties)
395 window->properties_ = *properties;
396 AddWindow(window);
397
398 const uint32_t change_id = ScheduleInFlightChange(make_scoped_ptr(
399 new CrashInFlightChange(window, type == NewWindowType::CHILD
400 ? ChangeType::NEW_WINDOW
401 : ChangeType::NEW_TOP_LEVEL_WINDOW)));
402 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties;
403 if (properties) {
404 transport_properties =
405 mojo::Map<mojo::String, mojo::Array<uint8_t>>::From(*properties);
406 }
407 if (type == NewWindowType::CHILD) {
408 tree_->NewWindow(change_id, window->id(), std::move(transport_properties));
409 } else {
410 roots_.insert(window);
411 tree_->NewTopLevelWindow(change_id, window->id(),
412 std::move(transport_properties));
413 }
414 return window;
415 }
416
386 void WindowTreeClientImpl::OnEmbedImpl(mojom::WindowTree* window_tree, 417 void WindowTreeClientImpl::OnEmbedImpl(mojom::WindowTree* window_tree,
387 ConnectionSpecificId connection_id, 418 ConnectionSpecificId connection_id,
388 mojom::WindowDataPtr root_data, 419 mojom::WindowDataPtr root_data,
389 Id focused_window_id, 420 Id focused_window_id,
390 uint32_t access_policy) { 421 uint32_t access_policy) {
391 tree_ = window_tree; 422 tree_ = window_tree;
392 connection_id_ = connection_id; 423 connection_id_ = connection_id;
393 is_embed_root_ = 424 is_embed_root_ =
394 (access_policy & mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT) != 0; 425 (access_policy & mojom::WindowTree::ACCESS_POLICY_EMBED_ROOT) != 0;
395 426
(...skipping 26 matching lines...) Expand all
422 IdToWindowMap::const_iterator it = windows_.find(id); 453 IdToWindowMap::const_iterator it = windows_.find(id);
423 return it != windows_.end() ? it->second : NULL; 454 return it != windows_.end() ? it->second : NULL;
424 } 455 }
425 456
426 Window* WindowTreeClientImpl::GetFocusedWindow() { 457 Window* WindowTreeClientImpl::GetFocusedWindow() {
427 return focused_window_; 458 return focused_window_;
428 } 459 }
429 460
430 Window* WindowTreeClientImpl::NewWindow( 461 Window* WindowTreeClientImpl::NewWindow(
431 const Window::SharedProperties* properties) { 462 const Window::SharedProperties* properties) {
432 DCHECK(tree_); 463 return NewWindowImpl(NewWindowType::CHILD, properties);
433 Window* window = 464 }
434 new Window(this, MakeTransportId(connection_id_, next_window_id_++));
435 if (properties)
436 window->properties_ = *properties;
437 AddWindow(window);
438 465
439 const uint32_t change_id = ScheduleInFlightChange( 466 Window* WindowTreeClientImpl::NewTopLevelWindow(
440 make_scoped_ptr(new CrashInFlightChange(window, ChangeType::NEW_WINDOW))); 467 const Window::SharedProperties* properties) {
441 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties; 468 return NewWindowImpl(NewWindowType::TOP_LEVEL, properties);
442 if (properties) {
443 transport_properties =
444 mojo::Map<mojo::String, mojo::Array<uint8_t>>::From(*properties);
445 }
446 tree_->NewWindow(change_id, window->id(), std::move(transport_properties));
447 return window;
448 } 469 }
449 470
450 bool WindowTreeClientImpl::IsEmbedRoot() { 471 bool WindowTreeClientImpl::IsEmbedRoot() {
451 return is_embed_root_; 472 return is_embed_root_;
452 } 473 }
453 474
454 ConnectionSpecificId WindowTreeClientImpl::GetConnectionId() { 475 ConnectionSpecificId WindowTreeClientImpl::GetConnectionId() {
455 return connection_id_; 476 return connection_id_;
456 } 477 }
457 478
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 result = window_manager_delegate_->OnWmSetProperty(window, name, &data); 780 result = window_manager_delegate_->OnWmSetProperty(window, name, &data);
760 if (result) { 781 if (result) {
761 // If the resulting bounds differ return false. Returning false ensures 782 // If the resulting bounds differ return false. Returning false ensures
762 // the client applies the bounds we set below. 783 // the client applies the bounds we set below.
763 window->SetSharedPropertyInternal(name, data.get()); 784 window->SetSharedPropertyInternal(name, data.get());
764 } 785 }
765 } 786 }
766 window_manager_internal_client_->WmResponse(change_id, result); 787 window_manager_internal_client_->WmResponse(change_id, result);
767 } 788 }
768 789
790 void WindowTreeClientImpl::WmCreateTopLevelWindow(
791 uint32_t change_id,
792 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) {
793 std::map<std::string, std::vector<uint8_t>> properties =
794 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
795 Window* window =
796 window_manager_delegate_->OnWmCreateTopLevelWindow(&properties);
797 window_manager_internal_client_->OnWmCreatedTopLevelWindow(change_id,
798 window->id());
799 }
800
769 } // namespace mus 801 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/window_tree_client_impl.h ('k') | components/mus/public/cpp/tests/test_window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698