diff --git a/README.md b/README.md index 447976c4..fe365cb0 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ The following dependencies are needed by the examples and test programs: cause an uncaught `BadWindow` error - [X11] Bugfix: No check was made for the presence GLX 1.3 when `GLX_SGIX_fbconfig` was unavailable + - [X11] Bugfix: The message type of ICCCM protocol events was not checked ## Contact diff --git a/src/x11_init.c b/src/x11_init.c index 18d92fdd..4dc46d48 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -430,6 +430,9 @@ static GLboolean initExtensions(void) Bool supported; // Find or create window manager atoms + _glfw.x11.WM_PROTOCOLS = XInternAtom(_glfw.x11.display, + "WM_PROTOCOLS", + False); _glfw.x11.WM_STATE = XInternAtom(_glfw.x11.display, "WM_STATE", False); _glfw.x11.WM_DELETE_WINDOW = XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", diff --git a/src/x11_platform.h b/src/x11_platform.h index 25a54612..f0dc6081 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -107,6 +107,7 @@ typedef struct _GLFWlibraryX11 XContext context; // Window manager atoms + Atom WM_PROTOCOLS; Atom WM_STATE; Atom WM_DELETE_WINDOW; Atom NET_WM_NAME; diff --git a/src/x11_window.c b/src/x11_window.c index 9042cc6f..eeb82474 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -739,25 +739,32 @@ static void processEvent(XEvent *event) { // Custom client message, probably from the window manager - if ((Atom) event->xclient.data.l[0] == _glfw.x11.WM_DELETE_WINDOW) - { - // The window manager was asked to close the window, for example by - // the user pressing a 'close' window decoration button + if (event->xclient.message_type == None) + break; - _glfwInputWindowCloseRequest(window); - } - else if (_glfw.x11.NET_WM_PING && - (Atom) event->xclient.data.l[0] == _glfw.x11.NET_WM_PING) + if (event->xclient.message_type == _glfw.x11.WM_PROTOCOLS) { - // The window manager is pinging the application to ensure it's - // still responding to events + if (_glfw.x11.WM_DELETE_WINDOW && + (Atom) event->xclient.data.l[0] == _glfw.x11.WM_DELETE_WINDOW) + { + // The window manager was asked to close the window, for example by + // the user pressing a 'close' window decoration button - event->xclient.window = _glfw.x11.root; - XSendEvent(_glfw.x11.display, - event->xclient.window, - False, - SubstructureNotifyMask | SubstructureRedirectMask, - event); + _glfwInputWindowCloseRequest(window); + } + else if (_glfw.x11.NET_WM_PING && + (Atom) event->xclient.data.l[0] == _glfw.x11.NET_WM_PING) + { + // The window manager is pinging the application to ensure it's + // still responding to events + + event->xclient.window = _glfw.x11.root; + XSendEvent(_glfw.x11.display, + event->xclient.window, + False, + SubstructureNotifyMask | SubstructureRedirectMask, + event); + } } else if (event->xclient.message_type == _glfw.x11.XdndEnter) {