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
3 // found in the LICENSE file.
5 #import "ui/gfx/mac/coordinate_conversion.h"
7 #import <Cocoa/Cocoa.h>
9 #include "ui/gfx/geometry/rect.h"
15 // The height of the primary display, which OSX defines as the monitor with the
16 // menubar. This is always at index 0.
17 CGFloat PrimaryDisplayHeight() {
18 return NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]);
23 NSRect ScreenRectToNSRect(const gfx::Rect& rect) {
24 return NSMakeRect(rect.x(),
25 PrimaryDisplayHeight() - rect.y() - rect.height(),
30 gfx::Rect ScreenRectFromNSRect(const NSRect& rect) {
31 return gfx::Rect(rect.origin.x,
32 PrimaryDisplayHeight() - rect.origin.y - rect.size.height,