Chromium Code Reviews| 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 "services/ui/ws/window_tree.h" | 5 #include "services/ui/ws/window_tree.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 } | 93 } |
| 94 | 94 |
| 95 void WindowTree::Init(std::unique_ptr<WindowTreeBinding> binding, | 95 void WindowTree::Init(std::unique_ptr<WindowTreeBinding> binding, |
| 96 mojom::WindowTreePtr tree) { | 96 mojom::WindowTreePtr tree) { |
| 97 DCHECK(!binding_); | 97 DCHECK(!binding_); |
| 98 binding_ = std::move(binding); | 98 binding_ = std::move(binding); |
| 99 | 99 |
| 100 if (roots_.empty()) | 100 if (roots_.empty()) |
| 101 return; | 101 return; |
| 102 | 102 |
| 103 DoOnEmbed(std::move(tree), nullptr /*ServerWindow*/); | |
|
fwang
2017/02/28 08:23:53
ditto about /* */ comment
| |
| 104 } | |
| 105 | |
| 106 void WindowTree::DoOnEmbed(mojom::WindowTreePtr tree, ServerWindow* r) { | |
|
fwang
2017/02/28 08:23:53
what about root_window to make it more explicit th
tonikitoo
2017/03/01 05:05:43
Done.
| |
| 103 std::vector<const ServerWindow*> to_send; | 107 std::vector<const ServerWindow*> to_send; |
| 104 CHECK_EQ(1u, roots_.size()); | 108 CHECK_NE(0u, roots_.size()); |
|
fwang
2017/02/28 08:23:53
These are unsigned integers, but maybe CHECK_LE(1u
tonikitoo
2017/03/01 05:05:43
Done.
| |
| 105 const ServerWindow* root = *roots_.begin(); | 109 |
| 110 const ServerWindow* root = r ? r : *roots_.begin(); | |
| 106 GetUnknownWindowsFrom(root, &to_send); | 111 GetUnknownWindowsFrom(root, &to_send); |
| 107 | 112 |
| 108 Display* display = GetDisplay(root); | 113 Display* display = GetDisplay(root); |
| 109 int64_t display_id = display ? display->GetId() : display::kInvalidDisplayId; | 114 int64_t display_id = display ? display->GetId() : display::kInvalidDisplayId; |
| 110 const ServerWindow* focused_window = | 115 const ServerWindow* focused_window = |
| 111 display ? display->GetFocusedWindow() : nullptr; | 116 display ? display->GetFocusedWindow() : nullptr; |
| 112 if (focused_window) | 117 if (focused_window) |
| 113 focused_window = access_policy_->GetWindowForFocusChange(focused_window); | 118 focused_window = access_policy_->GetWindowForFocusChange(focused_window); |
| 114 ClientWindowId focused_window_id; | 119 ClientWindowId focused_window_id; |
| 115 if (focused_window) | 120 if (focused_window) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 return window_server_->display_manager(); | 187 return window_server_->display_manager(); |
| 183 } | 188 } |
| 184 | 189 |
| 185 void WindowTree::PrepareForWindowServerShutdown() { | 190 void WindowTree::PrepareForWindowServerShutdown() { |
| 186 window_manager_internal_client_binding_.reset(); | 191 window_manager_internal_client_binding_.reset(); |
| 187 binding_->ResetClientForShutdown(); | 192 binding_->ResetClientForShutdown(); |
| 188 if (window_manager_internal_) | 193 if (window_manager_internal_) |
| 189 window_manager_internal_ = binding_->GetWindowManager(); | 194 window_manager_internal_ = binding_->GetWindowManager(); |
| 190 } | 195 } |
| 191 | 196 |
| 192 void WindowTree::AddRootForWindowManager(const ServerWindow* root) { | 197 void WindowTree::AddRoot(const ServerWindow* root) { |
| 193 DCHECK(window_manager_internal_); | 198 DCHECK(window_manager_internal_); |
| 194 const ClientWindowId client_window_id(WindowIdToTransportId(root->id())); | 199 const ClientWindowId client_window_id(WindowIdToTransportId(root->id())); |
| 195 DCHECK_EQ(0u, client_id_to_window_id_map_.count(client_window_id)); | 200 DCHECK_EQ(0u, client_id_to_window_id_map_.count(client_window_id)); |
| 196 client_id_to_window_id_map_[client_window_id] = root->id(); | 201 client_id_to_window_id_map_[client_window_id] = root->id(); |
| 197 window_id_to_client_id_map_[root->id()] = client_window_id; | 202 window_id_to_client_id_map_[root->id()] = client_window_id; |
| 198 roots_.insert(root); | 203 roots_.insert(root); |
| 199 | 204 |
| 200 Display* display = GetDisplay(root); | 205 Display* display = GetDisplay(root); |
| 201 DCHECK(display); | 206 DCHECK(display); |
| 207 } | |
| 202 | 208 |
| 203 window_manager_internal_->WmNewDisplayAdded(display->ToDisplay(), | 209 void WindowTree::AddRootForWindowManager(const ServerWindow* root) { |
| 210 AddRoot(root); | |
| 211 window_manager_internal_->WmNewDisplayAdded(GetDisplay(root)->ToDisplay(), | |
| 204 WindowToWindowData(root), | 212 WindowToWindowData(root), |
| 205 root->parent()->IsDrawn()); | 213 root->parent()->IsDrawn()); |
|
fwang
2017/02/28 08:23:53
This is the part that ensures MusDemoInternal is a
| |
| 206 } | 214 } |
| 207 | 215 |
| 208 void WindowTree::OnWindowDestroyingTreeImpl(WindowTree* tree) { | 216 void WindowTree::OnWindowDestroyingTreeImpl(WindowTree* tree) { |
| 209 if (event_source_wms_ && event_source_wms_->window_tree() == tree) | 217 if (event_source_wms_ && event_source_wms_->window_tree() == tree) |
| 210 event_source_wms_ = nullptr; | 218 event_source_wms_ = nullptr; |
| 211 | 219 |
| 212 // Notify our client if |tree| was embedded in any of our windows. | 220 // Notify our client if |tree| was embedded in any of our windows. |
| 213 for (const auto* tree_root : tree->roots_) { | 221 for (const auto* tree_root : tree->roots_) { |
| 214 const bool owns_tree_root = tree_root->id().client_id == id_; | 222 const bool owns_tree_root = tree_root->id().client_id == id_; |
| 215 if (owns_tree_root) { | 223 if (owns_tree_root) { |
| (...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2156 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 2164 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
| 2157 effect_bitmask, callback); | 2165 effect_bitmask, callback); |
| 2158 } | 2166 } |
| 2159 | 2167 |
| 2160 void WindowTree::PerformOnDragDropDone() { | 2168 void WindowTree::PerformOnDragDropDone() { |
| 2161 client()->OnDragDropDone(); | 2169 client()->OnDragDropDone(); |
| 2162 } | 2170 } |
| 2163 | 2171 |
| 2164 } // namespace ws | 2172 } // namespace ws |
| 2165 } // namespace ui | 2173 } // namespace ui |
| OLD | NEW |