Initial implementation of window attention for X11

This commit is contained in:
Felipe Ferreira da Silva 2017-03-21 10:02:57 -03:00
parent 1982543cd2
commit 301a84c4f5
4 changed files with 31 additions and 0 deletions

View File

@ -2698,6 +2698,8 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
*/
GLFWAPI void glfwShowWindow(GLFWwindow* window);
GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
/*! @brief Hides the specified window.
*
* This function hides the specified window if it was previously visible. If

View File

@ -629,6 +629,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window);
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
void _glfwPlatformShowWindow(_GLFWwindow* window);
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
void _glfwPlatformHideWindow(_GLFWwindow* window);
void _glfwPlatformFocusWindow(_GLFWwindow* window);
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);

View File

@ -675,6 +675,16 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle)
_glfwPlatformFocusWindow(window);
}
GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT();
_glfwPlatformRequestWindowAttention(window);
}
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;

View File

@ -2072,6 +2072,24 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
waitForVisibilityNotify(window);
}
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{
XEvent xev;
Atom wm_state = XInternAtom(_glfw.x11.display, "_NET_WM_STATE", False);
Atom wm_attention = XInternAtom(_glfw.x11.display, "_NET_WM_STATE_DEMANDS_ATTENTION", False);
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
xev.xclient.window = window->x11.handle;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = 1; /* _NET_WM_STATE_ADD */
xev.xclient.data.l[1] = wm_attention;
XSendEvent(_glfw.x11.display, DefaultRootWindow(_glfw.x11.display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
XUnmapWindow(_glfw.x11.display, window->x11.handle);