Share main loop implementation between wayland and X11

This commit is contained in:
Kovid Goyal
2019-02-26 21:21:14 +05:30
parent e6d5eea7eb
commit d4b477ad78
4 changed files with 54 additions and 34 deletions

33
glfw/x11_init.c vendored
View File

@@ -770,35 +770,4 @@ const char* _glfwPlatformGetVersionString(void)
;
}
static GLFWbool keep_going = GLFW_FALSE, tick_callback_requested = GLFW_FALSE;
void _glfwPlatformRequestTickCallback() {
tick_callback_requested = GLFW_TRUE;
}
void _glfwPlatformStopMainLoop(void) {
if (keep_going) {
keep_going = GLFW_FALSE;
_glfwPlatformPostEmptyEvent();
}
}
void _glfwPlatformRunMainLoop(GLFWtickcallback callback, void* data) {
keep_going = GLFW_TRUE;
tick_callback_requested = GLFW_FALSE;
while(keep_going) {
while (tick_callback_requested) {
tick_callback_requested = GLFW_FALSE;
callback(data);
}
_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 _glfwPlatformRemoveTimer(unsigned long long timer_id) {
removeTimer(&_glfw.x11.eventLoopData, timer_id);
}
#include "main_loop.h"