Index: ui/gfx/screen_mac.mm |
diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm |
index 28707ca7ea3a15ca95b127b2d6655fce60e624fa..704a59591a15174c78126b1a904a18f28ce9b06d 100644 |
--- a/ui/gfx/screen_mac.mm |
+++ b/ui/gfx/screen_mac.mm |
@@ -96,10 +96,15 @@ class ScreenMac : public gfx::Screen { |
} |
virtual int GetNumDisplays() const OVERRIDE { |
- // Don't just return the number of online displays. It includes displays |
- // that mirror other displays, which are not desired in the count. It's |
+ return GetAllDisplays().size(); |
+ |
+ } |
+ |
+ virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { |
+ // Don't just return all online displays. This would include displays |
+ // that mirror other displays, which are not desired in this list. It's |
// tempting to use the count returned by CGGetActiveDisplayList, but active |
- // displays exclude sleeping displays, and those are desired in the count. |
+ // displays exclude sleeping displays, and those are desired. |
// It would be ridiculous to have this many displays connected, but |
// CGDirectDisplayID is just an integer, so supporting up to this many |
@@ -109,29 +114,33 @@ class ScreenMac : public gfx::Screen { |
if (CGGetOnlineDisplayList(arraysize(online_displays), |
online_displays, |
&online_display_count) != kCGErrorSuccess) { |
- // 1 is a reasonable assumption. |
- return 1; |
+ return std::vector<gfx::Display>(1, GetPrimaryDisplay()); |
} |
- int display_count = 0; |
+ std::vector<gfx::Display> displays; |
for (CGDisplayCount online_display_index = 0; |
online_display_index < online_display_count; |
++online_display_index) { |
CGDirectDisplayID online_display = online_displays[online_display_index]; |
if (CGDisplayMirrorsDisplay(online_display) == kCGNullDirectDisplay) { |
- // If this display doesn't mirror any other, include it in the count. |
+ // If this display doesn't mirror any other, include it in the list. |
// The primary display in a mirrored set will be counted, but those that |
// mirror it will not be. |
- ++display_count; |
+ // Search for the associated screen and add it to our list. |
+ for (NSScreen* screen in [NSScreen screens]) { |
+ NSDictionary* screenDeviceDescription = [screen deviceDescription]; |
Nico
2013/10/24 15:41:27
Can you build an id -> NSScreen map before this lo
|
+ if (online_display == [[screenDeviceDescription |
+ objectForKey:@"NSScreenNumber"] unsignedIntValue]) { |
+ displays.push_back(GetDisplayForScreen(screen, false)); |
+ } |
+ } |
} |
} |
- return display_count; |
- } |
+ if (!displays.size()) |
+ return std::vector<gfx::Display>(1, GetPrimaryDisplay()); |
- virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { |
- NOTIMPLEMENTED(); |
- return std::vector<gfx::Display>(1, GetPrimaryDisplay()); |
+ return displays; |
} |
virtual gfx::Display GetDisplayNearestWindow( |