Index: ui/gfx/screen_mac.mm |
diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm |
index 6fb7c6e8dc284f597a9f5cac0b9966d085968b97..c6de34f4bf572e1c1ad7019cc82b0613f0cb0fe0 100644 |
--- a/ui/gfx/screen_mac.mm |
+++ b/ui/gfx/screen_mac.mm |
@@ -16,6 +16,7 @@ |
#include "base/timer/timer.h" |
#include "ui/gfx/display.h" |
#include "ui/gfx/display_change_notifier.h" |
+#include "ui/gfx/mac/coordinate_conversion.h" |
namespace { |
@@ -24,13 +25,7 @@ namespace { |
const int64_t kConfigureDelayMs = 500; |
gfx::Rect ConvertCoordinateSystem(NSRect ns_rect) { |
- // Primary monitor is defined as the monitor with the menubar, |
- // which is always at index 0. |
- NSScreen* primary_screen = [[NSScreen screens] firstObject]; |
- float primary_screen_height = [primary_screen frame].size.height; |
- gfx::Rect rect(NSRectToCGRect(ns_rect)); |
- rect.set_y(primary_screen_height - rect.y() - rect.height()); |
- return rect; |
+ return gfx::ScreenRectFromNSRect(ns_rect); |
} |
NSScreen* GetMatchingScreen(const gfx::Rect& match_rect) { |
@@ -105,9 +100,7 @@ class ScreenMac : public gfx::Screen { |
gfx::Point GetCursorScreenPoint() override { |
NSPoint mouseLocation = [NSEvent mouseLocation]; |
// Flip coordinates to gfx (0,0 in top-left corner) using primary screen. |
- NSScreen* screen = [[NSScreen screens] firstObject]; |
- mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y; |
- return gfx::Point(mouseLocation.x, mouseLocation.y); |
+ return gfx::ScreenPointFromNSPoint(mouseLocation); |
} |
gfx::NativeWindow GetWindowUnderCursor() override { |