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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/mus/public/cpp/lib/window_tree_client_impl.cc
diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.cc b/components/mus/public/cpp/lib/window_tree_client_impl.cc
index a07a43b644ec63ab66a3293515bcb0f88478c5fe..7d2a79537bf8fbdf4ff1069c135b2c5f5a5c4577 100644
--- a/components/mus/public/cpp/lib/window_tree_client_impl.cc
+++ b/components/mus/public/cpp/lib/window_tree_client_impl.cc
@@ -130,7 +130,7 @@ WindowTreeClientImpl::~WindowTreeClientImpl() {
std::vector<Window*> non_owned;
while (!windows_.empty()) {
IdToWindowMap::iterator it = windows_.begin();
- if (OwnsWindow(it->second->id())) {
+ if (OwnsWindow(it->second)) {
it->second->Destroy();
} else {
non_owned.push_back(it->second);
@@ -201,8 +201,10 @@ void WindowTreeClientImpl::Reorder(Window* window,
tree_->ReorderWindow(change_id, window->id(), relative_window_id, direction);
}
-bool WindowTreeClientImpl::OwnsWindow(Id id) const {
- return HiWord(id) == connection_id_;
+bool WindowTreeClientImpl::OwnsWindow(Window* window) const {
+ // Windows created via CreateTopLevelWindow() are not owned by us, but have
+ // our connection id.
+ return HiWord(window->id()) == connection_id_ && roots_.count(window) == 0;
}
void WindowTreeClientImpl::SetBounds(Window* window,
@@ -383,6 +385,35 @@ bool WindowTreeClientImpl::ApplyServerChangeToExistingInFlightChange(
return true;
}
+Window* WindowTreeClientImpl::NewWindowImpl(
+ NewWindowType type,
+ const Window::SharedProperties* properties) {
+ DCHECK(tree_);
+ Window* window =
+ new Window(this, MakeTransportId(connection_id_, next_window_id_++));
+ if (properties)
+ window->properties_ = *properties;
+ AddWindow(window);
+
+ const uint32_t change_id = ScheduleInFlightChange(make_scoped_ptr(
+ new CrashInFlightChange(window, type == NewWindowType::CHILD
+ ? ChangeType::NEW_WINDOW
+ : ChangeType::NEW_TOP_LEVEL_WINDOW)));
+ mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties;
+ if (properties) {
+ transport_properties =
+ mojo::Map<mojo::String, mojo::Array<uint8_t>>::From(*properties);
+ }
+ if (type == NewWindowType::CHILD) {
+ tree_->NewWindow(change_id, window->id(), std::move(transport_properties));
+ } else {
+ roots_.insert(window);
+ tree_->NewTopLevelWindow(change_id, window->id(),
+ std::move(transport_properties));
+ }
+ return window;
+}
+
void WindowTreeClientImpl::OnEmbedImpl(mojom::WindowTree* window_tree,
ConnectionSpecificId connection_id,
mojom::WindowDataPtr root_data,
@@ -429,22 +460,12 @@ Window* WindowTreeClientImpl::GetFocusedWindow() {
Window* WindowTreeClientImpl::NewWindow(
const Window::SharedProperties* properties) {
- DCHECK(tree_);
- Window* window =
- new Window(this, MakeTransportId(connection_id_, next_window_id_++));
- if (properties)
- window->properties_ = *properties;
- AddWindow(window);
+ return NewWindowImpl(NewWindowType::CHILD, properties);
+}
- const uint32_t change_id = ScheduleInFlightChange(
- make_scoped_ptr(new CrashInFlightChange(window, ChangeType::NEW_WINDOW)));
- mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties;
- if (properties) {
- transport_properties =
- mojo::Map<mojo::String, mojo::Array<uint8_t>>::From(*properties);
- }
- tree_->NewWindow(change_id, window->id(), std::move(transport_properties));
- return window;
+Window* WindowTreeClientImpl::NewTopLevelWindow(
+ const Window::SharedProperties* properties) {
+ return NewWindowImpl(NewWindowType::TOP_LEVEL, properties);
}
bool WindowTreeClientImpl::IsEmbedRoot() {
@@ -766,4 +787,15 @@ void WindowTreeClientImpl::WmSetProperty(uint32_t change_id,
window_manager_internal_client_->WmResponse(change_id, result);
}
+void WindowTreeClientImpl::WmCreateTopLevelWindow(
+ uint32_t change_id,
+ mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) {
+ std::map<std::string, std::vector<uint8_t>> properties =
+ transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
+ Window* window =
+ window_manager_delegate_->OnWmCreateTopLevelWindow(&properties);
+ window_manager_internal_client_->OnWmCreatedTopLevelWindow(change_id,
+ window->id());
+}
+
} // namespace mus
« 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