Replace NSScreen with platform functions

This commit is contained in:
Camilla Berglund 2015-09-01 18:33:34 +02:00
parent 4ad00fa388
commit f6f0771770
2 changed files with 16 additions and 39 deletions

View File

@ -256,29 +256,12 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
monitors = calloc(displayCount, sizeof(_GLFWmonitor*));
CGGetOnlineDisplayList(displayCount, displays, &displayCount);
NSArray* screens = [NSScreen screens];
for (i = 0; i < displayCount; i++)
{
NSUInteger j;
_GLFWmonitor* monitor;
CGDirectDisplayID screenDisplayID = CGDisplayMirrorsDisplay(displays[i]);
if (screenDisplayID == kCGNullDirectDisplay)
screenDisplayID = displays[i];
for (j = 0; j < [screens count]; j++)
{
NSScreen* screen = [screens objectAtIndex:j];
NSDictionary* dictionary = [screen deviceDescription];
NSNumber* number = [dictionary objectForKey:@"NSScreenNumber"];
if ([number unsignedIntegerValue] == screenDisplayID)
break;
}
// Skip displays that has no screen
if (j == [screens count])
if (CGDisplayIsAsleep(displays[i]))
continue;
const CGSize size = CGDisplayScreenSize(displays[i]);

View File

@ -32,23 +32,6 @@
#include <crt_externs.h>
// Returns the NSScreen corresponding to the specified CGDirectDisplayID
//
static NSScreen* getScreen(CGDirectDisplayID displayID)
{
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)
@ -100,13 +83,16 @@ static void updateModeCursor(_GLFWwindow* window)
//
static GLboolean enterFullscreenMode(_GLFWwindow* window)
{
GLFWvidmode mode;
GLboolean status;
int xpos, ypos;
status = _glfwSetVideoMode(window->monitor, &window->videoMode);
// NOTE: The window is resized despite mode setting failure to make
// glfwSetWindowSize more robust
[window->ns.object setFrame:[getScreen(window->monitor->ns.displayID) frame]
_glfwPlatformGetVideoMode(window->monitor, &mode);
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
[window->ns.object setFrame:NSMakeRect(xpos, ypos, mode.width, mode.height)
display:YES];
return status;
@ -864,7 +850,15 @@ static GLboolean createWindow(_GLFWwindow* window,
NSRect contentRect;
if (wndconfig->monitor)
contentRect = [getScreen(wndconfig->monitor->ns.displayID) frame];
{
GLFWvidmode mode;
int xpos, ypos;
_glfwPlatformGetVideoMode(window->monitor, &mode);
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height);
}
else
contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);