| 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; | 42 gfx::Rect intersection = gfx::Intersection(monitor_area, match_rect); |
| 43 intersection.Intersect(match_rect); | |
| 44 int area = intersection.width() * intersection.height(); | 43 int area = intersection.width() * intersection.height(); |
| 45 if (area > max_area) { | 44 if (area > max_area) { |
| 46 max_area = area; | 45 max_area = area; |
| 47 max_screen = screen; | 46 max_screen = screen; |
| 48 } | 47 } |
| 49 } | 48 } |
| 50 | 49 |
| 51 return max_screen; | 50 return max_screen; |
| 52 } | 51 } |
| 53 | 52 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 174 |
| 176 } // namespace | 175 } // namespace |
| 177 | 176 |
| 178 namespace gfx { | 177 namespace gfx { |
| 179 | 178 |
| 180 Screen* CreateNativeScreen() { | 179 Screen* CreateNativeScreen() { |
| 181 return new ScreenMac; | 180 return new ScreenMac; |
| 182 } | 181 } |
| 183 | 182 |
| 184 } | 183 } |
| OLD | NEW |