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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 175 |
175 } // namespace | 176 } // namespace |
176 | 177 |
177 namespace gfx { | 178 namespace gfx { |
178 | 179 |
179 Screen* CreateNativeScreen() { | 180 Screen* CreateNativeScreen() { |
180 return new ScreenMac; | 181 return new ScreenMac; |
181 } | 182 } |
182 | 183 |
183 } | 184 } |
OLD | NEW |