mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Wayland: Fix potential incomplete display flushing
The flushing of a Wayland display may need to be done in several steps, signalled by it failing with EAGAIN.
This commit is contained in:
parent
84b0923fe6
commit
3c2913dcb9
@ -716,6 +716,25 @@ static void incrementCursorImage(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLFWbool flushDisplay(void)
|
||||||
|
{
|
||||||
|
while (wl_display_flush(_glfw.wl.display) == -1)
|
||||||
|
{
|
||||||
|
if (errno != EAGAIN)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
struct pollfd fd = { wl_display_get_fd(_glfw.wl.display), POLLOUT };
|
||||||
|
|
||||||
|
while (poll(&fd, 1, -1) == -1)
|
||||||
|
{
|
||||||
|
if (errno != EINTR && errno != EAGAIN)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void handleEvents(int timeout)
|
static void handleEvents(int timeout)
|
||||||
{
|
{
|
||||||
struct pollfd fds[] =
|
struct pollfd fds[] =
|
||||||
@ -730,7 +749,7 @@ static void handleEvents(int timeout)
|
|||||||
|
|
||||||
// If an error other than EAGAIN happens, we have likely been disconnected
|
// If an error other than EAGAIN happens, we have likely been disconnected
|
||||||
// from the Wayland session; try to handle that the best we can.
|
// from the Wayland session; try to handle that the best we can.
|
||||||
if (wl_display_flush(_glfw.wl.display) < 0 && errno != EAGAIN)
|
if (!flushDisplay())
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = _glfw.windowListHead;
|
_GLFWwindow* window = _glfw.windowListHead;
|
||||||
while (window)
|
while (window)
|
||||||
|
Loading…
Reference in New Issue
Block a user