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

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

Issue 10540123: Rename gfx::Screen::GetMonitorXXXX to gfx::Screen::GetDisplayXXX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months 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_impl.h ('k') | ui/gfx/screen_unittest.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 @interface NSScreen (LionAPI) 10 @interface NSScreen (LionAPI)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // static 82 // static
83 gfx::Point Screen::GetCursorScreenPoint() { 83 gfx::Point Screen::GetCursorScreenPoint() {
84 NSPoint mouseLocation = [NSEvent mouseLocation]; 84 NSPoint mouseLocation = [NSEvent mouseLocation];
85 // Flip coordinates to gfx (0,0 in top-left corner) using primary screen. 85 // Flip coordinates to gfx (0,0 in top-left corner) using primary screen.
86 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 86 NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
87 mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y; 87 mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y;
88 return gfx::Point(mouseLocation.x, mouseLocation.y); 88 return gfx::Point(mouseLocation.x, mouseLocation.y);
89 } 89 }
90 90
91 // static 91 // static
92 gfx::Display Screen::GetMonitorNearestWindow(gfx::NativeView view) { 92 gfx::Display Screen::GetDisplayNearestWindow(gfx::NativeView view) {
93 NSWindow* window = [view window]; 93 NSWindow* window = [view window];
94 if (!window) 94 if (!window)
95 return GetPrimaryMonitor(); 95 return GetPrimaryDisplay();
96 NSScreen* match_screen = [window screen]; 96 NSScreen* match_screen = [window screen];
97 return GetDisplayForScreen(match_screen, false /* may not be primary */); 97 return GetDisplayForScreen(match_screen, false /* may not be primary */);
98 } 98 }
99 99
100 // static 100 // static
101 gfx::Display Screen::GetPrimaryMonitor() { 101 gfx::Display Screen::GetPrimaryDisplay() {
102 // Primary display is defined as the display with the menubar, 102 // Primary display is defined as the display with the menubar,
103 // which is always at index 0. 103 // which is always at index 0.
104 NSScreen* primary = [[NSScreen screens] objectAtIndex:0]; 104 NSScreen* primary = [[NSScreen screens] objectAtIndex:0];
105 gfx::Display display = GetDisplayForScreen(primary, true /* primary */); 105 gfx::Display display = GetDisplayForScreen(primary, true /* primary */);
106 return display; 106 return display;
107 } 107 }
108 108
109 // static 109 // static
110 gfx::Display Screen::GetMonitorMatching(const gfx::Rect& match_rect) { 110 gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) {
111 NSScreen* match_screen = GetMatchingScreen(match_rect); 111 NSScreen* match_screen = GetMatchingScreen(match_rect);
112 return GetDisplayForScreen(match_screen, false /* may not be primary */); 112 return GetDisplayForScreen(match_screen, false /* may not be primary */);
113 } 113 }
114 114
115 // static 115 // static
116 int Screen::GetNumMonitors() { 116 int Screen::GetNumDisplays() {
117 // Don't just return the number of online displays. It includes displays 117 // Don't just return the number of online displays. It includes displays
118 // that mirror other displays, which are not desired in the count. It's 118 // that mirror other displays, which are not desired in the count. It's
119 // tempting to use the count returned by CGGetActiveDisplayList, but active 119 // tempting to use the count returned by CGGetActiveDisplayList, but active
120 // displays exclude sleeping displays, and those are desired in the count. 120 // displays exclude sleeping displays, and those are desired in the count.
121 121
122 // It would be ridiculous to have this many displays connected, but 122 // It would be ridiculous to have this many displays connected, but
123 // CGDirectDisplayID is just an integer, so supporting up to this many 123 // CGDirectDisplayID is just an integer, so supporting up to this many
124 // doesn't hurt. 124 // doesn't hurt.
125 CGDirectDisplayID online_displays[128]; 125 CGDirectDisplayID online_displays[128];
126 CGDisplayCount online_display_count = 0; 126 CGDisplayCount online_display_count = 0;
(...skipping 14 matching lines...) Expand all
141 // The primary display in a mirrored set will be counted, but those that 141 // The primary display in a mirrored set will be counted, but those that
142 // mirror it will not be. 142 // mirror it will not be.
143 ++display_count; 143 ++display_count;
144 } 144 }
145 } 145 }
146 146
147 return display_count; 147 return display_count;
148 } 148 }
149 149
150 // static 150 // static
151 gfx::Display Screen::GetMonitorNearestPoint(const gfx::Point& point) { 151 gfx::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) {
152 NSPoint ns_point = NSPointFromCGPoint(point.ToCGPoint()); 152 NSPoint ns_point = NSPointFromCGPoint(point.ToCGPoint());
153 153
154 NSArray* screens = [NSScreen screens]; 154 NSArray* screens = [NSScreen screens];
155 NSScreen* primary = [screens objectAtIndex:0]; 155 NSScreen* primary = [screens objectAtIndex:0];
156 for (NSScreen* screen in screens) { 156 for (NSScreen* screen in screens) {
157 if (NSMouseInRect(ns_point, [screen frame], NO)) 157 if (NSMouseInRect(ns_point, [screen frame], NO))
158 return GetDisplayForScreen(screen, screen == primary); 158 return GetDisplayForScreen(screen, screen == primary);
159 } 159 }
160 NOTREACHED(); 160 NOTREACHED();
161 return gfx::Display(); 161 return gfx::Display();
162 } 162 }
163 163
164 } // namespace gfx 164 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/screen_impl.h ('k') | ui/gfx/screen_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698