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

Side by Side Diff: services/ui/ws/window_tree.cc

Issue 2712203002: c++ / mojo changes for 'external window mode'
Patch Set: addressing fwang/sky feedback Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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
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) {
103 std::vector<const ServerWindow*> to_send; 108 std::vector<const ServerWindow*> to_send;
104 CHECK_EQ(1u, roots_.size()); 109
105 const ServerWindow* root = *roots_.begin(); 110 bool in_external_window_mode = !!root_window;
111 if (in_external_window_mode)
112 CHECK_LE(1u, roots_.size());
113 else
114 CHECK_EQ(1u, roots_.size());
fwang 2017/03/01 06:38:47 Does that compile when assertions are disabled?
115
116 const ServerWindow* root = root_window ? root_window : *roots_.begin();
106 GetUnknownWindowsFrom(root, &to_send); 117 GetUnknownWindowsFrom(root, &to_send);
107 118
108 Display* display = GetDisplay(root); 119 Display* display = GetDisplay(root);
109 int64_t display_id = display ? display->GetId() : display::kInvalidDisplayId; 120 int64_t display_id = display ? display->GetId() : display::kInvalidDisplayId;
110 const ServerWindow* focused_window = 121 const ServerWindow* focused_window =
111 display ? display->GetFocusedWindow() : nullptr; 122 display ? display->GetFocusedWindow() : nullptr;
112 if (focused_window) 123 if (focused_window)
113 focused_window = access_policy_->GetWindowForFocusChange(focused_window); 124 focused_window = access_policy_->GetWindowForFocusChange(focused_window);
114 ClientWindowId focused_window_id; 125 ClientWindowId focused_window_id;
115 if (focused_window) 126 if (focused_window)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return window_server_->display_manager(); 193 return window_server_->display_manager();
183 } 194 }
184 195
185 void WindowTree::PrepareForWindowServerShutdown() { 196 void WindowTree::PrepareForWindowServerShutdown() {
186 window_manager_internal_client_binding_.reset(); 197 window_manager_internal_client_binding_.reset();
187 binding_->ResetClientForShutdown(); 198 binding_->ResetClientForShutdown();
188 if (window_manager_internal_) 199 if (window_manager_internal_)
189 window_manager_internal_ = binding_->GetWindowManager(); 200 window_manager_internal_ = binding_->GetWindowManager();
190 } 201 }
191 202
192 void WindowTree::AddRootForWindowManager(const ServerWindow* root) { 203 void WindowTree::AddRoot(const ServerWindow* root) {
193 DCHECK(window_manager_internal_);
194 const ClientWindowId client_window_id(WindowIdToTransportId(root->id())); 204 const ClientWindowId client_window_id(WindowIdToTransportId(root->id()));
195 DCHECK_EQ(0u, client_id_to_window_id_map_.count(client_window_id)); 205 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(); 206 client_id_to_window_id_map_[client_window_id] = root->id();
197 window_id_to_client_id_map_[root->id()] = client_window_id; 207 window_id_to_client_id_map_[root->id()] = client_window_id;
198 roots_.insert(root); 208 roots_.insert(root);
199 209
200 Display* display = GetDisplay(root); 210 Display* display = GetDisplay(root);
201 DCHECK(display); 211 DCHECK(display);
212 }
202 213
203 window_manager_internal_->WmNewDisplayAdded(display->ToDisplay(), 214 void WindowTree::AddRootForWindowManager(const ServerWindow* root) {
215 DCHECK(window_manager_internal_);
216 AddRoot(root);
217 window_manager_internal_->WmNewDisplayAdded(GetDisplay(root)->ToDisplay(),
204 WindowToWindowData(root), 218 WindowToWindowData(root),
205 root->parent()->IsDrawn()); 219 root->parent()->IsDrawn());
206 } 220 }
207 221
208 void WindowTree::OnWindowDestroyingTreeImpl(WindowTree* tree) { 222 void WindowTree::OnWindowDestroyingTreeImpl(WindowTree* tree) {
209 if (event_source_wms_ && event_source_wms_->window_tree() == tree) 223 if (event_source_wms_ && event_source_wms_->window_tree() == tree)
210 event_source_wms_ = nullptr; 224 event_source_wms_ = nullptr;
211 225
212 // Notify our client if |tree| was embedded in any of our windows. 226 // Notify our client if |tree| was embedded in any of our windows.
213 for (const auto* tree_root : tree->roots_) { 227 for (const auto* tree_root : tree->roots_) {
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, 2170 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset,
2157 effect_bitmask, callback); 2171 effect_bitmask, callback);
2158 } 2172 }
2159 2173
2160 void WindowTree::PerformOnDragDropDone() { 2174 void WindowTree::PerformOnDragDropDone() {
2161 client()->OnDragDropDone(); 2175 client()->OnDragDropDone();
2162 } 2176 }
2163 2177
2164 } // namespace ws 2178 } // namespace ws
2165 } // namespace ui 2179 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698