Ensure queued display events are dispatched when polling/waiting for events

This commit is contained in:
Kovid Goyal 2018-07-13 10:56:12 +05:30
parent 31853ee20c
commit 55556aaac4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 4 deletions

5
glfw/wl_window.c vendored
View File

@ -1163,16 +1163,19 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
void _glfwPlatformPollEvents(void)
{
wl_display_dispatch_pending(_glfw.wl.display);
handleEvents(0);
}
void _glfwPlatformWaitEvents(void)
{
handleEvents(-1);
double timeout = wl_display_dispatch_pending(_glfw.wl.display) > 0 ? 0 : -1;
handleEvents(timeout);
}
void _glfwPlatformWaitEventsTimeout(double timeout)
{
if (wl_display_dispatch_pending(_glfw.wl.display) > 0) timeout = 0;
handleEvents(timeout);
}

13
glfw/x11_window.c vendored
View File

@ -54,7 +54,7 @@
// This avoids blocking other threads via the per-display Xlib lock that also
// covers GLX functions
//
void _glfwDispatchX11Events(void);
GLFWbool _glfwDispatchX11Events(void);
static void
handleEvents(double timeout) {
@ -2543,8 +2543,10 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
PropModeReplace, (unsigned char*) &value, 1);
}
void _glfwDispatchX11Events(void) {
GLFWbool
_glfwDispatchX11Events(void) {
_GLFWwindow* window;
GLFWbool dispatched = GLFW_FALSE;
#if defined(__linux__)
_glfwDetectJoystickConnectionLinux();
@ -2556,6 +2558,7 @@ void _glfwDispatchX11Events(void) {
XEvent event;
XNextEvent(_glfw.x11.display, &event);
processEvent(&event);
dispatched = GLFW_TRUE;
}
window = _glfw.x11.disabledCursorWindow;
@ -2574,20 +2577,24 @@ void _glfwDispatchX11Events(void) {
}
XFlush(_glfw.x11.display);
return dispatched;
}
void _glfwPlatformPollEvents(void)
{
_glfwDispatchX11Events();
handleEvents(0);
}
void _glfwPlatformWaitEvents(void)
{
handleEvents(-1);
double timeout = _glfwDispatchX11Events() ? 0 : -1;
handleEvents(timeout);
}
void _glfwPlatformWaitEventsTimeout(double timeout)
{
if (_glfwDispatchX11Events()) timeout = 0;
handleEvents(timeout);
}