summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--video/out/gl_common.c4
-rw-r--r--video/out/gl_common.h1
-rw-r--r--video/out/gl_x11.c53
3 files changed, 34 insertions, 24 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c
index 31670ce75a..518f962d2c 100644
--- a/video/out/gl_common.c
+++ b/video/out/gl_common.c
@@ -528,6 +528,8 @@ struct backend {
const struct mpgl_driver *driver;
};
+extern const struct mpgl_driver mpgl_driver_x11;
+
static const struct backend backends[] = {
#if HAVE_RPI_GLES
{"rpi", mpgl_set_backend_rpi},
@@ -544,7 +546,7 @@ static const struct backend backends[] = {
{"wayland", mpgl_set_backend_wayland},
#endif
#if HAVE_GL_X11
- {"x11", mpgl_set_backend_x11},
+ {.driver = &mpgl_driver_x11},
#endif
#if HAVE_EGL_X11
{"x11egl", mpgl_set_backend_x11egl},
diff --git a/video/out/gl_common.h b/video/out/gl_common.h
index 711db271bd..3b5def0346 100644
--- a/video/out/gl_common.h
+++ b/video/out/gl_common.h
@@ -170,7 +170,6 @@ int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt,
void mpgl_set_backend_cocoa(MPGLContext *ctx);
void mpgl_set_backend_w32(MPGLContext *ctx);
-void mpgl_set_backend_x11(MPGLContext *ctx);
void mpgl_set_backend_x11egl(MPGLContext *ctx);
void mpgl_set_backend_wayland(MPGLContext *ctx);
void mpgl_set_backend_rpi(MPGLContext *ctx);
diff --git a/video/out/gl_x11.c b/video/out/gl_x11.c
index 8310cfe7de..55099fb797 100644
--- a/video/out/gl_x11.c
+++ b/video/out/gl_x11.c
@@ -187,13 +187,6 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags)
struct vo *vo = ctx->vo;
struct glx_context *glx_ctx = ctx->priv;
- if (glx_ctx->context) {
- // GL context and window already exist.
- // Only update window geometry etc.
- vo_x11_config_vo_window(vo, glx_ctx->vinfo, flags, "gl");
- return true;
- }
-
int glx_major, glx_minor;
if (!glXQueryVersion(vo->x11->display, &glx_major, &glx_minor)) {
@@ -247,7 +240,7 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags)
glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_GREEN_SIZE, &ctx->depth_g);
glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_BLUE_SIZE, &ctx->depth_b);
- vo_x11_config_vo_window(vo, glx_ctx->vinfo, flags, "gl");
+ vo_x11_config_vo_window(vo, glx_ctx->vinfo, flags | VOFLAG_HIDDEN, "gl");
int gl_version = ctx->requested_gl_version;
bool success = false;
@@ -263,7 +256,25 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags)
return success;
}
-static void releaseGlContext_x11(MPGLContext *ctx)
+static int glx_init(struct MPGLContext *ctx, int vo_flags)
+{
+ return vo_x11_init(ctx->vo) && config_window_x11(ctx, vo_flags) ? 0 : -1;
+}
+
+static int glx_reconfig(struct MPGLContext *ctx, int flags)
+{
+ struct glx_context *glx_ctx = ctx->priv;
+ vo_x11_config_vo_window(ctx->vo, glx_ctx->vinfo, flags, "gl");
+ return 0;
+}
+
+static int glx_control(struct MPGLContext *ctx, int *events, int request,
+ void *arg)
+{
+ return vo_x11_control(ctx->vo, events, request, arg);
+}
+
+static void glx_uninit(MPGLContext *ctx)
{
struct glx_context *glx_ctx = ctx->priv;
XVisualInfo **vinfo = &glx_ctx->vinfo;
@@ -271,26 +282,24 @@ static void releaseGlContext_x11(MPGLContext *ctx)
Display *display = ctx->vo->x11->display;
if (*vinfo)
XFree(*vinfo);
- *vinfo = NULL;
if (*context) {
glXMakeCurrent(display, None, NULL);
glXDestroyContext(display, *context);
}
- *context = 0;
+ vo_x11_uninit(ctx->vo);
}
-static void swapGlBuffers_x11(MPGLContext *ctx)
+static void glx_swap_buffers(struct MPGLContext *ctx)
{
glXSwapBuffers(ctx->vo->x11->display, ctx->vo->x11->window);
}
-void mpgl_set_backend_x11(MPGLContext *ctx)
-{
- ctx->priv = talloc_zero(ctx, struct glx_context);
- ctx->config_window = config_window_x11;
- ctx->releaseGlContext = releaseGlContext_x11;
- ctx->swapGlBuffers = swapGlBuffers_x11;
- ctx->vo_init = vo_x11_init;
- ctx->vo_uninit = vo_x11_uninit;
- ctx->vo_control = vo_x11_control;
-}
+const struct mpgl_driver mpgl_driver_x11 = {
+ .name = "x11",
+ .priv_size = sizeof(struct glx_context),
+ .init = glx_init,
+ .reconfig = glx_reconfig,
+ .swap_buffers = glx_swap_buffers,
+ .control = glx_control,
+ .uninit = glx_uninit,
+}; \ No newline at end of file