Infrastructure for moving the run loop into GLFW

This is needed on Cocoa, where Apple expects to be in control of the run
loop.
This commit is contained in:
Kovid Goyal
2019-02-25 13:58:45 +05:30
parent 13254ac4d5
commit da507dfd19
12 changed files with 129 additions and 6 deletions

25
glfw/x11_init.c vendored
View File

@@ -675,6 +675,7 @@ int _glfwPlatformInit(void)
void _glfwPlatformTerminate(void)
{
removeAllTimers(&_glfw.x11.eventLoopData);
if (_glfw.x11.helperWindowHandle)
{
if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==
@@ -768,3 +769,27 @@ const char* _glfwPlatformGetVersionString(void)
#endif
;
}
static GLFWbool keep_going;
void _glfwPlatformStopMainLoop(void) {
if (keep_going) {
keep_going = GLFW_FALSE;
_glfwPlatformPostEmptyEvent();
}
}
void _glfwPlatformRunMainLoop(void) {
keep_going = GLFW_TRUE;
while(keep_going) {
_glfwPlatformWaitEvents();
}
}
unsigned long long _glfwPlatformAddTimer(double interval, bool repeats, GLFWuserdatafreefun callback, void *callback_data, GLFWuserdatafreefun free_callback) {
return addTimer(&_glfw.x11.eventLoopData, "user timer", interval, 1, repeats, callback, callback_data, free_callback);
}
void _glfwRemoveTimer(unsigned long long timer_id) {
removeTimer(&_glfw.x11.eventLoopData, timer_id);
}