mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Replace NSScreen with platform functions
This commit is contained in:
parent
4ad00fa388
commit
f6f0771770
@ -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]);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user