From 55b1a16f9061520724fc507a9ef243f641d1ee02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 15 Jan 2019 19:28:17 +0100 Subject: [PATCH] Remove window requirement for all event functions This lets an application wait for non-window events without needing to create a window. Fixes #1317. --- README.md | 2 ++ docs/input.dox | 3 +-- include/GLFW/glfw3.h | 12 ------------ src/window.c | 8 -------- 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 80059c95..d50e5ddb 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,8 @@ information on what to include when reporting a bug. - Removed `GLFW_USE_RETINA` compile-time option - Removed `GLFW_USE_CHDIR` compile-time option - Removed `GLFW_USE_MENUBAR` compile-time option +- Removed requirement of at least one window for `glfwWaitEvents` and + `glfwPostEmptyEvent` (#1317) - Bugfix: Calling `glfwMaximizeWindow` on a full screen window was not ignored - Bugfix: `GLFW_INCLUDE_VULKAN` could not be combined with the corresponding OpenGL and OpenGL ES header macros diff --git a/docs/input.dox b/docs/input.dox index 84978bd0..73c7ef70 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -57,8 +57,7 @@ glfwWaitEvents(); It puts the thread to sleep until at least one event has been received and then processes all received events. This saves a great deal of CPU cycles and is -useful for, for example, editing tools. There must be at least one GLFW window -for this function to sleep. +useful for, for example, editing tools. If you want to wait for events but have UI elements or other tasks that need periodic updates, @ref glfwWaitEventsTimeout lets you specify a timeout. diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 099cd8e6..8606edc1 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3718,10 +3718,6 @@ GLFWAPI void glfwPollEvents(void); * GLFW will pass those events on to the application callbacks before * returning. * - * If no windows exist, this function returns immediately. For synchronization - * of threads in applications that do not create windows, use your threading - * library of choice. - * * Event processing is not required for joystick input to work. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref @@ -3769,10 +3765,6 @@ GLFWAPI void glfwWaitEvents(void); * GLFW will pass those events on to the application callbacks before * returning. * - * If no windows exist, this function returns immediately. For synchronization - * of threads in applications that do not create windows, use your threading - * library of choice. - * * Event processing is not required for joystick input to work. * * @param[in] timeout The maximum amount of time, in seconds, to wait. @@ -3799,10 +3791,6 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout); * This function posts an empty event from the current thread to the event * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return. * - * If no windows exist, this function returns immediately. For synchronization - * of threads in applications that do not create windows, use your threading - * library of choice. - * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * diff --git a/src/window.c b/src/window.c index 4e365cb4..2c98d4cb 100644 --- a/src/window.c +++ b/src/window.c @@ -1078,10 +1078,6 @@ GLFWAPI void glfwPollEvents(void) GLFWAPI void glfwWaitEvents(void) { _GLFW_REQUIRE_INIT(); - - if (!_glfw.windowListHead) - return; - _glfwPlatformWaitEvents(); } @@ -1104,10 +1100,6 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout) GLFWAPI void glfwPostEmptyEvent(void) { _GLFW_REQUIRE_INIT(); - - if (!_glfw.windowListHead) - return; - _glfwPlatformPostEmptyEvent(); }