From 601cf0122221969ee6ae479f98e65b244900a99a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 24 Apr 2020 19:24:11 +0530 Subject: [PATCH] Fix #2581 --- glfw/x11_window.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 3a1a8902b..997f235fe 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -1408,12 +1408,16 @@ static void processEvent(XEvent *event) if (!event->xany.send_event && window->x11.parent != _glfw.x11.root) { Window dummy; + _glfwGrabErrorHandlerX11(); XTranslateCoordinates(_glfw.x11.display, window->x11.parent, _glfw.x11.root, xpos, ypos, &xpos, &ypos, &dummy); + _glfwReleaseErrorHandlerX11(); + if (_glfw.x11.errorCode != Success) + _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to trnslate configurenotiy co-ords for reparented window"); } if (xpos != window->x11.xpos || ypos != window->x11.ypos) @@ -1550,17 +1554,21 @@ static void processEvent(XEvent *event) const int xabs = (event->xclient.data.l[2] >> 16) & 0xffff; const int yabs = (event->xclient.data.l[2]) & 0xffff; Window dummy; - int xpos, ypos; + int xpos = 0, ypos = 0; if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION) return; + _glfwGrabErrorHandlerX11(); XTranslateCoordinates(_glfw.x11.display, _glfw.x11.root, window->x11.handle, xabs, yabs, &xpos, &ypos, &dummy); + _glfwReleaseErrorHandlerX11(); + if (_glfw.x11.errorCode != Success) + _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to get DND event position"); _glfwInputCursorPos(window, xpos, ypos); @@ -1988,10 +1996,14 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window, void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) { Window dummy; - int x, y; + int x = 0, y = 0; + _glfwGrabErrorHandlerX11(); XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root, 0, 0, &x, &y, &dummy); + _glfwReleaseErrorHandlerX11(); + if (_glfw.x11.errorCode != Success) + _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to get window position"); if (xpos) *xpos = x;