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

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

Issue 2712203002: c++ / mojo changes for 'external window mode'
Patch Set: rebased 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
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_host_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
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
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* ws_display = GetDisplay(root); 243 Display* ws_display = GetDisplay(root);
201 DCHECK(ws_display); 244 DCHECK(ws_display);
(...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 WindowTree* tree = window_server_->GetTreeWithRoot(window); 2114 WindowTree* tree = window_server_->GetTreeWithRoot(window);
2072 return tree && tree != this; 2115 return tree && tree != this;
2073 } 2116 }
2074 2117
2075 bool WindowTree::IsWindowCreatedByWindowManager( 2118 bool WindowTree::IsWindowCreatedByWindowManager(
2076 const ServerWindow* window) const { 2119 const ServerWindow* window) const {
2077 // The WindowManager is attached to the root of the Display, if there isn't a 2120 // The WindowManager is attached to the root of the Display, if there isn't a
2078 // WindowManager attached, the window manager didn't create this window. 2121 // WindowManager attached, the window manager didn't create this window.
2079 const WindowManagerDisplayRoot* display_root = 2122 const WindowManagerDisplayRoot* display_root =
2080 GetWindowManagerDisplayRoot(window); 2123 GetWindowManagerDisplayRoot(window);
2081 if (!display_root) 2124 if (!display_root || !display_root->window_manager_state())
2082 return false; 2125 return false;
2083 2126
2084 return display_root->window_manager_state()->window_tree()->id() == 2127 return display_root->window_manager_state()->window_tree()->id() ==
2085 window->id().client_id; 2128 window->id().client_id;
2086 } 2129 }
2087 2130
2088 void WindowTree::OnDragCompleted(bool success, uint32_t action_taken) { 2131 void WindowTree::OnDragCompleted(bool success, uint32_t action_taken) {
2089 DCHECK(window_server_->in_drag_loop()); 2132 DCHECK(window_server_->in_drag_loop());
2090 2133
2091 if (window_server_->GetCurrentDragLoopInitiator() != this) 2134 if (window_server_->GetCurrentDragLoopInitiator() != this)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, 2222 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset,
2180 effect_bitmask, callback); 2223 effect_bitmask, callback);
2181 } 2224 }
2182 2225
2183 void WindowTree::PerformOnDragDropDone() { 2226 void WindowTree::PerformOnDragDropDone() {
2184 client()->OnDragDropDone(); 2227 client()->OnDragDropDone();
2185 } 2228 }
2186 2229
2187 } // namespace ws 2230 } // namespace ws
2188 } // namespace ui 2231 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_host_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698