OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This has to be before any other includes, else default is picked up. |
| 6 // See base/logging for details on this. |
| 7 #define NOTIMPLEMENTED_POLICY 5 |
| 8 |
| 9 #include "ui/display/screen_base.h" |
| 10 |
| 11 #include "ui/display/display_finder.h" |
| 12 |
| 13 namespace display { |
| 14 |
| 15 ScreenBase::ScreenBase() { |
| 16 display::Screen::SetScreenInstance(this); |
| 17 } |
| 18 |
| 19 ScreenBase::~ScreenBase() { |
| 20 DCHECK_EQ(this, display::Screen::GetScreen()); |
| 21 display::Screen::SetScreenInstance(nullptr); |
| 22 } |
| 23 |
| 24 void ScreenBase::ProcessDisplayChanged(const display::Display& changed_display, |
| 25 bool is_primary) { |
| 26 if (display_list_.FindDisplayById(changed_display.id()) == |
| 27 display_list_.displays().end()) { |
| 28 display_list_.AddDisplay( |
| 29 changed_display, is_primary ? display::DisplayList::Type::PRIMARY |
| 30 : display::DisplayList::Type::NOT_PRIMARY); |
| 31 return; |
| 32 } |
| 33 display_list_.UpdateDisplay( |
| 34 changed_display, is_primary ? display::DisplayList::Type::PRIMARY |
| 35 : display::DisplayList::Type::NOT_PRIMARY); |
| 36 } |
| 37 |
| 38 gfx::Point ScreenBase::GetCursorScreenPoint() { |
| 39 NOTIMPLEMENTED(); |
| 40 return gfx::Point(); |
| 41 } |
| 42 |
| 43 bool ScreenBase::IsWindowUnderCursor(gfx::NativeWindow window) { |
| 44 NOTIMPLEMENTED(); |
| 45 return false; |
| 46 } |
| 47 |
| 48 gfx::NativeWindow ScreenBase::GetWindowAtScreenPoint(const gfx::Point& point) { |
| 49 NOTIMPLEMENTED(); |
| 50 return nullptr; |
| 51 } |
| 52 |
| 53 display::Display ScreenBase::GetPrimaryDisplay() const { |
| 54 return *display_list_.GetPrimaryDisplayIterator(); |
| 55 } |
| 56 |
| 57 display::Display ScreenBase::GetDisplayNearestWindow( |
| 58 gfx::NativeView view) const { |
| 59 NOTIMPLEMENTED(); |
| 60 return *display_list_.GetPrimaryDisplayIterator(); |
| 61 } |
| 62 |
| 63 display::Display ScreenBase::GetDisplayNearestPoint( |
| 64 const gfx::Point& point) const { |
| 65 return *display::FindDisplayNearestPoint(display_list_.displays(), point); |
| 66 } |
| 67 |
| 68 int ScreenBase::GetNumDisplays() const { |
| 69 return static_cast<int>(display_list_.displays().size()); |
| 70 } |
| 71 |
| 72 std::vector<display::Display> ScreenBase::GetAllDisplays() const { |
| 73 return display_list_.displays(); |
| 74 } |
| 75 |
| 76 display::Display ScreenBase::GetDisplayMatching( |
| 77 const gfx::Rect& match_rect) const { |
| 78 const display::Display* match = display::FindDisplayWithBiggestIntersection( |
| 79 display_list_.displays(), match_rect); |
| 80 return match ? *match : GetPrimaryDisplay(); |
| 81 } |
| 82 |
| 83 void ScreenBase::AddObserver(display::DisplayObserver* observer) { |
| 84 display_list_.AddObserver(observer); |
| 85 } |
| 86 |
| 87 void ScreenBase::RemoveObserver(display::DisplayObserver* observer) { |
| 88 display_list_.RemoveObserver(observer); |
| 89 } |
| 90 |
| 91 } // namespace display |
OLD | NEW |