X11: Fix race in window hovered query

The window decoration window can go away between calls to XQueryPointer,
for example if the GLFW_DECORATED window attribute was just cleared.
This commit is contained in:
Camilla Löwy 2020-07-08 15:53:01 +02:00
parent 4ae93e0547
commit ceb20c7f97

View File

@ -2576,11 +2576,19 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window)
int rootX, rootY, childX, childY;
unsigned int mask;
if (!XQueryPointer(_glfw.x11.display, w,
&root, &w, &rootX, &rootY, &childX, &childY, &mask))
{
_glfwGrabErrorHandlerX11();
const Bool result = XQueryPointer(_glfw.x11.display, w,
&root, &w, &rootX, &rootY,
&childX, &childY, &mask);
_glfwReleaseErrorHandlerX11();
if (_glfw.x11.errorCode == BadWindow)
w = _glfw.x11.root;
if (!result)
return GLFW_FALSE;
}
if (w == window->x11.handle)
return GLFW_TRUE;