From a29f9f5ea4f0cb33bbe583fd654fabe407c9605b Mon Sep 17 00:00:00 2001 From: Felipe Ferreira da Silva Date: Sat, 8 Apr 2017 19:55:16 -0300 Subject: [PATCH] Update attention request For Cocoa, the attention request is made via the ```NSApp```. The functions for each platform were moved, and the documentation improved. --- include/GLFW/glfw3.h | 37 ++++++++++++++++++++----------------- src/cocoa_window.m | 10 +++++----- src/win32_window.c | 10 +++++----- src/wl_window.c | 8 ++++---- src/x11_window.c | 12 ++++++------ 5 files changed, 40 insertions(+), 37 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 4c0483530..434b24ad6 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2698,23 +2698,6 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window); */ GLFWAPI void glfwShowWindow(GLFWwindow* window); -/*! @brief Request attention to the specified window. - * - * This function makes the specified window to request attention. - * - * @param[in] window The window to request attention. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @since Added in version 3.3. - * - * @ingroup window - */ -GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window); - /*! @brief Hides the specified window. * * This function hides the specified window if it was previously visible. If @@ -2768,6 +2751,26 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window); */ GLFWAPI void glfwFocusWindow(GLFWwindow* window); +/*! @brief Request attention to the specified window. + * + * This function makes the specified window to request attention. + * + * @param[in] window The window to request attention. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_ERROR. + * + * @remark @macos The attention request will be made for the application and + * not the window passed in the argument. + * + * @thread_safety This function must only be called from the main thread. + * + * @since Added in version 3.3. + * + * @ingroup window + */ +GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window); + /*! @brief Returns the monitor that the window uses for full screen mode. * * This function returns the handle of the monitor that the specified window is diff --git a/src/cocoa_window.m b/src/cocoa_window.m index f2ee319d8..d2b207bb9 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1272,16 +1272,16 @@ void _glfwPlatformShowWindow(_GLFWwindow* window) [window->ns.object orderFront:nil]; } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) -{ - [window->ns.object requestUserAttention:NSInformationalRequest]; -} - void _glfwPlatformHideWindow(_GLFWwindow* window) { [window->ns.object orderOut:nil]; } +void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +{ + [NSApp requestUserAttention:NSInformationalRequest]; +} + void _glfwPlatformFocusWindow(_GLFWwindow* window) { // Make us the active application diff --git a/src/win32_window.c b/src/win32_window.c index f9eca060d..6d691e196 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1311,16 +1311,16 @@ void _glfwPlatformShowWindow(_GLFWwindow* window) ShowWindow(window->win32.handle, SW_SHOW); } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) -{ - FlashWindow(window->win32.handle, TRUE); -} - void _glfwPlatformHideWindow(_GLFWwindow* window) { ShowWindow(window->win32.handle, SW_HIDE); } +void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +{ + FlashWindow(window->win32.handle, TRUE); +} + void _glfwPlatformFocusWindow(_GLFWwindow* window) { BringWindowToTop(window->win32.handle); diff --git a/src/wl_window.c b/src/wl_window.c index 6a13717da..9dace92a7 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -589,10 +589,6 @@ void _glfwPlatformShowWindow(_GLFWwindow* window) } } -void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) -{ -} - void _glfwPlatformHideWindow(_GLFWwindow* window) { if (!window->monitor) @@ -603,6 +599,10 @@ void _glfwPlatformHideWindow(_GLFWwindow* window) } } +void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +{ +} + void _glfwPlatformFocusWindow(_GLFWwindow* window) { _glfwInputError(GLFW_PLATFORM_ERROR, diff --git a/src/x11_window.c b/src/x11_window.c index 40a76dfd3..db5ac83f0 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2072,6 +2072,12 @@ void _glfwPlatformShowWindow(_GLFWwindow* window) waitForVisibilityNotify(window); } +void _glfwPlatformHideWindow(_GLFWwindow* window) +{ + XUnmapWindow(_glfw.x11.display, window->x11.handle); + XFlush(_glfw.x11.display); +} + void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) { XEvent xev; @@ -2087,12 +2093,6 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) XSendEvent(_glfw.x11.display, DefaultRootWindow(_glfw.x11.display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); } -void _glfwPlatformHideWindow(_GLFWwindow* window) -{ - XUnmapWindow(_glfw.x11.display, window->x11.handle); - XFlush(_glfw.x11.display); -} - void _glfwPlatformFocusWindow(_GLFWwindow* window) { if (_glfw.x11.NET_ACTIVE_WINDOW)