| OLD | NEW |
| 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/ws/window_tree_impl.h" | 5 #include "components/mus/ws/window_tree_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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 target_ = nullptr; | 57 target_ = nullptr; |
| 58 } | 58 } |
| 59 | 59 |
| 60 ServerWindow* target_; | 60 ServerWindow* target_; |
| 61 mojom::EventPtr event_; | 61 mojom::EventPtr event_; |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(TargetedEvent); | 63 DISALLOW_COPY_AND_ASSIGN(TargetedEvent); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 WindowTreeImpl::WindowTreeImpl(ConnectionManager* connection_manager, | 66 WindowTreeImpl::WindowTreeImpl(ConnectionManager* connection_manager, |
| 67 ConnectionSpecificId creator_id, | |
| 68 const WindowId& root_id, | 67 const WindowId& root_id, |
| 69 uint32_t policy_bitmask) | 68 uint32_t policy_bitmask) |
| 70 : connection_manager_(connection_manager), | 69 : connection_manager_(connection_manager), |
| 71 id_(connection_manager_->GetAndAdvanceNextConnectionId()), | 70 id_(connection_manager_->GetAndAdvanceNextConnectionId()), |
| 72 creator_id_(creator_id), | |
| 73 client_(nullptr), | 71 client_(nullptr), |
| 74 event_ack_id_(0), | 72 event_ack_id_(0), |
| 75 is_embed_root_(false), | 73 is_embed_root_(false), |
| 76 window_manager_internal_(nullptr) { | 74 window_manager_internal_(nullptr) { |
| 77 ServerWindow* window = GetWindow(root_id); | 75 ServerWindow* window = GetWindow(root_id); |
| 78 CHECK(window); | 76 CHECK(window); |
| 79 root_.reset(new WindowId(root_id)); | 77 root_.reset(new WindowId(root_id)); |
| 80 if (window->GetRoot() == window) { | 78 if (window->GetRoot() == window) { |
| 81 access_policy_.reset(new WindowManagerAccessPolicy(id_, this)); | 79 access_policy_.reset(new WindowManagerAccessPolicy(id_, this)); |
| 82 is_embed_root_ = true; | 80 is_embed_root_ = true; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return root_.get() && *root_ == id; | 124 return root_.get() && *root_ == id; |
| 127 } | 125 } |
| 128 | 126 |
| 129 WindowTreeHostImpl* WindowTreeImpl::GetHost() const { | 127 WindowTreeHostImpl* WindowTreeImpl::GetHost() const { |
| 130 return root_.get() | 128 return root_.get() |
| 131 ? connection_manager_->GetWindowTreeHostByWindow(GetWindow(*root_)) | 129 ? connection_manager_->GetWindowTreeHostByWindow(GetWindow(*root_)) |
| 132 : nullptr; | 130 : nullptr; |
| 133 } | 131 } |
| 134 | 132 |
| 135 void WindowTreeImpl::OnWillDestroyWindowTreeImpl(WindowTreeImpl* connection) { | 133 void WindowTreeImpl::OnWillDestroyWindowTreeImpl(WindowTreeImpl* connection) { |
| 136 if (creator_id_ == connection->id()) | |
| 137 creator_id_ = kInvalidConnectionId; | |
| 138 const ServerWindow* connection_root = | 134 const ServerWindow* connection_root = |
| 139 connection->root_ ? connection->GetWindow(*connection->root_) : nullptr; | 135 connection->root_ ? connection->GetWindow(*connection->root_) : nullptr; |
| 140 if (connection_root && | 136 if (connection_root && |
| 141 ((connection_root->id().connection_id == id_ && | 137 ((connection_root->id().connection_id == id_ && |
| 142 window_map_.count(connection_root->id().window_id) > 0) || | 138 window_map_.count(connection_root->id().window_id) > 0) || |
| 143 (is_embed_root_ && IsWindowKnown(connection_root)))) { | 139 (is_embed_root_ && IsWindowKnown(connection_root)))) { |
| 144 client()->OnEmbeddedAppDisconnected( | 140 client()->OnEmbeddedAppDisconnected( |
| 145 WindowIdToTransportId(*connection->root_)); | 141 WindowIdToTransportId(*connection->root_)); |
| 146 } | 142 } |
| 147 if (root_.get() && root_->connection_id == connection->id()) | 143 if (root_.get() && root_->connection_id == connection->id()) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 214 |
| 219 bool WindowTreeImpl::Embed(const WindowId& window_id, | 215 bool WindowTreeImpl::Embed(const WindowId& window_id, |
| 220 mojom::WindowTreeClientPtr client, | 216 mojom::WindowTreeClientPtr client, |
| 221 uint32_t policy_bitmask, | 217 uint32_t policy_bitmask, |
| 222 ConnectionSpecificId* connection_id) { | 218 ConnectionSpecificId* connection_id) { |
| 223 *connection_id = kInvalidConnectionId; | 219 *connection_id = kInvalidConnectionId; |
| 224 if (!client.get() || !CanEmbed(window_id, policy_bitmask)) | 220 if (!client.get() || !CanEmbed(window_id, policy_bitmask)) |
| 225 return false; | 221 return false; |
| 226 PrepareForEmbed(window_id); | 222 PrepareForEmbed(window_id); |
| 227 WindowTreeImpl* new_connection = connection_manager_->EmbedAtWindow( | 223 WindowTreeImpl* new_connection = connection_manager_->EmbedAtWindow( |
| 228 id_, window_id, policy_bitmask, std::move(client)); | 224 window_id, policy_bitmask, std::move(client)); |
| 229 if (is_embed_root_) | 225 if (is_embed_root_) |
| 230 *connection_id = new_connection->id(); | 226 *connection_id = new_connection->id(); |
| 231 return true; | 227 return true; |
| 232 } | 228 } |
| 233 | 229 |
| 234 void WindowTreeImpl::DispatchInputEvent(ServerWindow* target, | 230 void WindowTreeImpl::DispatchInputEvent(ServerWindow* target, |
| 235 mojom::EventPtr event) { | 231 mojom::EventPtr event) { |
| 236 if (event_ack_id_) { | 232 if (event_ack_id_) { |
| 237 // This is currently waiting for an event ack. Add it to the queue. | 233 // This is currently waiting for an event ack. Add it to the queue. |
| 238 event_queue_.push( | 234 event_queue_.push( |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 return connection && connection != this; | 1004 return connection && connection != this; |
| 1009 } | 1005 } |
| 1010 | 1006 |
| 1011 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { | 1007 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { |
| 1012 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); | 1008 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); |
| 1013 } | 1009 } |
| 1014 | 1010 |
| 1015 } // namespace ws | 1011 } // namespace ws |
| 1016 | 1012 |
| 1017 } // namespace mus | 1013 } // namespace mus |
| OLD | NEW |