Use stored X11 atoms for attention request

The function to request window attention was using ```XInternAtom```.
Now, the atoms are stored and retrieved from the ```_GLFWlibraryX11```
structure.
This commit is contained in:
Felipe Ferreira da Silva 2017-04-07 04:03:32 -03:00
parent 82afc48fab
commit 26628af183
3 changed files with 5 additions and 5 deletions

View File

@ -438,6 +438,8 @@ static void detectEWMH(void)
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ = _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION");
_glfw.x11.NET_WM_FULLSCREEN_MONITORS = _glfw.x11.NET_WM_FULLSCREEN_MONITORS =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
_glfw.x11.NET_WM_WINDOW_TYPE = _glfw.x11.NET_WM_WINDOW_TYPE =

View File

@ -194,6 +194,7 @@ typedef struct _GLFWlibraryX11
Atom NET_WM_STATE_FULLSCREEN; Atom NET_WM_STATE_FULLSCREEN;
Atom NET_WM_STATE_MAXIMIZED_VERT; Atom NET_WM_STATE_MAXIMIZED_VERT;
Atom NET_WM_STATE_MAXIMIZED_HORZ; Atom NET_WM_STATE_MAXIMIZED_HORZ;
Atom NET_WM_STATE_DEMANDS_ATTENTION;
Atom NET_WM_BYPASS_COMPOSITOR; Atom NET_WM_BYPASS_COMPOSITOR;
Atom NET_WM_FULLSCREEN_MONITORS; Atom NET_WM_FULLSCREEN_MONITORS;
Atom NET_ACTIVE_WINDOW; Atom NET_ACTIVE_WINDOW;

View File

@ -2076,16 +2076,13 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{ {
XEvent xev; 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)); memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage; xev.type = ClientMessage;
xev.xclient.window = window->x11.handle; xev.xclient.window = window->x11.handle;
xev.xclient.message_type = wm_state; xev.xclient.message_type = _glfw.x11.NET_WM_STATE;
xev.xclient.format = 32; xev.xclient.format = 32;
xev.xclient.data.l[0] = _NET_WM_STATE_ADD; xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
xev.xclient.data.l[1] = wm_attention; xev.xclient.data.l[1] = _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION;
XSendEvent(_glfw.x11.display, DefaultRootWindow(_glfw.x11.display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); XSendEvent(_glfw.x11.display, DefaultRootWindow(_glfw.x11.display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
} }