| 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 #include "ash/mus/test/wm_test_screen.h" | 5 #include "ash/mus/test/wm_test_screen.h" |
| 6 | 6 |
| 7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
| 8 #include "ui/display/display_finder.h" | 8 #include "ui/display/display_finder.h" |
| 9 | 9 |
| 10 #undef NOTIMPLEMENTED | |
| 11 #define NOTIMPLEMENTED() DVLOG(1) << "notimplemented" | |
| 12 | |
| 13 namespace ash { | 10 namespace ash { |
| 14 namespace mus { | 11 namespace mus { |
| 15 | 12 |
| 16 WmTestScreen::WmTestScreen() { | 13 WmTestScreen::WmTestScreen() {} |
| 17 display::Screen::SetScreenInstance(this); | 14 WmTestScreen::~WmTestScreen() {} |
| 18 } | |
| 19 | |
| 20 WmTestScreen::~WmTestScreen() { | |
| 21 if (display::Screen::GetScreen() == this) | |
| 22 display::Screen::SetScreenInstance(nullptr); | |
| 23 } | |
| 24 | 15 |
| 25 gfx::Point WmTestScreen::GetCursorScreenPoint() { | 16 gfx::Point WmTestScreen::GetCursorScreenPoint() { |
| 26 // TODO(sky): use the implementation from WindowManagerConnection. | 17 // TODO(sky): use the implementation from WindowManagerConnection. |
| 27 NOTIMPLEMENTED(); | 18 DVLOG(1) << "NOTIMPLEMENTED"; |
| 28 return gfx::Point(); | 19 return gfx::Point(); |
| 29 } | 20 } |
| 30 | 21 |
| 31 bool WmTestScreen::IsWindowUnderCursor(gfx::NativeWindow window) { | 22 bool WmTestScreen::IsWindowUnderCursor(gfx::NativeWindow window) { |
| 32 if (!window) | 23 if (!window) |
| 33 return false; | 24 return false; |
| 34 | 25 |
| 35 return window->IsVisible() && | 26 return window->IsVisible() && |
| 36 window->GetBoundsInScreen().Contains(GetCursorScreenPoint()); | 27 window->GetBoundsInScreen().Contains(GetCursorScreenPoint()); |
| 37 } | 28 } |
| 38 | 29 |
| 39 gfx::NativeWindow WmTestScreen::GetWindowAtScreenPoint( | |
| 40 const gfx::Point& point) { | |
| 41 NOTREACHED(); | |
| 42 return nullptr; | |
| 43 } | |
| 44 | |
| 45 display::Display WmTestScreen::GetPrimaryDisplay() const { | |
| 46 return *display_list_.GetPrimaryDisplayIterator(); | |
| 47 } | |
| 48 | |
| 49 display::Display WmTestScreen::GetDisplayNearestWindow( | |
| 50 gfx::NativeView view) const { | |
| 51 NOTIMPLEMENTED(); | |
| 52 return *display_list_.GetPrimaryDisplayIterator(); | |
| 53 } | |
| 54 | |
| 55 display::Display WmTestScreen::GetDisplayNearestPoint( | |
| 56 const gfx::Point& point) const { | |
| 57 return *display::FindDisplayNearestPoint(display_list_.displays(), point); | |
| 58 } | |
| 59 | |
| 60 int WmTestScreen::GetNumDisplays() const { | |
| 61 return static_cast<int>(display_list_.displays().size()); | |
| 62 } | |
| 63 | |
| 64 std::vector<display::Display> WmTestScreen::GetAllDisplays() const { | |
| 65 return display_list_.displays(); | |
| 66 } | |
| 67 | |
| 68 display::Display WmTestScreen::GetDisplayMatching( | |
| 69 const gfx::Rect& match_rect) const { | |
| 70 const display::Display* match = display::FindDisplayWithBiggestIntersection( | |
| 71 display_list_.displays(), match_rect); | |
| 72 return match ? *match : GetPrimaryDisplay(); | |
| 73 } | |
| 74 | |
| 75 void WmTestScreen::AddObserver(display::DisplayObserver* observer) { | |
| 76 display_list_.AddObserver(observer); | |
| 77 } | |
| 78 | |
| 79 void WmTestScreen::RemoveObserver(display::DisplayObserver* observer) { | |
| 80 display_list_.RemoveObserver(observer); | |
| 81 } | |
| 82 | |
| 83 } // namespace mus | 30 } // namespace mus |
| 84 } // namespace ash | 31 } // namespace ash |
| OLD | NEW |