Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // This has to be before any other includes, else default is picked up. | 5 // This has to be before any other includes, else default is picked up. |
| 6 // See base/logging for details on this. | 6 // See base/logging for details on this. |
| 7 #define NOTIMPLEMENTED_POLICY 5 | 7 #define NOTIMPLEMENTED_POLICY 5 |
| 8 | 8 |
| 9 #include "ui/display/screen_base.h" | 9 #include "ui/display/screen_base.h" |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 | 51 |
| 52 int ScreenBase::GetNumDisplays() const { | 52 int ScreenBase::GetNumDisplays() const { |
| 53 return static_cast<int>(display_list_.displays().size()); | 53 return static_cast<int>(display_list_.displays().size()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 const std::vector<Display>& ScreenBase::GetAllDisplays() const { | 56 const std::vector<Display>& ScreenBase::GetAllDisplays() const { |
| 57 return display_list_.displays(); | 57 return display_list_.displays(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 Display ScreenBase::GetDisplayMatching(const gfx::Rect& match_rect) const { | 60 Display ScreenBase::GetDisplayMatching(const gfx::Rect& match_rect) const { |
| 61 if (match_rect.IsEmpty()) | |
| 62 return GetDisplayNearestPoint(match_rect.origin()); | |
|
sky
2017/03/06 17:08:25
This matches what ScreenAsh does.
| |
| 63 | |
| 61 const Display* match = | 64 const Display* match = |
| 62 FindDisplayWithBiggestIntersection(display_list_.displays(), match_rect); | 65 FindDisplayWithBiggestIntersection(display_list_.displays(), match_rect); |
| 63 return match ? *match : GetPrimaryDisplay(); | 66 return match ? *match : GetPrimaryDisplay(); |
| 64 } | 67 } |
| 65 | 68 |
| 66 void ScreenBase::AddObserver(DisplayObserver* observer) { | 69 void ScreenBase::AddObserver(DisplayObserver* observer) { |
| 67 display_list_.AddObserver(observer); | 70 display_list_.AddObserver(observer); |
| 68 } | 71 } |
| 69 | 72 |
| 70 void ScreenBase::RemoveObserver(DisplayObserver* observer) { | 73 void ScreenBase::RemoveObserver(DisplayObserver* observer) { |
| 71 display_list_.RemoveObserver(observer); | 74 display_list_.RemoveObserver(observer); |
| 72 } | 75 } |
| 73 | 76 |
| 74 void ScreenBase::ProcessDisplayChanged(const Display& changed_display, | 77 void ScreenBase::ProcessDisplayChanged(const Display& changed_display, |
| 75 bool is_primary) { | 78 bool is_primary) { |
| 76 if (display_list_.FindDisplayById(changed_display.id()) == | 79 if (display_list_.FindDisplayById(changed_display.id()) == |
| 77 display_list_.displays().end()) { | 80 display_list_.displays().end()) { |
| 78 display_list_.AddDisplay(changed_display, | 81 display_list_.AddDisplay(changed_display, |
| 79 is_primary ? DisplayList::Type::PRIMARY | 82 is_primary ? DisplayList::Type::PRIMARY |
| 80 : DisplayList::Type::NOT_PRIMARY); | 83 : DisplayList::Type::NOT_PRIMARY); |
| 81 return; | 84 return; |
| 82 } | 85 } |
| 83 display_list_.UpdateDisplay( | 86 display_list_.UpdateDisplay( |
| 84 changed_display, | 87 changed_display, |
| 85 is_primary ? DisplayList::Type::PRIMARY : DisplayList::Type::NOT_PRIMARY); | 88 is_primary ? DisplayList::Type::PRIMARY : DisplayList::Type::NOT_PRIMARY); |
| 86 } | 89 } |
| 87 | 90 |
| 88 } // namespace display | 91 } // namespace display |
| OLD | NEW |