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

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

Issue 1543183002: Switch to standard integer types in ui/gfx/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « ui/gfx/screen_android.cc ('k') | ui/gfx/screen_type_delegate.h » ('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 #include <stdint.h>
9 10
10 #include <map> 11 #include <map>
11 12
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/mac/sdk_forward_declarations.h" 14 #include "base/mac/sdk_forward_declarations.h"
15 #include "base/macros.h"
14 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
15 #include "ui/gfx/display.h" 17 #include "ui/gfx/display.h"
16 #include "ui/gfx/display_change_notifier.h" 18 #include "ui/gfx/display_change_notifier.h"
17 19
18 namespace { 20 namespace {
19 21
20 // The delay to handle the display configuration changes. 22 // The delay to handle the display configuration changes.
21 // See comments in ScreenMac::HandleDisplayReconfiguration. 23 // See comments in ScreenMac::HandleDisplayReconfiguration.
22 const int64 kConfigureDelayMs = 500; 24 const int64_t kConfigureDelayMs = 500;
23 25
24 gfx::Rect ConvertCoordinateSystem(NSRect ns_rect) { 26 gfx::Rect ConvertCoordinateSystem(NSRect ns_rect) {
25 // Primary monitor is defined as the monitor with the menubar, 27 // Primary monitor is defined as the monitor with the menubar,
26 // which is always at index 0. 28 // which is always at index 0.
27 NSScreen* primary_screen = [[NSScreen screens] firstObject]; 29 NSScreen* primary_screen = [[NSScreen screens] firstObject];
28 float primary_screen_height = [primary_screen frame].size.height; 30 float primary_screen_height = [primary_screen frame].size.height;
29 gfx::Rect rect(NSRectToCGRect(ns_rect)); 31 gfx::Rect rect(NSRectToCGRect(ns_rect));
30 rect.set_y(primary_screen_height - rect.y() - rect.height()); 32 rect.set_y(primary_screen_height - rect.y() - rect.height());
31 return rect; 33 return rect;
32 } 34 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // CGDirectDisplayID is just an integer, so supporting up to this many 220 // CGDirectDisplayID is just an integer, so supporting up to this many
219 // doesn't hurt. 221 // doesn't hurt.
220 CGDirectDisplayID online_displays[128]; 222 CGDirectDisplayID online_displays[128];
221 CGDisplayCount online_display_count = 0; 223 CGDisplayCount online_display_count = 0;
222 if (CGGetOnlineDisplayList(arraysize(online_displays), 224 if (CGGetOnlineDisplayList(arraysize(online_displays),
223 online_displays, 225 online_displays,
224 &online_display_count) != kCGErrorSuccess) { 226 &online_display_count) != kCGErrorSuccess) {
225 return std::vector<gfx::Display>(1, GetPrimaryDisplay()); 227 return std::vector<gfx::Display>(1, GetPrimaryDisplay());
226 } 228 }
227 229
228 typedef std::map<int64, NSScreen*> ScreenIdsToScreensMap; 230 typedef std::map<int64_t, NSScreen*> ScreenIdsToScreensMap;
229 ScreenIdsToScreensMap screen_ids_to_screens; 231 ScreenIdsToScreensMap screen_ids_to_screens;
230 for (NSScreen* screen in [NSScreen screens]) { 232 for (NSScreen* screen in [NSScreen screens]) {
231 NSDictionary* screen_device_description = [screen deviceDescription]; 233 NSDictionary* screen_device_description = [screen deviceDescription];
232 int64 screen_id = [[screen_device_description 234 int64_t screen_id = [[screen_device_description
233 objectForKey:@"NSScreenNumber"] unsignedIntValue]; 235 objectForKey:@"NSScreenNumber"] unsignedIntValue];
234 screen_ids_to_screens[screen_id] = screen; 236 screen_ids_to_screens[screen_id] = screen;
235 } 237 }
236 238
237 std::vector<gfx::Display> displays; 239 std::vector<gfx::Display> displays;
238 for (CGDisplayCount online_display_index = 0; 240 for (CGDisplayCount online_display_index = 0;
239 online_display_index < online_display_count; 241 online_display_index < online_display_count;
240 ++online_display_index) { 242 ++online_display_index) {
241 CGDirectDisplayID online_display = online_displays[online_display_index]; 243 CGDirectDisplayID online_display = online_displays[online_display_index];
242 if (CGDisplayMirrorsDisplay(online_display) == kCGNullDirectDisplay) { 244 if (CGDisplayMirrorsDisplay(online_display) == kCGNullDirectDisplay) {
243 // If this display doesn't mirror any other, include it in the list. 245 // If this display doesn't mirror any other, include it in the list.
(...skipping 29 matching lines...) Expand all
273 275
274 namespace gfx { 276 namespace gfx {
275 277
276 #if !defined(USE_AURA) 278 #if !defined(USE_AURA)
277 Screen* CreateNativeScreen() { 279 Screen* CreateNativeScreen() {
278 return new ScreenMac; 280 return new ScreenMac;
279 } 281 }
280 #endif 282 #endif
281 283
282 } 284 }
OLDNEW
« no previous file with comments | « ui/gfx/screen_android.cc ('k') | ui/gfx/screen_type_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698