Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: ui/gfx/screen_mac.mm

Issue 11270042: Add non-member non-mutating methods for common gfx::Rect operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/screen_gtk.cc ('k') | ui/views/animation/bounds_animator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::IntersectRects(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
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 }
OLDNEW
« no previous file with comments | « ui/gfx/screen_gtk.cc ('k') | ui/views/animation/bounds_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698