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

Side by Side Diff: ui/display/display_list.cc

Issue 2784173002: Changes how window is updated when display changes in mash (Closed)
Patch Set: feedback Created 3 years, 8 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 | « ui/display/display_list.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/display/display_list.h" 5 #include "ui/display/display_list.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "ui/display/display_observer.h" 8 #include "ui/display/display_observer.h"
9 9
10 namespace display { 10 namespace display {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 const { 45 const {
46 return primary_display_index_ == -1 46 return primary_display_index_ == -1
47 ? displays_.end() 47 ? displays_.end()
48 : displays_.begin() + primary_display_index_; 48 : displays_.begin() + primary_display_index_;
49 } 49 }
50 50
51 std::unique_ptr<DisplayListObserverLock> DisplayList::SuspendObserverUpdates() { 51 std::unique_ptr<DisplayListObserverLock> DisplayList::SuspendObserverUpdates() {
52 return base::WrapUnique(new DisplayListObserverLock(this)); 52 return base::WrapUnique(new DisplayListObserverLock(this));
53 } 53 }
54 54
55 void DisplayList::UpdateDisplay(const Display& display) { 55 uint32_t DisplayList::UpdateDisplay(const Display& display) {
56 UpdateDisplay(display, GetTypeByDisplayId(display.id())); 56 return UpdateDisplay(display, GetTypeByDisplayId(display.id()));
57 } 57 }
58 58
59 void DisplayList::UpdateDisplay(const Display& display, Type type) { 59 uint32_t DisplayList::UpdateDisplay(const Display& display, Type type) {
60 auto iter = FindDisplayByIdInternal(display.id()); 60 auto iter = FindDisplayByIdInternal(display.id());
61 DCHECK(iter != displays_.end()); 61 DCHECK(iter != displays_.end());
62 62
63 Display* local_display = &(*iter); 63 Display* local_display = &(*iter);
64 uint32_t changed_values = 0; 64 uint32_t changed_values = 0;
65 if (type == Type::PRIMARY && 65 if (type == Type::PRIMARY &&
66 static_cast<int>(iter - displays_.begin()) != 66 static_cast<int>(iter - displays_.begin()) !=
67 static_cast<int>(GetPrimaryDisplayIterator() - displays_.begin())) { 67 static_cast<int>(GetPrimaryDisplayIterator() - displays_.begin())) {
68 primary_display_index_ = static_cast<int>(iter - displays_.begin()); 68 primary_display_index_ = static_cast<int>(iter - displays_.begin());
69 // ash::DisplayManager only notifies for the Display gaining primary, not 69 // ash::DisplayManager only notifies for the Display gaining primary, not
(...skipping 13 matching lines...) Expand all
83 changed_values |= DisplayObserver::DISPLAY_METRIC_ROTATION; 83 changed_values |= DisplayObserver::DISPLAY_METRIC_ROTATION;
84 } 84 }
85 if (local_display->device_scale_factor() != display.device_scale_factor()) { 85 if (local_display->device_scale_factor() != display.device_scale_factor()) {
86 local_display->set_device_scale_factor(display.device_scale_factor()); 86 local_display->set_device_scale_factor(display.device_scale_factor());
87 changed_values |= DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; 87 changed_values |= DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR;
88 } 88 }
89 if (should_notify_observers()) { 89 if (should_notify_observers()) {
90 for (DisplayObserver& observer : observers_) 90 for (DisplayObserver& observer : observers_)
91 observer.OnDisplayMetricsChanged(*local_display, changed_values); 91 observer.OnDisplayMetricsChanged(*local_display, changed_values);
92 } 92 }
93 return changed_values;
93 } 94 }
94 95
95 void DisplayList::AddDisplay(const Display& display, Type type) { 96 void DisplayList::AddDisplay(const Display& display, Type type) {
96 DCHECK(displays_.end() == FindDisplayByIdInternal(display.id())); 97 DCHECK(displays_.end() == FindDisplayByIdInternal(display.id()));
97 displays_.push_back(display); 98 displays_.push_back(display);
98 if (type == Type::PRIMARY) 99 if (type == Type::PRIMARY)
99 primary_display_index_ = static_cast<int>(displays_.size()) - 1; 100 primary_display_index_ = static_cast<int>(displays_.size()) - 1;
100 if (should_notify_observers()) { 101 if (should_notify_observers()) {
101 for (DisplayObserver& observer : observers_) 102 for (DisplayObserver& observer : observers_)
102 observer.OnDisplayAdded(display); 103 observer.OnDisplayAdded(display);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 DisplayList::Displays::iterator DisplayList::FindDisplayByIdInternal( 144 DisplayList::Displays::iterator DisplayList::FindDisplayByIdInternal(
144 int64_t id) { 145 int64_t id) {
145 for (auto iter = displays_.begin(); iter != displays_.end(); ++iter) { 146 for (auto iter = displays_.begin(); iter != displays_.end(); ++iter) {
146 if (iter->id() == id) 147 if (iter->id() == id)
147 return iter; 148 return iter;
148 } 149 }
149 return displays_.end(); 150 return displays_.end();
150 } 151 }
151 152
152 } // namespace display 153 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/display_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698