mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Added initial NSScreen integration.
This (tentatively) fixes the bug of full screen windows on OS X always opening on the primary monitor.
This commit is contained in:
parent
130f07d8c3
commit
57751a5494
@ -1171,9 +1171,6 @@ GLFWAPI void glfwWindowHint(int target, int hint);
|
||||
*
|
||||
* @note This function may only be called from the main thread.
|
||||
*
|
||||
* @bug **Mac OS X:** The primary monitor is always used for full screen
|
||||
* windows, regardless of which monitor was specified.
|
||||
*
|
||||
* @sa glfwDestroyWindow
|
||||
*
|
||||
* @ingroup window
|
||||
|
@ -272,6 +272,35 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
}
|
||||
}
|
||||
|
||||
NSArray* screens = [NSScreen screens];
|
||||
|
||||
for (i = 0; i < monitorCount; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; j < [screens count]; j++)
|
||||
{
|
||||
NSScreen* screen = [screens objectAtIndex:j];
|
||||
NSDictionary* dictionary = [screen deviceDescription];
|
||||
NSNumber* number = [dictionary objectForKey:@"NSScreenNumber"];
|
||||
|
||||
if (monitors[i]->ns.displayID == [number unsignedIntegerValue])
|
||||
{
|
||||
monitors[i]->ns.screen = screen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (monitors[i]->ns.screen == nil)
|
||||
{
|
||||
_glfwDestroyMonitors(monitors, monitorCount);
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to find NSScreen for CGDisplay %s",
|
||||
monitors[i]->name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*count = monitorCount;
|
||||
return monitors;
|
||||
}
|
||||
|
@ -119,8 +119,9 @@ typedef struct _GLFWlibraryNS
|
||||
//------------------------------------------------------------------------
|
||||
typedef struct _GLFWmonitorNS
|
||||
{
|
||||
CGDirectDisplayID displayID;
|
||||
CGDisplayModeRef previousMode;
|
||||
CGDirectDisplayID displayID;
|
||||
CGDisplayModeRef previousMode;
|
||||
id screen;
|
||||
|
||||
} _GLFWmonitorNS;
|
||||
|
||||
|
@ -759,7 +759,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
return GL_FALSE;
|
||||
|
||||
_glfwPlatformShowWindow(window);
|
||||
[[window->ns.object contentView] enterFullScreenMode:[NSScreen mainScreen]
|
||||
[[window->ns.object contentView] enterFullScreenMode:wndconfig->monitor->ns.screen
|
||||
withOptions:nil];
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,9 @@ GLFWAPI void glfwTerminate(void)
|
||||
_glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);
|
||||
}
|
||||
|
||||
_glfwDestroyMonitors();
|
||||
_glfwDestroyMonitors(_glfw.monitors, _glfw.monitorCount);
|
||||
_glfw.monitors = NULL;
|
||||
_glfw.monitorCount = 0;
|
||||
|
||||
_glfwPlatformTerminate();
|
||||
|
||||
|
@ -706,6 +706,6 @@ void _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
||||
|
||||
/*! @ingroup utility
|
||||
*/
|
||||
void _glfwDestroyMonitors(void);
|
||||
void _glfwDestroyMonitors(_GLFWmonitor** monitors, int count);
|
||||
|
||||
#endif // _internal_h_
|
||||
|
@ -144,7 +144,7 @@ void _glfwInputMonitorChange(void)
|
||||
}
|
||||
}
|
||||
|
||||
_glfwDestroyMonitors();
|
||||
_glfwDestroyMonitors(_glfw.monitors, _glfw.monitorCount);
|
||||
|
||||
_glfw.monitors = monitors;
|
||||
_glfw.monitorCount = monitorCount;
|
||||
@ -175,16 +175,14 @@ void _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
||||
free(monitor);
|
||||
}
|
||||
|
||||
void _glfwDestroyMonitors(void)
|
||||
void _glfwDestroyMonitors(_GLFWmonitor** monitors, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < _glfw.monitorCount; i++)
|
||||
_glfwDestroyMonitor(_glfw.monitors[i]);
|
||||
for (i = 0; i < count; i++)
|
||||
_glfwDestroyMonitor(monitors[i]);
|
||||
|
||||
free(_glfw.monitors);
|
||||
_glfw.monitors = NULL;
|
||||
_glfw.monitorCount = 0;
|
||||
free(monitors);
|
||||
}
|
||||
|
||||
const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
||||
|
Loading…
Reference in New Issue
Block a user