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

Side by Side Diff: components/mus/ws/connection_manager.cc

Issue 1615023004: Start of display management for mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash and add back getting constants Created 4 years, 11 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 | « components/mus/ws/connection_manager.h ('k') | components/mus/ws/display_manager.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 "components/mus/ws/connection_manager.h" 5 #include "components/mus/ws/connection_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "components/mus/ws/client_connection.h" 9 #include "components/mus/ws/client_connection.h"
10 #include "components/mus/ws/connection_manager_delegate.h" 10 #include "components/mus/ws/connection_manager_delegate.h"
11 #include "components/mus/ws/operation.h" 11 #include "components/mus/ws/operation.h"
12 #include "components/mus/ws/server_window.h" 12 #include "components/mus/ws/server_window.h"
13 #include "components/mus/ws/window_coordinate_conversions.h" 13 #include "components/mus/ws/window_coordinate_conversions.h"
14 #include "components/mus/ws/window_tree_host_connection.h" 14 #include "components/mus/ws/window_tree_host_connection.h"
15 #include "components/mus/ws/window_tree_impl.h" 15 #include "components/mus/ws/window_tree_impl.h"
16 #include "mojo/converters/geometry/geometry_type_converters.h" 16 #include "mojo/converters/geometry/geometry_type_converters.h"
17 #include "mojo/converters/input_events/input_events_type_converters.h" 17 #include "mojo/converters/input_events/input_events_type_converters.h"
18 #include "mojo/converters/surfaces/surfaces_type_converters.h" 18 #include "mojo/converters/surfaces/surfaces_type_converters.h"
19 #include "mojo/shell/public/cpp/application_connection.h" 19 #include "mojo/shell/public/cpp/application_connection.h"
20 #include "ui/gfx/geometry/size_conversions.h" 20 #include "ui/gfx/geometry/size_conversions.h"
21 21
22 namespace mus { 22 namespace mus {
23
24 namespace ws { 23 namespace ws {
25 24
26 ConnectionManager::ConnectionManager( 25 ConnectionManager::ConnectionManager(
27 ConnectionManagerDelegate* delegate, 26 ConnectionManagerDelegate* delegate,
28 const scoped_refptr<mus::SurfacesState>& surfaces_state) 27 const scoped_refptr<mus::SurfacesState>& surfaces_state)
29 : delegate_(delegate), 28 : delegate_(delegate),
30 surfaces_state_(surfaces_state), 29 surfaces_state_(surfaces_state),
31 next_connection_id_(1), 30 next_connection_id_(1),
32 next_host_id_(0), 31 next_host_id_(0),
33 current_operation_(nullptr), 32 current_operation_(nullptr),
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (window == pair.first->root_window()) 246 if (window == pair.first->root_window())
248 return pair.first; 247 return pair.first;
249 } 248 }
250 return nullptr; 249 return nullptr;
251 } 250 }
252 251
253 WindowTreeHostImpl* ConnectionManager::GetActiveWindowTreeHost() { 252 WindowTreeHostImpl* ConnectionManager::GetActiveWindowTreeHost() {
254 return host_connection_map_.begin()->first; 253 return host_connection_map_.begin()->first;
255 } 254 }
256 255
256 void ConnectionManager::AddDisplayManagerBinding(
257 mojo::InterfaceRequest<mojom::DisplayManager> request) {
258 display_manager_bindings_.AddBinding(this, std::move(request));
259 }
260
257 uint32_t ConnectionManager::GenerateWindowManagerChangeId( 261 uint32_t ConnectionManager::GenerateWindowManagerChangeId(
258 WindowTreeImpl* source, 262 WindowTreeImpl* source,
259 uint32_t client_change_id) { 263 uint32_t client_change_id) {
260 const uint32_t wm_change_id = next_wm_change_id_++; 264 const uint32_t wm_change_id = next_wm_change_id_++;
261 in_flight_wm_change_map_[wm_change_id] = {source->id(), client_change_id}; 265 in_flight_wm_change_map_[wm_change_id] = {source->id(), client_change_id};
262 return wm_change_id; 266 return wm_change_id;
263 } 267 }
264 268
265 void ConnectionManager::WindowManagerChangeCompleted( 269 void ConnectionManager::WindowManagerChangeCompleted(
266 uint32_t window_manager_change_id, 270 uint32_t window_manager_change_id,
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 ServerWindow* transient_child) { 580 ServerWindow* transient_child) {
577 // If we're deleting a window, then this is a superfluous message. 581 // If we're deleting a window, then this is a superfluous message.
578 if (current_operation_type() == OperationType::DELETE_WINDOW) 582 if (current_operation_type() == OperationType::DELETE_WINDOW)
579 return; 583 return;
580 for (auto& pair : connection_map_) { 584 for (auto& pair : connection_map_) {
581 pair.second->service()->ProcessTransientWindowRemoved( 585 pair.second->service()->ProcessTransientWindowRemoved(
582 window, transient_child, IsOperationSource(pair.first)); 586 window, transient_child, IsOperationSource(pair.first));
583 } 587 }
584 } 588 }
585 589
590 void ConnectionManager::AddObserver(mojom::DisplayManagerObserverPtr observer) {
591 mojo::Array<mojom::DisplayPtr> displays(host_connection_map_.size());
592 {
593 size_t i = 0;
594 int next_x = 0;
595 for (auto& pair : host_connection_map_) {
596 const WindowTreeHostImpl* tree_host = pair.first;
597 const ServerWindow* root = tree_host->root_window();
598 displays[i] = mojom::Display::New();
599 displays[i]->id = tree_host->id();
600 displays[i]->bounds = mojo::Rect::New();
601 displays[i]->bounds->x = next_x;
602 displays[i]->bounds->y = 0;
603 displays[i]->bounds->width = root->bounds().size().width();
604 displays[i]->bounds->height = root->bounds().size().height();
605 next_x += displays[i]->bounds->width;
606 // TODO(sky): window manager needs an API to set the work area.
607 displays[i]->work_area = displays[i]->bounds.Clone();
608 displays[i]->device_pixel_ratio =
609 tree_host->GetViewportMetrics().device_pixel_ratio;
610 displays[i]->rotation = tree_host->GetRotation();
611 // TODO(sky): make this real.
612 displays[i]->is_primary = i == 0;
613 // TODO(sky): make this real.
614 displays[i]->touch_support = mojom::TouchSupport::UNKNOWN;
615 ++i;
616 }
617 }
618 observer->OnDisplays(std::move(displays));
619 display_manager_observers_.AddInterfacePtr(std::move(observer));
620 }
621
586 } // namespace ws 622 } // namespace ws
587
588 } // namespace mus 623 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/connection_manager.h ('k') | components/mus/ws/display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698