Hi everyone!
I’m trying to use SDL to make UIs of audio plugins, because I want to use SDL’s cross-platform support for creating OpenGL context and event handling. The SDL-created window is attached to an existing window (provided by “host” program) using platform-specific APIs, i.e. XReparentWindow in Linux.
Currently I’m facing the problem that when it is going to destruct the UI, SDL_DestroyWindow is blocked by XIfEvent infinitely. I browsed the stack that blocks, the source code inside SDL_x11window.c is:
if (X11_IsWindowMapped(_this, window)) {
X11_XWithdrawWindow(display, data->xwindow, screen);
// Blocking wait for "UnmapNotify" event
if (!(window->flags & SDL_WINDOW_EXTERNAL) && X11_IsDisplayOk(display)) {
X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); // this is where it stucks
}
X11_XFlush(display);
}
I’m not familiar with X11 programming, and I don’t know neither why it needs to wait for a UnmapNotify event, nor why it is blocked on the specific circumstances. So I ask here for help.
And here are some points:
- I have ensured that all SDL and X11 code are called in one thread.
- I use platform-specific
XReparentWindowinstead ofSDL_SetWindowParent, because wrapping the existing parent window withSDL_CreateWindowWithPropertieswould disturb the behavior of the parent window.
Thanks for a lot!