1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00
This commit is contained in:
Camilla Berglund 2013-06-24 14:38:00 +02:00
parent a17dad4f44
commit 4883073b91
5 changed files with 30 additions and 42 deletions

View File

@ -84,19 +84,18 @@ int _glfwPlatformInit(void)
changeToResourcesDirectory(); changeToResourcesDirectory();
#endif #endif
_glfwInitTimer();
_glfwInitJoysticks();
if (!_glfwInitContextAPI())
return GL_FALSE;
_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
if (!_glfw.ns.eventSource) if (!_glfw.ns.eventSource)
return GL_FALSE; return GL_FALSE;
CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0); CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
if (!_glfwInitContextAPI())
return GL_FALSE;
_glfwInitTimer();
_glfwInitJoysticks();
return GL_TRUE; return GL_TRUE;
} }
@ -121,7 +120,6 @@ void _glfwPlatformTerminate(void)
free(_glfw.ns.clipboardString); free(_glfw.ns.clipboardString);
_glfwTerminateJoysticks(); _glfwTerminateJoysticks();
_glfwTerminateContextAPI(); _glfwTerminateContextAPI();
} }

View File

@ -98,7 +98,7 @@ static GLboolean initLibraries(void)
// Unload used libraries (DLLs) // Unload used libraries (DLLs)
// //
static void freeLibraries(void) static void terminateLibraries(void)
{ {
#ifndef _GLFW_NO_DLOAD_WINMM #ifndef _GLFW_NO_DLOAD_WINMM
if (_glfw.win32.winmm.instance != NULL) if (_glfw.win32.winmm.instance != NULL)
@ -204,7 +204,6 @@ int _glfwPlatformInit(void)
return GL_FALSE; return GL_FALSE;
_glfwInitTimer(); _glfwInitTimer();
_glfwInitJoysticks(); _glfwInitJoysticks();
return GL_TRUE; return GL_TRUE;
@ -218,18 +217,16 @@ void _glfwPlatformTerminate(void)
_glfw.win32.classAtom = 0; _glfw.win32.classAtom = 0;
} }
free(_glfw.win32.clipboardString); // Restore previous foreground lock timeout system setting
_glfwTerminateContextAPI();
_glfwTerminateJoysticks();
freeLibraries();
// Restore previous FOREGROUNDLOCKTIMEOUT system setting
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
UIntToPtr(_glfw.win32.foregroundLockTimeout), UIntToPtr(_glfw.win32.foregroundLockTimeout),
SPIF_SENDCHANGE); SPIF_SENDCHANGE);
free(_glfw.win32.clipboardString);
_glfwTerminateJoysticks();
_glfwTerminateContextAPI();
terminateLibraries();
} }
const char* _glfwPlatformGetVersionString(void) const char* _glfwPlatformGetVersionString(void)

View File

@ -420,21 +420,10 @@ static void detectEWMH(void)
// Initialize X11 display and look for supported X11 extensions // Initialize X11 display and look for supported X11 extensions
// //
static GLboolean initDisplay(void) static GLboolean initExtensions(void)
{ {
Bool supported; Bool supported;
_glfw.x11.display = XOpenDisplay(NULL);
if (!_glfw.x11.display)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "X11: Failed to open X display");
return GL_FALSE;
}
_glfw.x11.screen = DefaultScreen(_glfw.x11.display);
_glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
_glfw.x11.context = XUniqueContext();
// Find or create window manager atoms // Find or create window manager atoms
_glfw.x11.WM_STATE = XInternAtom(_glfw.x11.display, "WM_STATE", False); _glfw.x11.WM_STATE = XInternAtom(_glfw.x11.display, "WM_STATE", False);
_glfw.x11.WM_DELETE_WINDOW = XInternAtom(_glfw.x11.display, _glfw.x11.WM_DELETE_WINDOW = XInternAtom(_glfw.x11.display,
@ -602,20 +591,28 @@ int _glfwPlatformInit(void)
{ {
XInitThreads(); XInitThreads();
if (!initDisplay()) _glfw.x11.display = XOpenDisplay(NULL);
if (!_glfw.x11.display)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "X11: Failed to open X display");
return GL_FALSE; return GL_FALSE;
}
_glfwInitGammaRamp(); _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
_glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
_glfw.x11.context = XUniqueContext();
if (!_glfwInitContextAPI()) if (!initExtensions())
return GL_FALSE; return GL_FALSE;
_glfw.x11.cursor = createNULLCursor(); _glfw.x11.cursor = createNULLCursor();
if (!_glfwInitJoysticks()) if (!_glfwInitContextAPI())
return GL_FALSE; return GL_FALSE;
_glfwInitTimer(); _glfwInitTimer();
_glfwInitJoysticks();
_glfwInitGammaRamp();
return GL_TRUE; return GL_TRUE;
} }
@ -631,9 +628,7 @@ void _glfwPlatformTerminate(void)
free(_glfw.x11.selection.string); free(_glfw.x11.selection.string);
_glfwTerminateJoysticks(); _glfwTerminateJoysticks();
_glfwTerminateContextAPI(); _glfwTerminateContextAPI();
terminateDisplay(); terminateDisplay();
} }

View File

@ -159,7 +159,7 @@ static void pollJoystickEvents(void)
// Initialize joystick interface // Initialize joystick interface
// //
int _glfwInitJoysticks(void) void _glfwInitJoysticks(void)
{ {
#ifdef __linux__ #ifdef __linux__
int i, joy = 0; int i, joy = 0;
@ -174,7 +174,7 @@ int _glfwInitJoysticks(void)
if (regcomp(&regex, "^js[0-9]\\+$", 0) != 0) if (regcomp(&regex, "^js[0-9]\\+$", 0) != 0)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to compile regex"); _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to compile regex");
return GL_FALSE; return;
} }
for (i = 0; i < sizeof(dirs) / sizeof(dirs[0]); i++) for (i = 0; i < sizeof(dirs) / sizeof(dirs[0]); i++)
@ -203,8 +203,6 @@ int _glfwInitJoysticks(void)
regfree(&regex); regfree(&regex);
#endif // __linux__ #endif // __linux__
return GL_TRUE;
} }
// Close all opened joystick handles // Close all opened joystick handles

View File

@ -238,7 +238,7 @@ void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);
void _glfwRestoreVideoMode(_GLFWmonitor* monitor); void _glfwRestoreVideoMode(_GLFWmonitor* monitor);
// Joystick input // Joystick input
int _glfwInitJoysticks(void); void _glfwInitJoysticks(void);
void _glfwTerminateJoysticks(void); void _glfwTerminateJoysticks(void);
// Unicode support // Unicode support