diff --git a/README.md b/README.md index ccd0f268..5653bb82 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ GLFW bundles a number of dependencies in the `deps/` directory. full screen windows - [X11] Bugfix: `GLFW_ARROW_CURSOR` selected the wrong cursor image - [X11] Bugfix: The `GLFW_DECORATED` hint was not ignored for full screen + - [X11] Bugfix: `glfwWaitEvents` did not handle `EINTR` for `select` - [WGL] Made all WGL functions dynamically loaded - [WGL] Removed `GLFW_USE_DWM_SWAP_INTERVAL` compile-time option - [WGL] Bugfix: Swap interval was ignored when DWM was enabled @@ -163,6 +164,7 @@ skills. - Robin Leffmann - Glenn Lewis - Shane Liesegang + - Eyal Lotem - Дмитри Малышев - Martins Mozeiko - Tristam MacDonald diff --git a/src/x11_window.c b/src/x11_window.c index 62e8a200..eabe2066 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -36,6 +36,7 @@ #include #include #include +#include // Action for EWMH client messages #define _NET_WM_STATE_REMOVE 0 @@ -63,15 +64,23 @@ typedef struct void selectDisplayConnection(struct timeval* timeout) { fd_set fds; + int result; const int fd = ConnectionNumber(_glfw.x11.display); FD_ZERO(&fds); FD_SET(fd, &fds); - // select(1) is used instead of an X function like XNextEvent, as the - // wait inside those are guarded by the mutex protecting the display - // struct, locking out other threads from using X (including GLX) - select(fd + 1, &fds, NULL, NULL, timeout); + // NOTE: We use select instead of an X function like XNextEvent, as the + // wait inside those are guarded by the mutex protecting the display + // struct, locking out other threads from using X (including GLX) + // NOTE: Only retry on EINTR if there is no timeout, as select is not + // required to update it for the time elapsed + // TODO: Update timeout value manually + do + { + result = select(fd + 1, &fds, NULL, NULL, timeout); + } + while (result == -1 && errno == EINTR && timeout == NULL); } // Returns whether the window is iconified