diff --git a/src/x11_init.c b/src/x11_init.c index 00e30e8b..666b42cc 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -630,6 +630,20 @@ static Cursor createHiddenCursor(void) return _glfwCreateCursorX11(&image, 0, 0); } +// Create a helper window for IPC +// +static Window createHelperWindow(void) +{ + XSetWindowAttributes wa; + wa.event_mask = PropertyChangeMask; + + return XCreateWindow(_glfw.x11.display, _glfw.x11.root, + 0, 0, 1, 1, 0, 0, + InputOnly, + DefaultVisual(_glfw.x11.display, _glfw.x11.screen), + CWEventMask, &wa); +} + // X error handler // static int errorHandler(Display *display, XErrorEvent* event) @@ -741,12 +755,12 @@ int _glfwPlatformInit(void) _glfw.x11.screen = DefaultScreen(_glfw.x11.display); _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen); _glfw.x11.context = XUniqueContext(); + _glfw.x11.helperWindowHandle = createHelperWindow(); + _glfw.x11.hiddenCursorHandle = createHiddenCursor(); if (!initExtensions()) return GLFW_FALSE; - _glfw.x11.hiddenCursorHandle = createHiddenCursor(); - if (XSupportsLocale()) { XSetLocaleModifiers(""); @@ -781,6 +795,12 @@ void _glfwPlatformTerminate(void) _glfw.x11.x11xcb.handle = NULL; } + if (_glfw.x11.helperWindowHandle) + { + XDestroyWindow(_glfw.x11.display, _glfw.x11.helperWindowHandle); + _glfw.x11.helperWindowHandle = None; + } + if (_glfw.x11.hiddenCursorHandle) { XFreeCursor(_glfw.x11.display, _glfw.x11.hiddenCursorHandle); diff --git a/src/x11_platform.h b/src/x11_platform.h index 65f34a48..c86944ba 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -136,6 +136,8 @@ typedef struct _GLFWlibraryX11 int screen; Window root; + // Helper window for IPC + Window helperWindowHandle; // Invisible cursor for hidden cursor mode Cursor hiddenCursorHandle; // Context for mapping window XIDs to _GLFWwindow pointers