| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/screen.h" | 5 #include "ui/gfx/screen.h" |
| 6 | 6 |
| 7 #import <ApplicationServices/ApplicationServices.h> | 7 #import <ApplicationServices/ApplicationServices.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/logging.h" |
| 11 #include "ui/gfx/display.h" |
| 12 |
| 13 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
| 14 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
| 15 |
| 10 @interface NSScreen (LionAPI) | 16 @interface NSScreen (LionAPI) |
| 11 - (CGFloat)backingScaleFactor; | 17 - (CGFloat)backingScaleFactor; |
| 12 @end | 18 @end |
| 13 | 19 |
| 14 #include "base/logging.h" | 20 #endif // 10.7 |
| 15 #include "ui/gfx/display.h" | |
| 16 | 21 |
| 17 namespace { | 22 namespace { |
| 18 | 23 |
| 19 gfx::Rect ConvertCoordinateSystem(NSRect ns_rect) { | 24 gfx::Rect ConvertCoordinateSystem(NSRect ns_rect) { |
| 20 // Primary monitor is defined as the monitor with the menubar, | 25 // Primary monitor is defined as the monitor with the menubar, |
| 21 // which is always at index 0. | 26 // which is always at index 0. |
| 22 NSScreen* primary_screen = [[NSScreen screens] objectAtIndex:0]; | 27 NSScreen* primary_screen = [[NSScreen screens] objectAtIndex:0]; |
| 23 float primary_screen_height = [primary_screen frame].size.height; | 28 float primary_screen_height = [primary_screen frame].size.height; |
| 24 gfx::Rect rect(NSRectToCGRect(ns_rect)); | 29 gfx::Rect rect(NSRectToCGRect(ns_rect)); |
| 25 rect.set_y(primary_screen_height - rect.y() - rect.height()); | 30 rect.set_y(primary_screen_height - rect.y() - rect.height()); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 NSArray* screens = [NSScreen screens]; | 159 NSArray* screens = [NSScreen screens]; |
| 155 NSScreen* primary = [screens objectAtIndex:0]; | 160 NSScreen* primary = [screens objectAtIndex:0]; |
| 156 for (NSScreen* screen in screens) { | 161 for (NSScreen* screen in screens) { |
| 157 if (NSMouseInRect(ns_point, [screen frame], NO)) | 162 if (NSMouseInRect(ns_point, [screen frame], NO)) |
| 158 return GetDisplayForScreen(screen, screen == primary); | 163 return GetDisplayForScreen(screen, screen == primary); |
| 159 } | 164 } |
| 160 return GetPrimaryDisplay(); | 165 return GetPrimaryDisplay(); |
| 161 } | 166 } |
| 162 | 167 |
| 163 } // namespace gfx | 168 } // namespace gfx |
| OLD | NEW |