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*/); |
| 104 } |
| 105 |
| 106 void WindowTree::DoOnEmbed(mojom::WindowTreePtr tree, |
| 107 ServerWindow* root_window) { |
| 108 bool in_external_window_mode = !!root_window; |
| 109 if (in_external_window_mode) { |
| 110 DCHECK(!tree); |
| 111 CHECK_LE(1u, roots_.size()); |
| 112 |
| 113 Display* display = GetDisplay(root_window); |
| 114 int64_t display_id = |
| 115 display ? display->GetId() : display::kInvalidDisplayId; |
| 116 |
| 117 ClientWindowId window_id; |
| 118 IsWindowKnown(root_window, &window_id); |
| 119 |
| 120 const bool drawn = |
| 121 root_window->parent() && root_window->parent()->IsDrawn(); |
| 122 client()->OnEmbed(id_, WindowToWindowData(root_window), |
| 123 nullptr /*mojom::WindowTreePtr*/, display_id, |
| 124 window_id.id, drawn); |
| 125 return; |
| 126 } |
| 127 |
103 std::vector<const ServerWindow*> to_send; | 128 std::vector<const ServerWindow*> to_send; |
| 129 |
| 130 DCHECK(!root_window); |
104 CHECK_EQ(1u, roots_.size()); | 131 CHECK_EQ(1u, roots_.size()); |
105 const ServerWindow* root = *roots_.begin(); | 132 const ServerWindow* root = *roots_.begin(); |
106 GetUnknownWindowsFrom(root, &to_send); | 133 GetUnknownWindowsFrom(root, &to_send); |
107 | 134 |
108 Display* display = GetDisplay(root); | 135 Display* display = GetDisplay(root); |
109 int64_t display_id = display ? display->GetId() : display::kInvalidDisplayId; | 136 int64_t display_id = display ? display->GetId() : display::kInvalidDisplayId; |
110 const ServerWindow* focused_window = | 137 const ServerWindow* focused_window = |
111 display ? display->GetFocusedWindow() : nullptr; | 138 display ? display->GetFocusedWindow() : nullptr; |
112 if (focused_window) | 139 if (focused_window) |
113 focused_window = access_policy_->GetWindowForFocusChange(focused_window); | 140 focused_window = access_policy_->GetWindowForFocusChange(focused_window); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return window_server_->display_manager(); | 209 return window_server_->display_manager(); |
183 } | 210 } |
184 | 211 |
185 void WindowTree::PrepareForWindowServerShutdown() { | 212 void WindowTree::PrepareForWindowServerShutdown() { |
186 window_manager_internal_client_binding_.reset(); | 213 window_manager_internal_client_binding_.reset(); |
187 binding_->ResetClientForShutdown(); | 214 binding_->ResetClientForShutdown(); |
188 if (window_manager_internal_) | 215 if (window_manager_internal_) |
189 window_manager_internal_ = binding_->GetWindowManager(); | 216 window_manager_internal_ = binding_->GetWindowManager(); |
190 } | 217 } |
191 | 218 |
| 219 void WindowTree::AddRoot(const ServerWindow* root) { |
| 220 DCHECK(pending_client_id_ != kInvalidClientId); |
| 221 |
| 222 const ClientWindowId client_window_id(pending_client_id_); |
| 223 DCHECK_EQ(0u, client_id_to_window_id_map_.count(client_window_id)); |
| 224 |
| 225 client_id_to_window_id_map_[client_window_id] = root->id(); |
| 226 window_id_to_client_id_map_[root->id()] = client_window_id; |
| 227 pending_client_id_ = kInvalidClientId; |
| 228 |
| 229 roots_.insert(root); |
| 230 |
| 231 Display* display = GetDisplay(root); |
| 232 DCHECK(display); |
| 233 } |
| 234 |
192 void WindowTree::AddRootForWindowManager(const ServerWindow* root) { | 235 void WindowTree::AddRootForWindowManager(const ServerWindow* root) { |
193 DCHECK(window_manager_internal_); | 236 DCHECK(window_manager_internal_); |
194 const ClientWindowId client_window_id(WindowIdToTransportId(root->id())); | 237 const ClientWindowId client_window_id(WindowIdToTransportId(root->id())); |
195 DCHECK_EQ(0u, client_id_to_window_id_map_.count(client_window_id)); | 238 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(); | 239 client_id_to_window_id_map_[client_window_id] = root->id(); |
197 window_id_to_client_id_map_[root->id()] = client_window_id; | 240 window_id_to_client_id_map_[root->id()] = client_window_id; |
198 roots_.insert(root); | 241 roots_.insert(root); |
199 | 242 |
200 Display* display = GetDisplay(root); | 243 Display* display = GetDisplay(root); |
201 DCHECK(display); | 244 DCHECK(display); |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 2091 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
2049 return tree && tree != this; | 2092 return tree && tree != this; |
2050 } | 2093 } |
2051 | 2094 |
2052 bool WindowTree::IsWindowCreatedByWindowManager( | 2095 bool WindowTree::IsWindowCreatedByWindowManager( |
2053 const ServerWindow* window) const { | 2096 const ServerWindow* window) const { |
2054 // The WindowManager is attached to the root of the Display, if there isn't a | 2097 // The WindowManager is attached to the root of the Display, if there isn't a |
2055 // WindowManager attached, the window manager didn't create this window. | 2098 // WindowManager attached, the window manager didn't create this window. |
2056 const WindowManagerDisplayRoot* display_root = | 2099 const WindowManagerDisplayRoot* display_root = |
2057 GetWindowManagerDisplayRoot(window); | 2100 GetWindowManagerDisplayRoot(window); |
2058 if (!display_root) | 2101 if (!display_root || !display_root->window_manager_state()) |
2059 return false; | 2102 return false; |
2060 | 2103 |
2061 return display_root->window_manager_state()->window_tree()->id() == | 2104 return display_root->window_manager_state()->window_tree()->id() == |
2062 window->id().client_id; | 2105 window->id().client_id; |
2063 } | 2106 } |
2064 | 2107 |
2065 void WindowTree::OnDragCompleted(bool success, uint32_t action_taken) { | 2108 void WindowTree::OnDragCompleted(bool success, uint32_t action_taken) { |
2066 DCHECK(window_server_->in_drag_loop()); | 2109 DCHECK(window_server_->in_drag_loop()); |
2067 | 2110 |
2068 if (window_server_->GetCurrentDragLoopInitiator() != this) | 2111 if (window_server_->GetCurrentDragLoopInitiator() != this) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 2199 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
2157 effect_bitmask, callback); | 2200 effect_bitmask, callback); |
2158 } | 2201 } |
2159 | 2202 |
2160 void WindowTree::PerformOnDragDropDone() { | 2203 void WindowTree::PerformOnDragDropDone() { |
2161 client()->OnDragDropDone(); | 2204 client()->OnDragDropDone(); |
2162 } | 2205 } |
2163 | 2206 |
2164 } // namespace ws | 2207 } // namespace ws |
2165 } // namespace ui | 2208 } // namespace ui |
OLD | NEW |