Index: ui/mojo/init/screen_mojo.cc |
diff --git a/ui/mojo/init/screen_mojo.cc b/ui/mojo/init/screen_mojo.cc |
index 1ed0d4146aeffb41f823426d02e05ba8eab3a4d4..2590b6a1b9a1d0af72e3fe2b0484516737a0f9d6 100644 |
--- a/ui/mojo/init/screen_mojo.cc |
+++ b/ui/mojo/init/screen_mojo.cc |
@@ -7,17 +7,13 @@ |
namespace ui { |
namespace mojo { |
-ScreenMojo::ScreenMojo(const gfx::Size& screen_size_in_pixels, |
- float device_pixel_ratio) |
- : screen_size_in_pixels_(screen_size_in_pixels), |
- device_pixel_ratio_(device_pixel_ratio) { |
- static int64 synthesized_display_id = 2000; |
- display_.set_id(synthesized_display_id++); |
- display_.SetScaleAndBounds(device_pixel_ratio, |
- gfx::Rect(screen_size_in_pixels)); |
-} |
+ScreenMojo::ScreenMojo(const std::vector<gfx::Display>& displays) |
+ : displays_(displays) {} |
+ |
+ScreenMojo::~ScreenMojo() {} |
gfx::Point ScreenMojo::GetCursorScreenPoint() { |
+ NOTIMPLEMENTED(); |
return gfx::Point(); |
} |
@@ -32,7 +28,7 @@ gfx::NativeWindow ScreenMojo::GetWindowAtScreenPoint(const gfx::Point& point) { |
} |
gfx::Display ScreenMojo::GetPrimaryDisplay() const { |
- return display_; |
+ return displays_[0]; |
} |
gfx::Display ScreenMojo::GetDisplayNearestWindow(gfx::NativeView view) const { |
@@ -44,15 +40,29 @@ gfx::Display ScreenMojo::GetDisplayNearestPoint(const gfx::Point& point) const { |
} |
int ScreenMojo::GetNumDisplays() const { |
- return 1; |
+ return static_cast<int>(displays_.size()); |
} |
std::vector<gfx::Display> ScreenMojo::GetAllDisplays() const { |
- return std::vector<gfx::Display>(1, GetPrimaryDisplay()); |
+ return displays_; |
} |
gfx::Display ScreenMojo::GetDisplayMatching(const gfx::Rect& match_rect) const { |
- return GetPrimaryDisplay(); |
+ int biggest_area = 0; |
+ gfx::Display result; |
+ const gfx::Display matching_display; |
+ for (const gfx::Display& display : displays_) { |
+ gfx::Rect display_union(match_rect); |
+ display_union.Union(display.bounds()); |
+ if (!display_union.IsEmpty()) { |
+ const int area = display_union.width() * display_union.height(); |
+ if (area > biggest_area) { |
+ biggest_area = area; |
+ result = display; |
+ } |
+ } |
+ } |
+ return biggest_area == 0 ? displays_[0] : result; |
} |
void ScreenMojo::AddObserver(gfx::DisplayObserver* observer) { |