| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/gfx/mac/coordinate_conversion.h" | 5 #import "ui/gfx/mac/coordinate_conversion.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "ui/gfx/geometry/point.h" | 9 #include "ui/gfx/geometry/point.h" |
| 10 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
| 11 | 11 |
| 12 namespace gfx { | 12 namespace gfx { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // The height of the primary display, which OSX defines as the monitor with the | 16 // The height of the primary display, which OSX defines as the monitor with the |
| 17 // menubar. This is always at index 0. | 17 // menubar. This is always at index 0. |
| 18 CGFloat PrimaryDisplayHeight() { | 18 CGFloat PrimaryDisplayHeight() { |
| 19 return NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]); | 19 return NSMaxY([[[NSScreen screens] firstObject] frame]); |
| 20 } | 20 } |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 NSRect ScreenRectToNSRect(const Rect& rect) { | 24 NSRect ScreenRectToNSRect(const Rect& rect) { |
| 25 return NSMakeRect(rect.x(), | 25 return NSMakeRect(rect.x(), |
| 26 PrimaryDisplayHeight() - rect.y() - rect.height(), | 26 PrimaryDisplayHeight() - rect.y() - rect.height(), |
| 27 rect.width(), | 27 rect.width(), |
| 28 rect.height()); | 28 rect.height()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 Rect ScreenRectFromNSRect(const NSRect& rect) { | 31 Rect ScreenRectFromNSRect(const NSRect& rect) { |
| 32 return Rect(rect.origin.x, | 32 return Rect(rect.origin.x, |
| 33 PrimaryDisplayHeight() - rect.origin.y - rect.size.height, | 33 PrimaryDisplayHeight() - rect.origin.y - rect.size.height, |
| 34 rect.size.width, rect.size.height); | 34 rect.size.width, rect.size.height); |
| 35 } | 35 } |
| 36 | 36 |
| 37 NSPoint ScreenPointToNSPoint(const Point& point) { | 37 NSPoint ScreenPointToNSPoint(const Point& point) { |
| 38 return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y()); | 38 return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 Point ScreenPointFromNSPoint(const NSPoint& point) { | 41 Point ScreenPointFromNSPoint(const NSPoint& point) { |
| 42 return Point(point.x, PrimaryDisplayHeight() - point.y); | 42 return Point(point.x, PrimaryDisplayHeight() - point.y); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace gfx | 45 } // namespace gfx |
| OLD | NEW |