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

Side by Side Diff: ash/display/multi_display_manager.cc

Issue 11140006: Fix code around display overscan settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/display/multi_display_manager_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/display/multi_display_manager.h" 5 #include "ash/display/multi_display_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_controller.h" 10 #include "ash/display/display_controller.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return old_work_area != display.work_area(); 125 return old_work_area != display.work_area();
126 } 126 }
127 127
128 const gfx::Display& MultiDisplayManager::GetDisplayForId(int64 id) const { 128 const gfx::Display& MultiDisplayManager::GetDisplayForId(int64 id) const {
129 for (DisplayList::const_iterator iter = displays_.begin(); 129 for (DisplayList::const_iterator iter = displays_.begin();
130 iter != displays_.end(); ++iter) { 130 iter != displays_.end(); ++iter) {
131 if ((*iter).id() == id) 131 if ((*iter).id() == id)
132 return *iter; 132 return *iter;
133 } 133 }
134 VLOG(1) << "display not found for id:" << id; 134 VLOG(1) << "display not found for id:" << id;
135 return GetInvalidDisplay(); 135 return GetInvalidDisplay();
oshima 2012/10/17 16:34:09 can you changet hsi to use FindDisplayForId() ? it
Jun Mukai 2012/10/17 16:53:40 Done but rather changed FindDisplayForId to use th
Jun Mukai 2012/10/17 17:37:24 talked offline and changed to edit GetDisplayForId
136 } 136 }
137 137
138 const gfx::Display& MultiDisplayManager::FindDisplayContainingPoint( 138 const gfx::Display& MultiDisplayManager::FindDisplayContainingPoint(
139 const gfx::Point& point_in_screen) const { 139 const gfx::Point& point_in_screen) const {
140 for (DisplayList::const_iterator iter = displays_.begin(); 140 for (DisplayList::const_iterator iter = displays_.begin();
141 iter != displays_.end(); ++iter) { 141 iter != displays_.end(); ++iter) {
142 const gfx::Display& display = *iter; 142 const gfx::Display& display = *iter;
143 if (display.bounds().Contains(point_in_screen)) 143 if (display.bounds().Contains(point_in_screen))
144 return display; 144 return display;
145 } 145 }
146 return GetInvalidDisplay(); 146 return GetInvalidDisplay();
147 } 147 }
148 148
149 void MultiDisplayManager::SetOverscanInsets(int64 display_id, 149 void MultiDisplayManager::SetOverscanInsets(int64 display_id,
150 const gfx::Insets& insets_in_dip) { 150 const gfx::Insets& insets_in_dip) {
151 std::map<int64, gfx::Insets>::const_iterator old_overscan =
152 overscan_mapping_.find(display_id);
153 if (old_overscan != overscan_mapping_.end()) {
154 gfx::Insets old_insets = old_overscan->second;
155 gfx::Display& display = FindDisplayForId(display_id);
156 if (display.id() != gfx::Display::kInvalidDisplayID) {
oshima 2012/10/17 16:34:09 Can you add Display::is_valid() and use here?
Jun Mukai 2012/10/17 16:53:40 Done.
157 // Reimburse the existing insets before applying the new insets.
158 gfx::Rect bounds = display.bounds_in_pixel();
159 bounds.Inset(old_insets.Scale(-display.device_scale_factor()));
160 display.SetScaleAndBounds(display.device_scale_factor(), bounds);
161 }
162 }
151 overscan_mapping_[display_id] = insets_in_dip; 163 overscan_mapping_[display_id] = insets_in_dip;
152 OnNativeDisplaysChanged(displays_); 164 OnNativeDisplaysChanged(displays_);
153 } 165 }
154 166
155 void MultiDisplayManager::OnNativeDisplaysChanged( 167 void MultiDisplayManager::OnNativeDisplaysChanged(
156 const std::vector<gfx::Display>& updated_displays) { 168 const std::vector<gfx::Display>& updated_displays) {
157 if (updated_displays.empty()) { 169 if (updated_displays.empty()) {
158 // Don't update the displays when all displays are disconnected. 170 // Don't update the displays when all displays are disconnected.
159 // This happens when: 171 // This happens when:
160 // - the device is idle and powerd requested to turn off all displays. 172 // - the device is idle and powerd requested to turn off all displays.
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 new_displays.push_back(display); 442 new_displays.push_back(display);
431 } 443 }
432 OnNativeDisplaysChanged(new_displays); 444 OnNativeDisplaysChanged(new_displays);
433 } 445 }
434 446
435 gfx::Display& MultiDisplayManager::FindDisplayForRootWindow( 447 gfx::Display& MultiDisplayManager::FindDisplayForRootWindow(
436 const aura::RootWindow* root_window) { 448 const aura::RootWindow* root_window) {
437 int64 id = root_window->GetProperty(kDisplayIdKey); 449 int64 id = root_window->GetProperty(kDisplayIdKey);
438 // if id is |kInvaildDisplayID|, it's being deleted. 450 // if id is |kInvaildDisplayID|, it's being deleted.
439 DCHECK(id != gfx::Display::kInvalidDisplayID); 451 DCHECK(id != gfx::Display::kInvalidDisplayID);
440 return FindDisplayForId(id); 452 return FindDisplayForId(id);
oshima 2012/10/17 16:34:09 gfx::Display& display = FindDisplayFor(id); DCHECK
Jun Mukai 2012/10/17 16:53:40 Done.
441 } 453 }
442 454
443 gfx::Display& MultiDisplayManager::FindDisplayForId(int64 id) { 455 gfx::Display& MultiDisplayManager::FindDisplayForId(int64 id) {
444 for (DisplayList::iterator iter = displays_.begin(); 456 for (DisplayList::iterator iter = displays_.begin();
445 iter != displays_.end(); ++iter) { 457 iter != displays_.end(); ++iter) {
446 if ((*iter).id() == id) 458 if ((*iter).id() == id)
447 return *iter; 459 return *iter;
448 } 460 }
449 DLOG(FATAL) << "Could not find display:" << id; 461 DLOG(WARNING) << "Could not find display:" << id;
450 return GetInvalidDisplay(); 462 return GetInvalidDisplay();
451 } 463 }
452 464
453 void MultiDisplayManager::AddDisplayFromSpec(const std::string& spec) { 465 void MultiDisplayManager::AddDisplayFromSpec(const std::string& spec) {
454 gfx::Display display = CreateDisplayFromSpec(spec); 466 gfx::Display display = CreateDisplayFromSpec(spec);
455 467
456 const gfx::Insets insets = display.GetWorkAreaInsets(); 468 const gfx::Insets insets = display.GetWorkAreaInsets();
457 const gfx::Rect& native_bounds = display.bounds_in_pixel(); 469 const gfx::Rect& native_bounds = display.bounds_in_pixel();
458 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds); 470 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds);
459 display.UpdateWorkAreaFromInsets(insets); 471 display.UpdateWorkAreaFromInsets(insets);
(...skipping 11 matching lines...) Expand all
471 DisplayList::iterator iter_to_update = to_update->begin(); 483 DisplayList::iterator iter_to_update = to_update->begin();
472 DisplayList::const_iterator iter = displays_.begin(); 484 DisplayList::const_iterator iter = displays_.begin();
473 for (; iter != displays_.end() && iter_to_update != to_update->end(); 485 for (; iter != displays_.end() && iter_to_update != to_update->end();
474 ++iter, ++iter_to_update) { 486 ++iter, ++iter_to_update) {
475 (*iter_to_update).set_id((*iter).id()); 487 (*iter_to_update).set_id((*iter).id());
476 } 488 }
477 } 489 }
478 490
479 } // namespace internal 491 } // namespace internal
480 } // namespace ash 492 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/display/multi_display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698