mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
Initial implementation of window attention for X11
This commit is contained in:
parent
1982543cd2
commit
301a84c4f5
@ -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
|
||||
|
@ -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);
|
||||
|
10
src/window.c
10
src/window.c
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user