mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Wayland: Improve event processing with timeout
If the polling was interrupted by a signal or by incomplete or unrelated
data on any file descriptor, handleEvents could return before the full
timeout had elapsed.
This retries the Wayland prepare-to-read and poll until the full timeout
has elapsed or until any event was processed. Unfortunately, due to how
the Wayland client API is designed, this also includes the delete_id
for the frame callback created by eglSwapBuffers.
This means glfwWaitEvents* are still not fully functional on Wayland.
See #1911 for more details.
(cherry picked from commit 71742d9a27
)
This commit is contained in:
parent
eac18b9324
commit
9cfd4c49b0
@ -900,6 +900,7 @@ static GLFWbool flushDisplay(void)
|
|||||||
|
|
||||||
static void handleEvents(double* timeout)
|
static void handleEvents(double* timeout)
|
||||||
{
|
{
|
||||||
|
GLFWbool event = GLFW_FALSE;
|
||||||
struct pollfd fds[] =
|
struct pollfd fds[] =
|
||||||
{
|
{
|
||||||
{ wl_display_get_fd(_glfw.wl.display), POLLIN },
|
{ wl_display_get_fd(_glfw.wl.display), POLLIN },
|
||||||
@ -907,6 +908,8 @@ static void handleEvents(double* timeout)
|
|||||||
{ _glfw.wl.cursorTimerfd, POLLIN },
|
{ _glfw.wl.cursorTimerfd, POLLIN },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
while (!event)
|
||||||
|
{
|
||||||
while (wl_display_prepare_read(_glfw.wl.display) != 0)
|
while (wl_display_prepare_read(_glfw.wl.display) != 0)
|
||||||
wl_display_dispatch_pending(_glfw.wl.display);
|
wl_display_dispatch_pending(_glfw.wl.display);
|
||||||
|
|
||||||
@ -926,12 +929,17 @@ static void handleEvents(double* timeout)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waitForData(fds, 3, timeout) > 0)
|
if (!waitForData(fds, 3, timeout))
|
||||||
{
|
{
|
||||||
|
wl_display_cancel_read(_glfw.wl.display);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (fds[0].revents & POLLIN)
|
if (fds[0].revents & POLLIN)
|
||||||
{
|
{
|
||||||
wl_display_read_events(_glfw.wl.display);
|
wl_display_read_events(_glfw.wl.display);
|
||||||
wl_display_dispatch_pending(_glfw.wl.display);
|
if (wl_display_dispatch_pending(_glfw.wl.display) > 0)
|
||||||
|
event = GLFW_TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wl_display_cancel_read(_glfw.wl.display);
|
wl_display_cancel_read(_glfw.wl.display);
|
||||||
@ -952,6 +960,8 @@ static void handleEvents(double* timeout)
|
|||||||
_glfwInputTextWayland(_glfw.wl.keyboardFocus,
|
_glfwInputTextWayland(_glfw.wl.keyboardFocus,
|
||||||
_glfw.wl.keyboardLastScancode);
|
_glfw.wl.keyboardLastScancode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event = GLFW_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,11 +970,12 @@ static void handleEvents(double* timeout)
|
|||||||
uint64_t repeats;
|
uint64_t repeats;
|
||||||
|
|
||||||
if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8)
|
if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8)
|
||||||
|
{
|
||||||
incrementCursorImage(_glfw.wl.pointerFocus);
|
incrementCursorImage(_glfw.wl.pointerFocus);
|
||||||
|
event = GLFW_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
wl_display_cancel_read(_glfw.wl.display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translates a GLFW standard cursor to a theme cursor name
|
// Translates a GLFW standard cursor to a theme cursor name
|
||||||
|
Loading…
Reference in New Issue
Block a user