mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 18:15:10 +00:00
Removed NSScreen member of OS X monitor.
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. Fixes #492. Closes #493.
This commit is contained in:
parent
882b770ecb
commit
4277e9f5d6
@ -286,7 +286,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
|
||||
monitor = _glfwAllocMonitor(name, size.width, size.height);
|
||||
monitor->ns.displayID = displays[i];
|
||||
monitor->ns.screen = [screens objectAtIndex:j];
|
||||
|
||||
free(name);
|
||||
|
||||
|
@ -92,7 +92,6 @@ typedef struct _GLFWmonitorNS
|
||||
{
|
||||
CGDirectDisplayID displayID;
|
||||
CGDisplayModeRef previousMode;
|
||||
id screen;
|
||||
|
||||
} _GLFWmonitorNS;
|
||||
|
||||
|
@ -32,6 +32,27 @@
|
||||
#include <crt_externs.h>
|
||||
|
||||
|
||||
// Returns the screen that is specified by a 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];
|
||||
|
||||
for(NSScreen *screen in screens) {
|
||||
NSDictionary *dictionary = [screen deviceDescription];
|
||||
NSNumber *number = [dictionary objectForKey:@"NSScreenNumber"];
|
||||
if ([number unsignedIntegerValue] == displayID)
|
||||
return screen;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Returns the specified standard cursor
|
||||
//
|
||||
static NSCursor* getStandardCursor(int shape)
|
||||
@ -89,8 +110,8 @@ static GLboolean enterFullscreenMode(_GLFWwindow* window)
|
||||
|
||||
// NOTE: The window is resized despite mode setting failure to make
|
||||
// glfwSetWindowSize more robust
|
||||
[window->ns.object setFrame:[window->monitor->ns.screen frame]
|
||||
display:YES];
|
||||
[window->ns.object setFrame:[getScreen(window->monitor->ns.displayID) frame]
|
||||
display:YES];
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -838,7 +859,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
||||
NSRect contentRect;
|
||||
|
||||
if (wndconfig->monitor)
|
||||
contentRect = [wndconfig->monitor->ns.screen frame];
|
||||
contentRect = [getScreen(wndconfig->monitor->ns.displayID) frame];
|
||||
else
|
||||
contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user