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

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

Issue 1639563003: Renames WindowManagerConfig to FrameDecorationValues and moves to Display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments 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
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"
(...skipping 13 matching lines...) Expand all
24 24
25 ConnectionManager::ConnectionManager( 25 ConnectionManager::ConnectionManager(
26 ConnectionManagerDelegate* delegate, 26 ConnectionManagerDelegate* delegate,
27 const scoped_refptr<mus::SurfacesState>& surfaces_state) 27 const scoped_refptr<mus::SurfacesState>& surfaces_state)
28 : delegate_(delegate), 28 : delegate_(delegate),
29 surfaces_state_(surfaces_state), 29 surfaces_state_(surfaces_state),
30 next_connection_id_(1), 30 next_connection_id_(1),
31 next_host_id_(0), 31 next_host_id_(0),
32 current_operation_(nullptr), 32 current_operation_(nullptr),
33 in_destructor_(false), 33 in_destructor_(false),
34 next_wm_change_id_(0) {} 34 next_wm_change_id_(0),
35 got_valid_frame_decorations_(false) {}
35 36
36 ConnectionManager::~ConnectionManager() { 37 ConnectionManager::~ConnectionManager() {
37 in_destructor_ = true; 38 in_destructor_ = true;
38 39
39 // Copy the HostConnectionMap because it will be mutated as the connections 40 // Copy the HostConnectionMap because it will be mutated as the connections
40 // are closed. 41 // are closed.
41 HostConnectionMap host_connection_map(host_connection_map_); 42 HostConnectionMap host_connection_map(host_connection_map_);
42 for (auto& pair : host_connection_map) 43 for (auto& pair : host_connection_map)
43 pair.second->CloseConnection(); 44 pair.second->CloseConnection();
44 45
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 385 }
385 386
386 void ConnectionManager::ProcessViewportMetricsChanged( 387 void ConnectionManager::ProcessViewportMetricsChanged(
387 WindowTreeHostImpl* host, 388 WindowTreeHostImpl* host,
388 const mojom::ViewportMetrics& old_metrics, 389 const mojom::ViewportMetrics& old_metrics,
389 const mojom::ViewportMetrics& new_metrics) { 390 const mojom::ViewportMetrics& new_metrics) {
390 for (auto& pair : connection_map_) { 391 for (auto& pair : connection_map_) {
391 pair.second->service()->ProcessViewportMetricsChanged( 392 pair.second->service()->ProcessViewportMetricsChanged(
392 host, old_metrics, new_metrics, IsOperationSource(pair.first)); 393 host, old_metrics, new_metrics, IsOperationSource(pair.first));
393 } 394 }
395
396 if (!got_valid_frame_decorations_)
397 return;
398 }
399
400 void ConnectionManager::ProcessFrameDecorationValuesChanged(
401 WindowTreeHostImpl* host) {
402 if (!got_valid_frame_decorations_) {
403 got_valid_frame_decorations_ = true;
404 display_manager_observers_.ForAllPtrs([this](
405 mojom::DisplayManagerObserver* observer) { CallOnDisplays(observer); });
406 return;
407 }
408
409 display_manager_observers_.ForAllPtrs(
410 [this, &host](mojom::DisplayManagerObserver* observer) {
411 CallOnDisplayChanged(observer, host);
412 });
394 } 413 }
395 414
396 bool ConnectionManager::GetAndClearInFlightWindowManagerChange( 415 bool ConnectionManager::GetAndClearInFlightWindowManagerChange(
397 uint32_t window_manager_change_id, 416 uint32_t window_manager_change_id,
398 InFlightWindowManagerChange* change) { 417 InFlightWindowManagerChange* change) {
399 // There are valid reasons as to why we wouldn't know about the id. The 418 // There are valid reasons as to why we wouldn't know about the id. The
400 // most likely is the client disconnected before the response from the window 419 // most likely is the client disconnected before the response from the window
401 // manager came back. 420 // manager came back.
402 auto iter = in_flight_wm_change_map_.find(window_manager_change_id); 421 auto iter = in_flight_wm_change_map_.find(window_manager_change_id);
403 if (iter == in_flight_wm_change_map_.end()) 422 if (iter == in_flight_wm_change_map_.end())
(...skipping 21 matching lines...) Expand all
425 connection_map_[connection->service()->id()] = connection; 444 connection_map_[connection->service()->id()] = connection;
426 } 445 }
427 446
428 void ConnectionManager::MaybeUpdateNativeCursor(ServerWindow* window) { 447 void ConnectionManager::MaybeUpdateNativeCursor(ServerWindow* window) {
429 // This can be null in unit tests. 448 // This can be null in unit tests.
430 WindowTreeHostImpl* impl = GetWindowTreeHostByWindow(window); 449 WindowTreeHostImpl* impl = GetWindowTreeHostByWindow(window);
431 if (impl) 450 if (impl)
432 impl->MaybeChangeCursorOnWindowTreeChange(); 451 impl->MaybeChangeCursorOnWindowTreeChange();
433 } 452 }
434 453
454 void ConnectionManager::CallOnDisplays(
455 mojom::DisplayManagerObserver* observer) {
456 mojo::Array<mojom::DisplayPtr> displays(host_connection_map_.size());
457 {
458 size_t i = 0;
459 for (auto& pair : host_connection_map_) {
460 displays[i] = DisplayForHost(pair.first);
461 ++i;
462 }
463 }
464 observer->OnDisplays(std::move(displays));
465 }
466
467 void ConnectionManager::CallOnDisplayChanged(
468 mojom::DisplayManagerObserver* observer,
469 WindowTreeHostImpl* host) {
470 mojo::Array<mojom::DisplayPtr> displays(1);
471 displays[0] = DisplayForHost(host);
472 display_manager_observers_.ForAllPtrs(
473 [&displays](mojom::DisplayManagerObserver* observer) {
474 observer->OnDisplaysChanged(displays.Clone());
475 });
476 }
477
478 mojom::DisplayPtr ConnectionManager::DisplayForHost(WindowTreeHostImpl* host) {
479 size_t i = 0;
480 int next_x = 0;
481 for (auto& pair : host_connection_map_) {
482 const ServerWindow* root = host->root_window();
483 if (pair.first == host) {
484 mojom::DisplayPtr display = mojom::Display::New();
485 display = mojom::Display::New();
486 display->id = host->id();
487 display->bounds = mojo::Rect::New();
488 display->bounds->x = next_x;
489 display->bounds->y = 0;
490 display->bounds->width = root->bounds().size().width();
491 display->bounds->height = root->bounds().size().height();
492 // TODO(sky): window manager needs an API to set the work area.
493 display->work_area = display->bounds.Clone();
494 display->device_pixel_ratio =
495 host->GetViewportMetrics().device_pixel_ratio;
496 display->rotation = host->GetRotation();
497 // TODO(sky): make this real.
498 display->is_primary = i == 0;
499 // TODO(sky): make this real.
500 display->touch_support = mojom::TouchSupport::UNKNOWN;
501 display->frame_decoration_values =
502 host->frame_decoration_values().Clone();
503 return display;
504 }
505 next_x += root->bounds().size().width();
506 ++i;
507 }
508 NOTREACHED();
509 return mojom::Display::New();
510 }
511
435 mus::SurfacesState* ConnectionManager::GetSurfacesState() { 512 mus::SurfacesState* ConnectionManager::GetSurfacesState() {
436 return surfaces_state_.get(); 513 return surfaces_state_.get();
437 } 514 }
438 515
439 void ConnectionManager::OnScheduleWindowPaint(const ServerWindow* window) { 516 void ConnectionManager::OnScheduleWindowPaint(const ServerWindow* window) {
440 if (!in_destructor_) 517 if (!in_destructor_)
441 SchedulePaint(window, gfx::Rect(window->bounds().size())); 518 SchedulePaint(window, gfx::Rect(window->bounds().size()));
442 } 519 }
443 520
444 const ServerWindow* ConnectionManager::GetRootWindow( 521 const ServerWindow* ConnectionManager::GetRootWindow(
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // If we're deleting a window, then this is a superfluous message. 658 // If we're deleting a window, then this is a superfluous message.
582 if (current_operation_type() == OperationType::DELETE_WINDOW) 659 if (current_operation_type() == OperationType::DELETE_WINDOW)
583 return; 660 return;
584 for (auto& pair : connection_map_) { 661 for (auto& pair : connection_map_) {
585 pair.second->service()->ProcessTransientWindowRemoved( 662 pair.second->service()->ProcessTransientWindowRemoved(
586 window, transient_child, IsOperationSource(pair.first)); 663 window, transient_child, IsOperationSource(pair.first));
587 } 664 }
588 } 665 }
589 666
590 void ConnectionManager::AddObserver(mojom::DisplayManagerObserverPtr observer) { 667 void ConnectionManager::AddObserver(mojom::DisplayManagerObserverPtr observer) {
591 mojo::Array<mojom::DisplayPtr> displays(host_connection_map_.size()); 668 // Many clients key off the frame decorations to size widgets. Wait for frame
592 { 669 // decorations before notifying so that we don't have to worry about clients
593 size_t i = 0; 670 // resizing appropriately.
594 int next_x = 0; 671 if (!got_valid_frame_decorations_) {
595 for (auto& pair : host_connection_map_) { 672 display_manager_observers_.AddInterfacePtr(std::move(observer));
596 const WindowTreeHostImpl* tree_host = pair.first; 673 return;
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 } 674 }
618 observer->OnDisplays(std::move(displays)); 675 CallOnDisplays(observer.get());
619 display_manager_observers_.AddInterfacePtr(std::move(observer)); 676 display_manager_observers_.AddInterfacePtr(std::move(observer));
620 } 677 }
621 678
622 } // namespace ws 679 } // namespace ws
623 } // namespace mus 680 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698