Update attention request

For Cocoa, the attention request is made via the ```NSApp```. The
functions for each platform were moved, and the documentation improved.
This commit is contained in:
Felipe Ferreira da Silva 2017-04-08 19:55:16 -03:00
parent 26628af183
commit a29f9f5ea4
5 changed files with 40 additions and 37 deletions

View File

@ -2698,23 +2698,6 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
*/ */
GLFWAPI void glfwShowWindow(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. /*! @brief Hides the specified window.
* *
* This function hides the specified window if it was previously visible. If * 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); 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. /*! @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 * This function returns the handle of the monitor that the specified window is

View File

@ -1272,16 +1272,16 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
[window->ns.object orderFront:nil]; [window->ns.object orderFront:nil];
} }
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{
[window->ns.object requestUserAttention:NSInformationalRequest];
}
void _glfwPlatformHideWindow(_GLFWwindow* window) void _glfwPlatformHideWindow(_GLFWwindow* window)
{ {
[window->ns.object orderOut:nil]; [window->ns.object orderOut:nil];
} }
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{
[NSApp requestUserAttention:NSInformationalRequest];
}
void _glfwPlatformFocusWindow(_GLFWwindow* window) void _glfwPlatformFocusWindow(_GLFWwindow* window)
{ {
// Make us the active application // Make us the active application

View File

@ -1311,16 +1311,16 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
ShowWindow(window->win32.handle, SW_SHOW); ShowWindow(window->win32.handle, SW_SHOW);
} }
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{
FlashWindow(window->win32.handle, TRUE);
}
void _glfwPlatformHideWindow(_GLFWwindow* window) void _glfwPlatformHideWindow(_GLFWwindow* window)
{ {
ShowWindow(window->win32.handle, SW_HIDE); ShowWindow(window->win32.handle, SW_HIDE);
} }
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{
FlashWindow(window->win32.handle, TRUE);
}
void _glfwPlatformFocusWindow(_GLFWwindow* window) void _glfwPlatformFocusWindow(_GLFWwindow* window)
{ {
BringWindowToTop(window->win32.handle); BringWindowToTop(window->win32.handle);

View File

@ -589,10 +589,6 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
} }
} }
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{
}
void _glfwPlatformHideWindow(_GLFWwindow* window) void _glfwPlatformHideWindow(_GLFWwindow* window)
{ {
if (!window->monitor) if (!window->monitor)
@ -603,6 +599,10 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
} }
} }
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{
}
void _glfwPlatformFocusWindow(_GLFWwindow* window) void _glfwPlatformFocusWindow(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,

View File

@ -2072,6 +2072,12 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
waitForVisibilityNotify(window); waitForVisibilityNotify(window);
} }
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
XUnmapWindow(_glfw.x11.display, window->x11.handle);
XFlush(_glfw.x11.display);
}
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{ {
XEvent xev; XEvent xev;
@ -2087,12 +2093,6 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
XSendEvent(_glfw.x11.display, DefaultRootWindow(_glfw.x11.display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); 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) void _glfwPlatformFocusWindow(_GLFWwindow* window)
{ {
if (_glfw.x11.NET_ACTIVE_WINDOW) if (_glfw.x11.NET_ACTIVE_WINDOW)