| Index: ui/views/mus/screen_mus.cc
|
| diff --git a/ui/views/mus/screen_mus.cc b/ui/views/mus/screen_mus.cc
|
| index b2a84a7ff77dd2a2ecc8e7693145f1f1340ff058..227170606ae384220c29741a26a67bb5f15a9fe2 100644
|
| --- a/ui/views/mus/screen_mus.cc
|
| +++ b/ui/views/mus/screen_mus.cc
|
| @@ -36,7 +36,6 @@ namespace views {
|
|
|
| ScreenMus::ScreenMus(ScreenMusDelegate* delegate)
|
| : delegate_(delegate),
|
| - primary_display_index_(0),
|
| display_manager_observer_binding_(this) {
|
| }
|
|
|
| @@ -59,64 +58,28 @@ void ScreenMus::Init(shell::Connector* connector) {
|
| // The WaitForIncomingMethodCall() should have supplied the set of Displays,
|
| // unless mus is going down, in which case encountered_error() is true, or the
|
| // call to WaitForIncomingMethodCall() failed.
|
| - if (displays_.empty()) {
|
| + if (display_list_.displays().empty()) {
|
| DCHECK(display_manager_.encountered_error() || !success);
|
| // In this case we install a default display and assume the process is
|
| // going to exit shortly so that the real value doesn't matter.
|
| - displays_.push_back(
|
| - display::Display(0xFFFFFFFF, gfx::Rect(0, 0, 801, 802)));
|
| + display_list_.AddDisplay(
|
| + display::Display(0xFFFFFFFF, gfx::Rect(0, 0, 801, 802)),
|
| + DisplayList::Type::PRIMARY);
|
| }
|
| }
|
|
|
| -int ScreenMus::FindDisplayIndexById(int64_t id) const {
|
| - for (size_t i = 0; i < displays_.size(); ++i) {
|
| - if (displays_[i].id() == id)
|
| - return static_cast<int>(i);
|
| - }
|
| - return -1;
|
| -}
|
| -
|
| void ScreenMus::ProcessDisplayChanged(const display::Display& changed_display,
|
| bool is_primary) {
|
| - const int display_index = FindDisplayIndexById(changed_display.id());
|
| - if (display_index == -1) {
|
| - displays_.push_back(changed_display);
|
| - if (is_primary)
|
| - primary_display_index_ = static_cast<int>(displays_.size()) - 1;
|
| - FOR_EACH_OBSERVER(display::DisplayObserver, observers_,
|
| - OnDisplayAdded(changed_display));
|
| + if (display_list_.FindDisplayById(changed_display.id()) ==
|
| + display_list_.displays().end()) {
|
| + display_list_.AddDisplay(changed_display,
|
| + is_primary ? DisplayList::Type::PRIMARY
|
| + : DisplayList::Type::NOT_PRIMARY);
|
| return;
|
| }
|
| -
|
| - display::Display* local_display = &displays_[display_index];
|
| - uint32_t changed_values = 0;
|
| - if (is_primary && display_index != primary_display_index_) {
|
| - primary_display_index_ = display_index;
|
| - // ash::DisplayManager only notifies for the Display gaining primary, not
|
| - // the one losing it.
|
| - changed_values |= display::DisplayObserver::DISPLAY_METRIC_PRIMARY;
|
| - }
|
| - if (local_display->bounds() != changed_display.bounds()) {
|
| - local_display->set_bounds(changed_display.bounds());
|
| - changed_values |= display::DisplayObserver::DISPLAY_METRIC_BOUNDS;
|
| - }
|
| - if (local_display->work_area() != changed_display.work_area()) {
|
| - local_display->set_work_area(changed_display.work_area());
|
| - changed_values |= display::DisplayObserver::DISPLAY_METRIC_WORK_AREA;
|
| - }
|
| - if (local_display->rotation() != changed_display.rotation()) {
|
| - local_display->set_rotation(changed_display.rotation());
|
| - changed_values |= display::DisplayObserver::DISPLAY_METRIC_ROTATION;
|
| - }
|
| - if (local_display->device_scale_factor() !=
|
| - changed_display.device_scale_factor()) {
|
| - local_display->set_device_scale_factor(
|
| - changed_display.device_scale_factor());
|
| - changed_values |=
|
| - display::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR;
|
| - }
|
| - FOR_EACH_OBSERVER(display::DisplayObserver, observers_,
|
| - OnDisplayMetricsChanged(*local_display, changed_values));
|
| + display_list_.UpdateDisplay(
|
| + changed_display,
|
| + is_primary ? DisplayList::Type::PRIMARY : DisplayList::Type::NOT_PRIMARY);
|
| }
|
|
|
| gfx::Point ScreenMus::GetCursorScreenPoint() {
|
| @@ -144,58 +107,64 @@ gfx::NativeWindow ScreenMus::GetWindowAtScreenPoint(const gfx::Point& point) {
|
| }
|
|
|
| display::Display ScreenMus::GetPrimaryDisplay() const {
|
| - return displays_[primary_display_index_];
|
| + return *display_list_.GetPrimaryDisplayIterator();
|
| }
|
|
|
| display::Display ScreenMus::GetDisplayNearestWindow(
|
| gfx::NativeView view) const {
|
| //NOTIMPLEMENTED();
|
| - return GetPrimaryDisplay();
|
| + return *display_list_.GetPrimaryDisplayIterator();
|
| }
|
|
|
| display::Display ScreenMus::GetDisplayNearestPoint(
|
| const gfx::Point& point) const {
|
| - return *display::FindDisplayNearestPoint(displays_, point);
|
| + return *display::FindDisplayNearestPoint(display_list_.displays(), point);
|
| }
|
|
|
| int ScreenMus::GetNumDisplays() const {
|
| - return static_cast<int>(displays_.size());
|
| + return static_cast<int>(display_list_.displays().size());
|
| }
|
|
|
| std::vector<display::Display> ScreenMus::GetAllDisplays() const {
|
| - return displays_;
|
| + return display_list_.displays();
|
| }
|
|
|
| display::Display ScreenMus::GetDisplayMatching(
|
| const gfx::Rect& match_rect) const {
|
| - const display::Display* match =
|
| - display::FindDisplayWithBiggestIntersection(displays_, match_rect);
|
| + const display::Display* match = display::FindDisplayWithBiggestIntersection(
|
| + display_list_.displays(), match_rect);
|
| return match ? *match : GetPrimaryDisplay();
|
| }
|
|
|
| void ScreenMus::AddObserver(display::DisplayObserver* observer) {
|
| - observers_.AddObserver(observer);
|
| + display_list_.AddObserver(observer);
|
| }
|
|
|
| void ScreenMus::RemoveObserver(display::DisplayObserver* observer) {
|
| - observers_.RemoveObserver(observer);
|
| + display_list_.RemoveObserver(observer);
|
| }
|
|
|
| -void ScreenMus::OnDisplays(mojo::Array<mus::mojom::DisplayPtr> displays) {
|
| +void ScreenMus::OnDisplays(
|
| + mojo::Array<mus::mojom::DisplayPtr> transport_displays) {
|
| // This should only be called once from Init() before any observers have been
|
| // added.
|
| - DCHECK(displays_.empty());
|
| - displays_ = displays.To<std::vector<display::Display>>();
|
| - DCHECK(!displays_.empty());
|
| + DCHECK(display_list_.displays().empty());
|
| + std::vector<display::Display> displays =
|
| + transport_displays.To<std::vector<display::Display>>();
|
| for (size_t i = 0; i < displays.size(); ++i) {
|
| - if (displays[i]->is_primary) {
|
| - primary_display_index_ = static_cast<int>(i);
|
| + const bool is_primary = transport_displays[i]->is_primary;
|
| + display_list_.AddDisplay(displays[i], is_primary
|
| + ? DisplayList::Type::PRIMARY
|
| + : DisplayList::Type::NOT_PRIMARY);
|
| + if (is_primary) {
|
| // TODO(sky): Make WindowManagerFrameValues per display.
|
| WindowManagerFrameValues frame_values =
|
| - displays[i]->frame_decoration_values.To<WindowManagerFrameValues>();
|
| + transport_displays[i]
|
| + ->frame_decoration_values.To<WindowManagerFrameValues>();
|
| WindowManagerFrameValues::SetInstance(frame_values);
|
| }
|
| }
|
| + DCHECK(!display_list_.displays().empty());
|
| }
|
|
|
| void ScreenMus::OnDisplaysChanged(
|
| @@ -216,14 +185,7 @@ void ScreenMus::OnDisplaysChanged(
|
| }
|
|
|
| void ScreenMus::OnDisplayRemoved(int64_t id) {
|
| - const int index = FindDisplayIndexById(id);
|
| - DCHECK_NE(-1, index);
|
| - // Another display must become primary before the existing primary is
|
| - // removed.
|
| - DCHECK_NE(index, primary_display_index_);
|
| - const display::Display display = displays_[index];
|
| - FOR_EACH_OBSERVER(display::DisplayObserver, observers_,
|
| - OnDisplayRemoved(display));
|
| + display_list_.RemoveDisplay(id);
|
| }
|
|
|
| } // namespace views
|
|
|