mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Wayland: Clean up event pump
Adapt style to the rest of the project.
(cherry picked from commit 79e7e65c9d
)
This commit is contained in:
parent
17c5c53910
commit
5e8186af0a
@ -824,22 +824,19 @@ static void incrementCursorImage(_GLFWwindow* window)
|
|||||||
|
|
||||||
static void handleEvents(int timeout)
|
static void handleEvents(int timeout)
|
||||||
{
|
{
|
||||||
struct wl_display* display = _glfw.wl.display;
|
struct pollfd fds[] =
|
||||||
struct pollfd fds[] = {
|
{
|
||||||
{ wl_display_get_fd(display), POLLIN },
|
{ wl_display_get_fd(_glfw.wl.display), POLLIN },
|
||||||
{ _glfw.wl.timerfd, POLLIN },
|
{ _glfw.wl.timerfd, POLLIN },
|
||||||
{ _glfw.wl.cursorTimerfd, POLLIN },
|
{ _glfw.wl.cursorTimerfd, POLLIN },
|
||||||
};
|
};
|
||||||
ssize_t read_ret;
|
|
||||||
uint64_t repeats, i;
|
|
||||||
|
|
||||||
while (wl_display_prepare_read(display) != 0)
|
while (wl_display_prepare_read(_glfw.wl.display) != 0)
|
||||||
wl_display_dispatch_pending(display);
|
wl_display_dispatch_pending(_glfw.wl.display);
|
||||||
|
|
||||||
// If an error different from EAGAIN happens, we have likely been
|
// If an error other than EAGAIN happens, we have likely been disconnected
|
||||||
// disconnected from the Wayland session, try to handle that the best we
|
// from the Wayland session; try to handle that the best we can.
|
||||||
// can.
|
if (wl_display_flush(_glfw.wl.display) < 0 && errno != EAGAIN)
|
||||||
if (wl_display_flush(display) < 0 && errno != EAGAIN)
|
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = _glfw.windowListHead;
|
_GLFWwindow* window = _glfw.windowListHead;
|
||||||
while (window)
|
while (window)
|
||||||
@ -847,7 +844,8 @@ static void handleEvents(int timeout)
|
|||||||
_glfwInputWindowCloseRequest(window);
|
_glfwInputWindowCloseRequest(window);
|
||||||
window = window->next;
|
window = window->next;
|
||||||
}
|
}
|
||||||
wl_display_cancel_read(display);
|
|
||||||
|
wl_display_cancel_read(_glfw.wl.display);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -855,41 +853,42 @@ static void handleEvents(int timeout)
|
|||||||
{
|
{
|
||||||
if (fds[0].revents & POLLIN)
|
if (fds[0].revents & POLLIN)
|
||||||
{
|
{
|
||||||
wl_display_read_events(display);
|
wl_display_read_events(_glfw.wl.display);
|
||||||
wl_display_dispatch_pending(display);
|
wl_display_dispatch_pending(_glfw.wl.display);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
wl_display_cancel_read(_glfw.wl.display);
|
||||||
wl_display_cancel_read(display);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fds[1].revents & POLLIN)
|
if (fds[1].revents & POLLIN)
|
||||||
{
|
{
|
||||||
read_ret = read(_glfw.wl.timerfd, &repeats, sizeof(repeats));
|
uint64_t repeats;
|
||||||
if (read_ret == 8 && _glfw.wl.keyboardFocus)
|
|
||||||
|
if (read(_glfw.wl.timerfd, &repeats, sizeof(repeats)) == 8)
|
||||||
{
|
{
|
||||||
for (i = 0; i < repeats; ++i)
|
if (_glfw.wl.keyboardFocus)
|
||||||
{
|
{
|
||||||
_glfwInputKey(_glfw.wl.keyboardFocus,
|
for (uint64_t i = 0; i < repeats; i++)
|
||||||
_glfw.wl.keyboardLastKey,
|
{
|
||||||
_glfw.wl.keyboardLastScancode,
|
_glfwInputKey(_glfw.wl.keyboardFocus,
|
||||||
GLFW_REPEAT,
|
_glfw.wl.keyboardLastKey,
|
||||||
_glfw.wl.xkb.modifiers);
|
_glfw.wl.keyboardLastScancode,
|
||||||
|
GLFW_REPEAT,
|
||||||
|
_glfw.wl.xkb.modifiers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fds[2].revents & POLLIN)
|
if (fds[2].revents & POLLIN)
|
||||||
{
|
{
|
||||||
read_ret = read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats));
|
uint64_t repeats;
|
||||||
if (read_ret == 8)
|
|
||||||
|
if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8)
|
||||||
incrementCursorImage(_glfw.wl.pointerFocus);
|
incrementCursorImage(_glfw.wl.pointerFocus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
wl_display_cancel_read(_glfw.wl.display);
|
||||||
wl_display_cancel_read(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