x11: Set EGL surface for foreign X11 windows.
Cherry-picked by hand from SDL2: 780ec8fac062deaee5a018823e33f33c727738bc Also cleaned up the XDestroyIC cleanup code to match the setup code. Fixes #11996.
This commit is contained in:
@@ -766,6 +766,18 @@ void X11_CreateInputContext(SDL_WindowData *data)
|
|||||||
#endif // X_HAVE_UTF8_STRING
|
#endif // X_HAVE_UTF8_STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void X11_DestroyInputContext(SDL_WindowData *data)
|
||||||
|
{
|
||||||
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
|
X11_XDestroyIC(data->ic);
|
||||||
|
SDL_free(data->preedit_text);
|
||||||
|
SDL_free(data->preedit_feedback);
|
||||||
|
data->preedit_text = NULL;
|
||||||
|
data->preedit_feedback = NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void X11_ResetXIM(SDL_VideoDevice *_this, SDL_Window *window)
|
static void X11_ResetXIM(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
{
|
{
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ extern bool X11_InitKeyboard(SDL_VideoDevice *_this);
|
|||||||
extern void X11_UpdateKeymap(SDL_VideoDevice *_this, bool send_event);
|
extern void X11_UpdateKeymap(SDL_VideoDevice *_this, bool send_event);
|
||||||
extern void X11_QuitKeyboard(SDL_VideoDevice *_this);
|
extern void X11_QuitKeyboard(SDL_VideoDevice *_this);
|
||||||
extern void X11_CreateInputContext(SDL_WindowData *data);
|
extern void X11_CreateInputContext(SDL_WindowData *data);
|
||||||
|
extern void X11_DestroyInputContext(SDL_WindowData *data);
|
||||||
extern void X11_ClearComposition(SDL_WindowData *data);
|
extern void X11_ClearComposition(SDL_WindowData *data);
|
||||||
extern bool X11_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
extern bool X11_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||||
extern bool X11_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window);
|
extern bool X11_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window);
|
||||||
|
|||||||
@@ -398,8 +398,7 @@ static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w
|
|||||||
} else {
|
} else {
|
||||||
SDL_WindowData ** new_windowlist = (SDL_WindowData **)SDL_realloc(windowlist, (numwindows + 1) * sizeof(*windowlist));
|
SDL_WindowData ** new_windowlist = (SDL_WindowData **)SDL_realloc(windowlist, (numwindows + 1) * sizeof(*windowlist));
|
||||||
if (!new_windowlist) {
|
if (!new_windowlist) {
|
||||||
SDL_free(data);
|
goto error_cleanup;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
windowlist = new_windowlist;
|
windowlist = new_windowlist;
|
||||||
windowlist[numwindows] = data;
|
windowlist[numwindows] = data;
|
||||||
@@ -458,9 +457,42 @@ static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w
|
|||||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_X11_SCREEN_NUMBER, screen);
|
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_X11_SCREEN_NUMBER, screen);
|
||||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, data->xwindow);
|
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, data->xwindow);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) || defined(SDL_VIDEO_OPENGL_EGL)
|
||||||
|
if ((window->flags & SDL_WINDOW_OPENGL) &&
|
||||||
|
((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) ||
|
||||||
|
SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false))
|
||||||
|
#ifdef SDL_VIDEO_OPENGL_GLX
|
||||||
|
&& (!_this->gl_data || X11_GL_UseEGL(_this))
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||||
|
if (!_this->egl_data) {
|
||||||
|
goto error_cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the GLES window surface
|
||||||
|
data->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)w);
|
||||||
|
|
||||||
|
if (data->egl_surface == EGL_NO_SURFACE) {
|
||||||
|
SDL_SetError("Could not create GLES window surface");
|
||||||
|
goto error_cleanup;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SDL_SetError("Could not create GLES window surface (EGL support not configured)");
|
||||||
|
goto error_cleanup;
|
||||||
|
#endif // SDL_VIDEO_OPENGL_EGL
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// All done!
|
// All done!
|
||||||
window->internal = data;
|
window->internal = data;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
error_cleanup:
|
||||||
|
X11_DestroyInputContext(data);
|
||||||
|
SDL_free(data);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetupWindowInput(SDL_VideoDevice *_this, SDL_Window *window)
|
static void SetupWindowInput(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
@@ -858,31 +890,6 @@ bool X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properties
|
|||||||
}
|
}
|
||||||
#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */
|
#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */
|
||||||
|
|
||||||
#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) || defined(SDL_VIDEO_OPENGL_EGL)
|
|
||||||
if ((window->flags & SDL_WINDOW_OPENGL) &&
|
|
||||||
((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) ||
|
|
||||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false))
|
|
||||||
#ifdef SDL_VIDEO_OPENGL_GLX
|
|
||||||
&& (!_this->gl_data || X11_GL_UseEGL(_this))
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
|
||||||
if (!_this->egl_data) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the GLES window surface
|
|
||||||
windowdata->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)w);
|
|
||||||
|
|
||||||
if (windowdata->egl_surface == EGL_NO_SURFACE) {
|
|
||||||
return SDL_SetError("Could not create GLES window surface");
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return SDL_SetError("Could not create GLES window surface (EGL support not configured)");
|
|
||||||
#endif // SDL_VIDEO_OPENGL_EGL
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE
|
#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||||
// Tooltips do not receive input
|
// Tooltips do not receive input
|
||||||
if (window->flags & SDL_WINDOW_TOOLTIP) {
|
if (window->flags & SDL_WINDOW_TOOLTIP) {
|
||||||
@@ -2180,13 +2187,8 @@ void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
|
||||||
if (data->ic) {
|
X11_DestroyInputContext(data);
|
||||||
X11_XDestroyIC(data->ic);
|
|
||||||
SDL_free(data->preedit_text);
|
|
||||||
SDL_free(data->preedit_feedback);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_X11_XSYNC
|
#ifdef SDL_VIDEO_DRIVER_X11_XSYNC
|
||||||
X11_TermResizeSync(window);
|
X11_TermResizeSync(window);
|
||||||
|
|||||||
Reference in New Issue
Block a user