X11: Improve window handle race condition

The non-root parent window owned by the WM could be destroyed before we
process the ConfigureNotify event using the cached parent handle.

Bug was found by unmapping a decorated window.

This like all uses of the Xlib error handler is not thread safe and
there is nothing we can do about that short of moving to XCB.

Fixes #1633.
This commit is contained in:
Camilla Löwy
2020-03-19 23:28:21 +01:00
parent 2c8e0512dd
commit e65de2941c
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -1547,6 +1547,8 @@ static void processEvent(XEvent *event)
// the position into root (screen) coordinates
if (!event->xany.send_event && window->x11.parent != _glfw.x11.root)
{
_glfwGrabErrorHandlerX11();
Window dummy;
XTranslateCoordinates(_glfw.x11.display,
window->x11.parent,
@@ -1554,6 +1556,10 @@ static void processEvent(XEvent *event)
xpos, ypos,
&xpos, &ypos,
&dummy);
_glfwReleaseErrorHandlerX11();
if (_glfw.x11.errorCode == BadWindow)
return;
}
if (xpos != window->x11.xpos || ypos != window->x11.ypos)