| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 is_embed_root_(false), | 73 is_embed_root_(false), |
| 74 window_manager_internal_(nullptr) { | 74 window_manager_internal_(nullptr) { |
| 75 ServerWindow* window = GetWindow(root_id); | 75 ServerWindow* window = GetWindow(root_id); |
| 76 CHECK(window); | 76 CHECK(window); |
| 77 root_.reset(new WindowId(root_id)); | 77 root_.reset(new WindowId(root_id)); |
| 78 if (window->GetRoot() == window) { | 78 if (window->GetRoot() == window) { |
| 79 access_policy_.reset(new WindowManagerAccessPolicy(id_, this)); | 79 access_policy_.reset(new WindowManagerAccessPolicy(id_, this)); |
| 80 is_embed_root_ = true; | 80 is_embed_root_ = true; |
| 81 } else { | 81 } else { |
| 82 access_policy_.reset(new DefaultAccessPolicy(id_, this)); | 82 access_policy_.reset(new DefaultAccessPolicy(id_, this)); |
| 83 is_embed_root_ = | 83 is_embed_root_ = (policy_bitmask & WindowTree::kAccessPolicyEmbedRoot) != 0; |
| 84 (policy_bitmask & WindowTree::ACCESS_POLICY_EMBED_ROOT) != 0; | |
| 85 } | 84 } |
| 86 } | 85 } |
| 87 | 86 |
| 88 WindowTreeImpl::~WindowTreeImpl() { | 87 WindowTreeImpl::~WindowTreeImpl() { |
| 89 DestroyWindows(); | 88 DestroyWindows(); |
| 90 } | 89 } |
| 91 | 90 |
| 92 void WindowTreeImpl::Init(mojom::WindowTreeClient* client, | 91 void WindowTreeImpl::Init(mojom::WindowTreeClient* client, |
| 93 mojom::WindowTreePtr tree) { | 92 mojom::WindowTreePtr tree) { |
| 94 DCHECK(!client_); | 93 DCHECK(!client_); |
| 95 client_ = client; | 94 client_ = client; |
| 96 std::vector<const ServerWindow*> to_send; | 95 std::vector<const ServerWindow*> to_send; |
| 97 if (root_.get()) | 96 if (root_.get()) |
| 98 GetUnknownWindowsFrom(GetWindow(*root_), &to_send); | 97 GetUnknownWindowsFrom(GetWindow(*root_), &to_send); |
| 99 | 98 |
| 100 // TODO(beng): verify that host can actually be nullptr here. | 99 // TODO(beng): verify that host can actually be nullptr here. |
| 101 WindowTreeHostImpl* host = GetHost(); | 100 WindowTreeHostImpl* host = GetHost(); |
| 102 const ServerWindow* focused_window = | 101 const ServerWindow* focused_window = |
| 103 host ? host->GetFocusedWindow() : nullptr; | 102 host ? host->GetFocusedWindow() : nullptr; |
| 104 if (focused_window) | 103 if (focused_window) |
| 105 focused_window = access_policy_->GetWindowForFocusChange(focused_window); | 104 focused_window = access_policy_->GetWindowForFocusChange(focused_window); |
| 106 const Id focused_window_transport_id(WindowIdToTransportId( | 105 const Id focused_window_transport_id(WindowIdToTransportId( |
| 107 focused_window ? focused_window->id() : WindowId())); | 106 focused_window ? focused_window->id() : WindowId())); |
| 108 | 107 |
| 109 client->OnEmbed(id_, WindowToWindowData(to_send.front()), std::move(tree), | 108 client->OnEmbed(id_, WindowToWindowData(to_send.front()), std::move(tree), |
| 110 focused_window_transport_id, | 109 focused_window_transport_id, |
| 111 is_embed_root_ ? WindowTree::ACCESS_POLICY_EMBED_ROOT | 110 is_embed_root_ ? WindowTree::kAccessPolicyEmbedRoot |
| 112 : WindowTree::ACCESS_POLICY_DEFAULT); | 111 : WindowTree::kAccessPolicyDefault); |
| 113 } | 112 } |
| 114 | 113 |
| 115 const ServerWindow* WindowTreeImpl::GetWindow(const WindowId& id) const { | 114 const ServerWindow* WindowTreeImpl::GetWindow(const WindowId& id) const { |
| 116 if (id_ == id.connection_id) { | 115 if (id_ == id.connection_id) { |
| 117 WindowMap::const_iterator i = window_map_.find(id.window_id); | 116 WindowMap::const_iterator i = window_map_.find(id.window_id); |
| 118 return i == window_map_.end() ? NULL : i->second; | 117 return i == window_map_.end() ? NULL : i->second; |
| 119 } | 118 } |
| 120 return connection_manager_->GetWindow(id); | 119 return connection_manager_->GetWindow(id); |
| 121 } | 120 } |
| 122 | 121 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 139 (is_embed_root_ && IsWindowKnown(connection_root)))) { | 138 (is_embed_root_ && IsWindowKnown(connection_root)))) { |
| 140 client()->OnEmbeddedAppDisconnected( | 139 client()->OnEmbeddedAppDisconnected( |
| 141 WindowIdToTransportId(*connection->root_)); | 140 WindowIdToTransportId(*connection->root_)); |
| 142 } | 141 } |
| 143 } | 142 } |
| 144 | 143 |
| 145 void WindowTreeImpl::NotifyChangeCompleted( | 144 void WindowTreeImpl::NotifyChangeCompleted( |
| 146 uint32_t change_id, | 145 uint32_t change_id, |
| 147 mojom::WindowManagerErrorCode error_code) { | 146 mojom::WindowManagerErrorCode error_code) { |
| 148 client_->OnChangeCompleted( | 147 client_->OnChangeCompleted( |
| 149 change_id, error_code == mojom::WINDOW_MANAGER_ERROR_CODE_SUCCESS); | 148 change_id, error_code == mojom::WindowManagerErrorCode::SUCCESS); |
| 150 } | 149 } |
| 151 | 150 |
| 152 bool WindowTreeImpl::NewWindow( | 151 bool WindowTreeImpl::NewWindow( |
| 153 const WindowId& window_id, | 152 const WindowId& window_id, |
| 154 const std::map<std::string, std::vector<uint8_t>>& properties) { | 153 const std::map<std::string, std::vector<uint8_t>>& properties) { |
| 155 if (window_id.connection_id != id_) | 154 if (window_id.connection_id != id_) |
| 156 return false; | 155 return false; |
| 157 if (window_map_.find(window_id.window_id) != window_map_.end()) | 156 if (window_map_.find(window_id.window_id) != window_map_.end()) |
| 158 return false; | 157 return false; |
| 159 window_map_[window_id.window_id] = | 158 window_map_[window_id.window_id] = |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 484 |
| 486 if (!access_policy_->CanReorderWindow(window, relative_window, direction)) | 485 if (!access_policy_->CanReorderWindow(window, relative_window, direction)) |
| 487 return false; | 486 return false; |
| 488 | 487 |
| 489 std::vector<const ServerWindow*> children = window->parent()->GetChildren(); | 488 std::vector<const ServerWindow*> children = window->parent()->GetChildren(); |
| 490 const size_t child_i = | 489 const size_t child_i = |
| 491 std::find(children.begin(), children.end(), window) - children.begin(); | 490 std::find(children.begin(), children.end(), window) - children.begin(); |
| 492 const size_t target_i = | 491 const size_t target_i = |
| 493 std::find(children.begin(), children.end(), relative_window) - | 492 std::find(children.begin(), children.end(), relative_window) - |
| 494 children.begin(); | 493 children.begin(); |
| 495 if ((direction == mojom::ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || | 494 if ((direction == mojom::OrderDirection::ABOVE && child_i == target_i + 1) || |
| 496 (direction == mojom::ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { | 495 (direction == mojom::OrderDirection::BELOW && child_i + 1 == target_i)) { |
| 497 return false; | 496 return false; |
| 498 } | 497 } |
| 499 | 498 |
| 500 return true; | 499 return true; |
| 501 } | 500 } |
| 502 | 501 |
| 503 bool WindowTreeImpl::DeleteWindowImpl(WindowTreeImpl* source, | 502 bool WindowTreeImpl::DeleteWindowImpl(WindowTreeImpl* source, |
| 504 ServerWindow* window) { | 503 ServerWindow* window) { |
| 505 DCHECK(window); | 504 DCHECK(window); |
| 506 DCHECK_EQ(window->id().connection_id, id_); | 505 DCHECK_EQ(window->id().connection_id, id_); |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 return connection && connection != this; | 1001 return connection && connection != this; |
| 1003 } | 1002 } |
| 1004 | 1003 |
| 1005 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { | 1004 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { |
| 1006 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); | 1005 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); |
| 1007 } | 1006 } |
| 1008 | 1007 |
| 1009 } // namespace ws | 1008 } // namespace ws |
| 1010 | 1009 |
| 1011 } // namespace mus | 1010 } // namespace mus |
| OLD | NEW |