mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 20:28:49 -05: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.
|
* @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
|
* @sa glfwDestroyWindow
|
||||||
*
|
*
|
||||||
* @ingroup window
|
* @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;
|
*count = monitorCount;
|
||||||
return monitors;
|
return monitors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,8 +119,9 @@ typedef struct _GLFWlibraryNS
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
typedef struct _GLFWmonitorNS
|
typedef struct _GLFWmonitorNS
|
||||||
{
|
{
|
||||||
CGDirectDisplayID displayID;
|
CGDirectDisplayID displayID;
|
||||||
CGDisplayModeRef previousMode;
|
CGDisplayModeRef previousMode;
|
||||||
|
id screen;
|
||||||
|
|
||||||
} _GLFWmonitorNS;
|
} _GLFWmonitorNS;
|
||||||
|
|
||||||
|
|
|
@ -759,7 +759,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
_glfwPlatformShowWindow(window);
|
_glfwPlatformShowWindow(window);
|
||||||
[[window->ns.object contentView] enterFullScreenMode:[NSScreen mainScreen]
|
[[window->ns.object contentView] enterFullScreenMode:wndconfig->monitor->ns.screen
|
||||||
withOptions:nil];
|
withOptions:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,9 @@ GLFWAPI void glfwTerminate(void)
|
||||||
_glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);
|
_glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwDestroyMonitors();
|
_glfwDestroyMonitors(_glfw.monitors, _glfw.monitorCount);
|
||||||
|
_glfw.monitors = NULL;
|
||||||
|
_glfw.monitorCount = 0;
|
||||||
|
|
||||||
_glfwPlatformTerminate();
|
_glfwPlatformTerminate();
|
||||||
|
|
||||||
|
|
|
@ -706,6 +706,6 @@ void _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
/*! @ingroup utility
|
/*! @ingroup utility
|
||||||
*/
|
*/
|
||||||
void _glfwDestroyMonitors(void);
|
void _glfwDestroyMonitors(_GLFWmonitor** monitors, int count);
|
||||||
|
|
||||||
#endif // _internal_h_
|
#endif // _internal_h_
|
||||||
|
|
|
@ -144,7 +144,7 @@ void _glfwInputMonitorChange(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwDestroyMonitors();
|
_glfwDestroyMonitors(_glfw.monitors, _glfw.monitorCount);
|
||||||
|
|
||||||
_glfw.monitors = monitors;
|
_glfw.monitors = monitors;
|
||||||
_glfw.monitorCount = monitorCount;
|
_glfw.monitorCount = monitorCount;
|
||||||
|
@ -175,16 +175,14 @@ void _glfwDestroyMonitor(_GLFWmonitor* monitor)
|
||||||
free(monitor);
|
free(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwDestroyMonitors(void)
|
void _glfwDestroyMonitors(_GLFWmonitor** monitors, int count)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < _glfw.monitorCount; i++)
|
for (i = 0; i < count; i++)
|
||||||
_glfwDestroyMonitor(_glfw.monitors[i]);
|
_glfwDestroyMonitor(monitors[i]);
|
||||||
|
|
||||||
free(_glfw.monitors);
|
free(monitors);
|
||||||
_glfw.monitors = NULL;
|
|
||||||
_glfw.monitorCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user