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

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

Issue 2904993003: chromeos: changes how DisplayManagerObservers are notified (Closed)
Patch Set: cleanup Created 3 years, 6 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_unittest.cc » ('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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 276 }
277 277
278 ServerWindow* WindowTree::ProcessSetDisplayRoot( 278 ServerWindow* WindowTree::ProcessSetDisplayRoot(
279 const display::Display& display_to_create, 279 const display::Display& display_to_create,
280 const mojom::WmViewportMetrics& transport_viewport_metrics, 280 const mojom::WmViewportMetrics& transport_viewport_metrics,
281 bool is_primary_display, 281 bool is_primary_display,
282 const ClientWindowId& client_window_id) { 282 const ClientWindowId& client_window_id) {
283 DCHECK(window_manager_state_); // Only called for window manager. 283 DCHECK(window_manager_state_); // Only called for window manager.
284 DVLOG(3) << "SetDisplayRoot client=" << id_ 284 DVLOG(3) << "SetDisplayRoot client=" << id_
285 << " global window_id=" << client_window_id.id; 285 << " global window_id=" << client_window_id.id;
286 Display* display = 286 Display* display = display_manager()->GetDisplayById(display_to_create.id());
287 window_server_->display_manager()->GetDisplayById(display_to_create.id());
288 if (display) { 287 if (display) {
289 DVLOG(1) << "SetDisplayRoot called with existing display " 288 DVLOG(1) << "SetDisplayRoot called with existing display "
290 << display_to_create.id(); 289 << display_to_create.id();
291 return nullptr; 290 return nullptr;
292 } 291 }
293 292
294 if (automatically_create_display_roots_) { 293 if (automatically_create_display_roots_) {
295 DVLOG(1) << "SetDisplayRoot is only applicable when " 294 DVLOG(1) << "SetDisplayRoot is only applicable when "
296 << "automatically_create_display_roots is false"; 295 << "automatically_create_display_roots is false";
297 return nullptr; 296 return nullptr;
298 } 297 }
299 298
300 ServerWindow* window = GetWindowByClientId(client_window_id); 299 ServerWindow* window = GetWindowByClientId(client_window_id);
301 // The window must not have a parent. 300 // The window must not have a parent.
302 if (!window || window->parent()) { 301 if (!window || window->parent()) {
303 DVLOG(1) << "SetDisplayRoot called with invalid window id " 302 DVLOG(1) << "SetDisplayRoot called with invalid window id "
304 << client_window_id.id; 303 << client_window_id.id;
305 return nullptr; 304 return nullptr;
306 } 305 }
307 306
308 if (base::ContainsValue(roots_, window)) { 307 if (base::ContainsValue(roots_, window)) {
309 DVLOG(1) << "SetDisplayRoot called with existing root"; 308 DVLOG(1) << "SetDisplayRoot called with existing root";
310 return nullptr; 309 return nullptr;
311 } 310 }
312 311
313 const display::DisplayList::Type display_type =
314 is_primary_display ? display::DisplayList::Type::PRIMARY
315 : display::DisplayList::Type::NOT_PRIMARY;
316 display::ScreenManager::GetInstance()->GetScreen()->display_list().AddDisplay(
317 display_to_create, display_type);
318 display::ViewportMetrics viewport_metrics; 312 display::ViewportMetrics viewport_metrics;
319 viewport_metrics.bounds_in_pixels = 313 viewport_metrics.bounds_in_pixels =
320 transport_viewport_metrics.bounds_in_pixels; 314 transport_viewport_metrics.bounds_in_pixels;
321 viewport_metrics.device_scale_factor = 315 viewport_metrics.device_scale_factor =
322 transport_viewport_metrics.device_scale_factor; 316 transport_viewport_metrics.device_scale_factor;
323 viewport_metrics.ui_scale_factor = transport_viewport_metrics.ui_scale_factor; 317 viewport_metrics.ui_scale_factor = transport_viewport_metrics.ui_scale_factor;
324 window_server_->display_manager()->AddDisplayForWindowManager( 318 display = display_manager()->AddDisplayForWindowManager(
325 display_to_create, viewport_metrics); 319 is_primary_display, display_to_create, viewport_metrics);
326
327 // OnDisplayAdded() should trigger creation of the Display.
328 display =
329 window_server_->display_manager()->GetDisplayById(display_to_create.id());
330 DCHECK(display); 320 DCHECK(display);
331 WindowManagerDisplayRoot* display_root = 321 WindowManagerDisplayRoot* display_root =
332 display->GetWindowManagerDisplayRootForUser( 322 display->GetWindowManagerDisplayRootForUser(
333 window_manager_state_->user_id()); 323 window_manager_state_->user_id());
334 DCHECK(display_root); 324 DCHECK(display_root);
335 DCHECK(display_root->root()->children().empty()); 325 DCHECK(display_root->root()->children().empty());
336 326
337 // NOTE: this doesn't resize the window in anyway. We assume the client takes 327 // NOTE: this doesn't resize the window in anyway. We assume the client takes
338 // care of any modifications it needs to do. 328 // care of any modifications it needs to do.
339 roots_.insert(window); 329 roots_.insert(window);
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 const ServerWindow::Windows& children = window->children(); 1138 const ServerWindow::Windows& children = window->children();
1149 for (ServerWindow* child : children) 1139 for (ServerWindow* child : children)
1150 RemoveFromKnown(child, local_windows); 1140 RemoveFromKnown(child, local_windows);
1151 } 1141 }
1152 1142
1153 void WindowTree::RemoveRoot(ServerWindow* window, RemoveRootReason reason) { 1143 void WindowTree::RemoveRoot(ServerWindow* window, RemoveRootReason reason) {
1154 DCHECK(roots_.count(window) > 0); 1144 DCHECK(roots_.count(window) > 0);
1155 roots_.erase(window); 1145 roots_.erase(window);
1156 1146
1157 if (window->id().client_id == id_) { 1147 if (window->id().client_id == id_) {
1158 // This cllient created the window. If this client is the window manager and 1148 // This client created the window. If this client is the window manager and
1159 // display roots are manually created, then |window| is a display root and 1149 // display roots are manually created, then |window| is a display root and
1160 // needs be cleaned. 1150 // needs be cleaned.
1161 if (window_manager_state_ && !automatically_create_display_roots_) { 1151 if (window_manager_state_ && !automatically_create_display_roots_) {
1162 // The window manager is asking to delete the root it created. 1152 // The window manager is asking to delete the root it created.
1163 window_manager_state_->DeleteWindowManagerDisplayRoot(window->parent()); 1153 window_manager_state_->DeleteWindowManagerDisplayRoot(window->parent());
1164 DeleteWindowImpl(this, window); 1154 DeleteWindowImpl(this, window);
1165 } 1155 }
1166 return; 1156 return;
1167 } 1157 }
1168 1158
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 window_manager_internal_client_binding_) { 1963 window_manager_internal_client_binding_) {
1974 return; 1964 return;
1975 } 1965 }
1976 window_manager_internal_client_binding_.reset( 1966 window_manager_internal_client_binding_.reset(
1977 new mojo::AssociatedBinding<mojom::WindowManagerClient>( 1967 new mojo::AssociatedBinding<mojom::WindowManagerClient>(
1978 this, std::move(internal))); 1968 this, std::move(internal)));
1979 } 1969 }
1980 1970
1981 void WindowTree::GetCursorLocationMemory( 1971 void WindowTree::GetCursorLocationMemory(
1982 const GetCursorLocationMemoryCallback& callback) { 1972 const GetCursorLocationMemoryCallback& callback) {
1983 callback.Run(window_server_->display_manager() 1973 callback.Run(display_manager()
1984 ->GetCursorLocationManager(user_id_) 1974 ->GetCursorLocationManager(user_id_)
1985 ->GetCursorLocationMemory()); 1975 ->GetCursorLocationMemory());
1986 } 1976 }
1987 1977
1988 void WindowTree::PerformDragDrop( 1978 void WindowTree::PerformDragDrop(
1989 uint32_t change_id, 1979 uint32_t change_id,
1990 Id source_window_id, 1980 Id source_window_id,
1991 const gfx::Point& screen_location, 1981 const gfx::Point& screen_location,
1992 const std::unordered_map<std::string, std::vector<uint8_t>>& drag_data, 1982 const std::unordered_map<std::string, std::vector<uint8_t>>& drag_data,
1993 const SkBitmap& drag_image, 1983 const SkBitmap& drag_image,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 WindowManagerDisplayRoot* display_root = 2185 WindowManagerDisplayRoot* display_root =
2196 GetWindowManagerDisplayRoot(focused_window); 2186 GetWindowManagerDisplayRoot(focused_window);
2197 if (display_root->window_manager_state() != window_manager_state_.get()) { 2187 if (display_root->window_manager_state() != window_manager_state_.get()) {
2198 // We aren't active. 2188 // We aren't active.
2199 return; 2189 return;
2200 } 2190 }
2201 display_root->display()->ActivateNextWindow(); 2191 display_root->display()->ActivateNextWindow();
2202 return; 2192 return;
2203 } 2193 }
2204 // Use the first display. 2194 // Use the first display.
2205 std::set<Display*> displays = window_server_->display_manager()->displays(); 2195 std::set<Display*> displays = display_manager()->displays();
2206 if (displays.empty()) 2196 if (displays.empty())
2207 return; 2197 return;
2208 2198
2209 (*displays.begin())->ActivateNextWindow(); 2199 (*displays.begin())->ActivateNextWindow();
2210 } 2200 }
2211 2201
2212 void WindowTree::SetExtendedHitArea(Id window_id, const gfx::Insets& hit_area) { 2202 void WindowTree::SetExtendedHitArea(Id window_id, const gfx::Insets& hit_area) {
2213 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 2203 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
2214 // Extended hit test region should only be set by the owner of the window. 2204 // Extended hit test region should only be set by the owner of the window.
2215 if (!window) { 2205 if (!window) {
(...skipping 17 matching lines...) Expand all
2233 ProcessSetDisplayRoot(display, *viewport_metrics, is_primary_display, 2223 ProcessSetDisplayRoot(display, *viewport_metrics, is_primary_display,
2234 ClientWindowId(window_id)); 2224 ClientWindowId(window_id));
2235 if (!display_root) { 2225 if (!display_root) {
2236 callback.Run(base::nullopt); 2226 callback.Run(base::nullopt);
2237 return; 2227 return;
2238 } 2228 }
2239 display_root->parent()->SetVisible(true); 2229 display_root->parent()->SetVisible(true);
2240 callback.Run(display_root->current_local_surface_id()); 2230 callback.Run(display_root->current_local_surface_id());
2241 } 2231 }
2242 2232
2233 void WindowTree::SetDisplayConfiguration(
2234 const std::vector<display::Display>& displays,
2235 std::vector<ui::mojom::WmViewportMetricsPtr> viewport_metrics,
2236 int64_t primary_display_id,
2237 const SetDisplayConfigurationCallback& callback) {
2238 callback.Run(display_manager()->SetDisplayConfiguration(
2239 displays, std::move(viewport_metrics), primary_display_id));
2240 }
2241
2243 void WindowTree::WmResponse(uint32_t change_id, bool response) { 2242 void WindowTree::WmResponse(uint32_t change_id, bool response) {
2244 if (window_server_->in_move_loop() && 2243 if (window_server_->in_move_loop() &&
2245 window_server_->GetCurrentMoveLoopChangeId() == change_id) { 2244 window_server_->GetCurrentMoveLoopChangeId() == change_id) {
2246 ServerWindow* window = window_server_->GetCurrentMoveLoopWindow(); 2245 ServerWindow* window = window_server_->GetCurrentMoveLoopWindow();
2247 2246
2248 if (window->id().client_id != id_) { 2247 if (window->id().client_id != id_) {
2249 window_server_->WindowManagerSentBogusMessage(); 2248 window_server_->WindowManagerSentBogusMessage();
2250 window = nullptr; 2249 window = nullptr;
2251 } else { 2250 } else {
2252 WindowManagerDisplayRoot* display_root = 2251 WindowManagerDisplayRoot* display_root =
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2503 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, 2502 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset,
2504 effect_bitmask, callback); 2503 effect_bitmask, callback);
2505 } 2504 }
2506 2505
2507 void WindowTree::PerformOnDragDropDone() { 2506 void WindowTree::PerformOnDragDropDone() {
2508 client()->OnDragDropDone(); 2507 client()->OnDragDropDone();
2509 } 2508 }
2510 2509
2511 } // namespace ws 2510 } // namespace ws
2512 } // namespace ui 2511 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.h ('k') | services/ui/ws/window_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698