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" | 10 #include "base/logging.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 NSScreen* GetMatchingScreen(const gfx::Rect& match_rect) { | 34 NSScreen* GetMatchingScreen(const gfx::Rect& match_rect) { |
35 // Default to the monitor with the current keyboard focus, in case | 35 // Default to the monitor with the current keyboard focus, in case |
36 // |match_rect| is not on any screen at all. | 36 // |match_rect| is not on any screen at all. |
37 NSScreen* max_screen = [NSScreen mainScreen]; | 37 NSScreen* max_screen = [NSScreen mainScreen]; |
38 int max_area = 0; | 38 int max_area = 0; |
39 | 39 |
40 for (NSScreen* screen in [NSScreen screens]) { | 40 for (NSScreen* screen in [NSScreen screens]) { |
41 gfx::Rect monitor_area = ConvertCoordinateSystem([screen frame]); | 41 gfx::Rect monitor_area = ConvertCoordinateSystem([screen frame]); |
42 gfx::Rect intersection = monitor_area.Intersect(match_rect); | 42 gfx::Rect intersection = monitor_area; |
| 43 intersection.Intersect(match_rect); |
43 int area = intersection.width() * intersection.height(); | 44 int area = intersection.width() * intersection.height(); |
44 if (area > max_area) { | 45 if (area > max_area) { |
45 max_area = area; | 46 max_area = area; |
46 max_screen = screen; | 47 max_screen = screen; |
47 } | 48 } |
48 } | 49 } |
49 | 50 |
50 return max_screen; | 51 return max_screen; |
51 } | 52 } |
52 | 53 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 NSArray* screens = [NSScreen screens]; | 160 NSArray* screens = [NSScreen screens]; |
160 NSScreen* primary = [screens objectAtIndex:0]; | 161 NSScreen* primary = [screens objectAtIndex:0]; |
161 for (NSScreen* screen in screens) { | 162 for (NSScreen* screen in screens) { |
162 if (NSMouseInRect(ns_point, [screen frame], NO)) | 163 if (NSMouseInRect(ns_point, [screen frame], NO)) |
163 return GetDisplayForScreen(screen, screen == primary); | 164 return GetDisplayForScreen(screen, screen == primary); |
164 } | 165 } |
165 return GetPrimaryDisplay(); | 166 return GetPrimaryDisplay(); |
166 } | 167 } |
167 | 168 |
168 } // namespace gfx | 169 } // namespace gfx |
OLD | NEW |