From c5099ff4074cb29ad0fe3d86a0b672270caf1e9b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 9 Apr 2015 16:09:39 +0200 Subject: [PATCH] Cleanup of #493. --- README.md | 2 ++ src/cocoa_window.m | 18 +++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c41f2070..a9ea8063 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ GLFW bundles a number of dependencies in the `deps/` directory. - Bugfix: Initialization failed on headless systems - Bugfix: The cached current context could get out of sync + - [Cocoa] Bugfix: The cached `NSScreen` for a monitor could get out of sync ## Contact @@ -102,6 +103,7 @@ skills. - Doug Binks - blanco - Martin Capitanio + - Chi-kwan Chan - Lambert Clara - Andrew Corrigan - Noel Cower diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 15a624dc..143a43b3 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -32,20 +32,16 @@ #include -// Returns the screen that is specified by a displayID +// Returns the NSScreen corresponding to the specified CGDirectDisplayID // -static NSScreen *getScreen(CGDirectDisplayID displayID) +static NSScreen* getScreen(CGDirectDisplayID displayID) { - // NOTE: Apple's documentation of [NSScreen screens] mentions that, - // "The (screens) array should not be cached. Screens can be - // added, removed, or dynamically reconfigured at any time." - // Because of this, we simply obtain the screen from a - // displayID whenever we need it. - NSArray *screens = [NSScreen screens]; + NSArray* screens = [NSScreen screens]; - for(NSScreen *screen in screens) { - NSDictionary *dictionary = [screen deviceDescription]; - NSNumber *number = [dictionary objectForKey:@"NSScreenNumber"]; + for (NSScreen* screen in screens) + { + NSDictionary* dictionary = [screen deviceDescription]; + NSNumber* number = [dictionary objectForKey:@"NSScreenNumber"]; if ([number unsignedIntegerValue] == displayID) return screen; }