| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/engine/app/ui/blimp_screen.h" | 5 #include "blimp/engine/app/ui/blimp_screen.h" |
| 6 | 6 |
| 7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
| 8 #include "ui/aura/window_tree_host.h" | 8 #include "ui/aura/window_tree_host.h" |
| 9 #include "ui/gfx/display_observer.h" | 9 #include "ui/display/display_observer.h" |
| 10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
| 11 | 11 |
| 12 namespace blimp { | 12 namespace blimp { |
| 13 namespace engine { | 13 namespace engine { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const int64_t kDisplayId = 1; | 17 const int64_t kDisplayId = 1; |
| 18 const int kNumDisplays = 1; | 18 const int kNumDisplays = 1; |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 BlimpScreen::BlimpScreen() : display_(kDisplayId) {} | 22 BlimpScreen::BlimpScreen() : display_(kDisplayId) {} |
| 23 | 23 |
| 24 BlimpScreen::~BlimpScreen() {} | 24 BlimpScreen::~BlimpScreen() {} |
| 25 | 25 |
| 26 void BlimpScreen::UpdateDisplayScaleAndSize(float scale, | 26 void BlimpScreen::UpdateDisplayScaleAndSize(float scale, |
| 27 const gfx::Size& size) { | 27 const gfx::Size& size) { |
| 28 if (scale == display_.device_scale_factor() && | 28 if (scale == display_.device_scale_factor() && |
| 29 size == display_.GetSizeInPixel()) { | 29 size == display_.GetSizeInPixel()) { |
| 30 return; | 30 return; |
| 31 } | 31 } |
| 32 | 32 |
| 33 uint32_t metrics = gfx::DisplayObserver::DISPLAY_METRIC_NONE; | 33 uint32_t metrics = display::DisplayObserver::DISPLAY_METRIC_NONE; |
| 34 if (scale != display_.device_scale_factor()) | 34 if (scale != display_.device_scale_factor()) |
| 35 metrics |= gfx::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; | 35 metrics |= display::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; |
| 36 | 36 |
| 37 if (size != display_.GetSizeInPixel()) | 37 if (size != display_.GetSizeInPixel()) |
| 38 metrics |= gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS; | 38 metrics |= display::DisplayObserver::DISPLAY_METRIC_BOUNDS; |
| 39 | 39 |
| 40 display_.SetScaleAndBounds(scale, gfx::Rect(size)); | 40 display_.SetScaleAndBounds(scale, gfx::Rect(size)); |
| 41 | 41 |
| 42 FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_, | 42 FOR_EACH_OBSERVER(display::DisplayObserver, observers_, |
| 43 OnDisplayMetricsChanged(display_, metrics)); | 43 OnDisplayMetricsChanged(display_, metrics)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 gfx::Point BlimpScreen::GetCursorScreenPoint() { | 46 gfx::Point BlimpScreen::GetCursorScreenPoint() { |
| 47 return gfx::Point(); | 47 return gfx::Point(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 gfx::NativeWindow BlimpScreen::GetWindowUnderCursor() { | 50 gfx::NativeWindow BlimpScreen::GetWindowUnderCursor() { |
| 51 NOTIMPLEMENTED(); | 51 NOTIMPLEMENTED(); |
| 52 return gfx::NativeWindow(nullptr); | 52 return gfx::NativeWindow(nullptr); |
| 53 } | 53 } |
| 54 | 54 |
| 55 gfx::NativeWindow BlimpScreen::GetWindowAtScreenPoint(const gfx::Point& point) { | 55 gfx::NativeWindow BlimpScreen::GetWindowAtScreenPoint(const gfx::Point& point) { |
| 56 return window_tree_host_ | 56 return window_tree_host_ |
| 57 ? window_tree_host_->window()->GetTopWindowContainingPoint(point) | 57 ? window_tree_host_->window()->GetTopWindowContainingPoint(point) |
| 58 : gfx::NativeWindow(nullptr); | 58 : gfx::NativeWindow(nullptr); |
| 59 } | 59 } |
| 60 | 60 |
| 61 int BlimpScreen::GetNumDisplays() const { | 61 int BlimpScreen::GetNumDisplays() const { |
| 62 return kNumDisplays; | 62 return kNumDisplays; |
| 63 } | 63 } |
| 64 | 64 |
| 65 std::vector<gfx::Display> BlimpScreen::GetAllDisplays() const { | 65 std::vector<display::Display> BlimpScreen::GetAllDisplays() const { |
| 66 return std::vector<gfx::Display>(1, display_); | 66 return std::vector<display::Display>(1, display_); |
| 67 } | 67 } |
| 68 | 68 |
| 69 gfx::Display BlimpScreen::GetDisplayNearestWindow( | 69 display::Display BlimpScreen::GetDisplayNearestWindow( |
| 70 gfx::NativeWindow window) const { | 70 gfx::NativeWindow window) const { |
| 71 return display_; | 71 return display_; |
| 72 } | 72 } |
| 73 | 73 |
| 74 gfx::Display BlimpScreen::GetDisplayNearestPoint( | 74 display::Display BlimpScreen::GetDisplayNearestPoint( |
| 75 const gfx::Point& point) const { | 75 const gfx::Point& point) const { |
| 76 return display_; | 76 return display_; |
| 77 } | 77 } |
| 78 | 78 |
| 79 gfx::Display BlimpScreen::GetDisplayMatching( | 79 display::Display BlimpScreen::GetDisplayMatching( |
| 80 const gfx::Rect& match_rect) const { | 80 const gfx::Rect& match_rect) const { |
| 81 return display_; | 81 return display_; |
| 82 } | 82 } |
| 83 | 83 |
| 84 gfx::Display BlimpScreen::GetPrimaryDisplay() const { | 84 display::Display BlimpScreen::GetPrimaryDisplay() const { |
| 85 return display_; | 85 return display_; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void BlimpScreen::AddObserver(gfx::DisplayObserver* observer) { | 88 void BlimpScreen::AddObserver(display::DisplayObserver* observer) { |
| 89 observers_.AddObserver(observer); | 89 observers_.AddObserver(observer); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void BlimpScreen::RemoveObserver(gfx::DisplayObserver* observer) { | 92 void BlimpScreen::RemoveObserver(display::DisplayObserver* observer) { |
| 93 observers_.RemoveObserver(observer); | 93 observers_.RemoveObserver(observer); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace engine | 96 } // namespace engine |
| 97 } // namespace blimp | 97 } // namespace blimp |
| OLD | NEW |