summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/context_wayland.c
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2020-10-05 10:28:37 -0500
committerDudemanguy <random342@airmail.cc>2020-10-15 13:43:45 +0000
commitb60545bdc6a820112b04dbe8b54d93816efa5a05 (patch)
treebf329898ca19ee573a934b57378c3fe122120fa5 /video/out/opengl/context_wayland.c
parentaacefa4ae5c6112ee7e98535e377c3806bcec85a (diff)
downloadmpv-b60545bdc6a820112b04dbe8b54d93816efa5a05.tar.bz2
mpv-b60545bdc6a820112b04dbe8b54d93816efa5a05.tar.xz
wayland: update opaque region on runtime
Made possible with 00b9c81. 34b8adc let the wayland surface set an opaque region depending on if alpha was set by the user or not. However, there was no attempted detection for runtime changes and it is possible (at least in wayland vulkan) to toggle the alpha on and off. So this meant, we could be incorrectly signalling an opaque region if the user happened to change the alpha. Additionally, add a helper function for this and use it everywhere we want to set the opaque region.
Diffstat (limited to 'video/out/opengl/context_wayland.c')
-rw-r--r--video/out/opengl/context_wayland.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c
index 2456de1b90..95ea9f65e0 100644
--- a/video/out/opengl/context_wayland.c
+++ b/video/out/opengl/context_wayland.c
@@ -119,16 +119,10 @@ static void resize(struct ra_ctx *ctx)
MP_VERBOSE(wl, "Handling resize on the egl side\n");
- const int32_t width = wl->scaling*mp_rect_w(wl->geometry);
- const int32_t height = wl->scaling*mp_rect_h(wl->geometry);
-
- if (!ctx->opts.want_alpha) {
- struct wl_region *region = wl_compositor_create_region(wl->compositor);
- wl_region_add(region, 0, 0, width, height);
- wl_surface_set_opaque_region(wl->surface, region);
- wl_region_destroy(region);
- }
+ const int32_t width = wl->scaling * mp_rect_w(wl->geometry);
+ const int32_t height = wl->scaling * mp_rect_h(wl->geometry);
+ vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
wl_surface_set_buffer_scale(wl->surface, wl->scaling);
if (p->egl_window)
@@ -296,6 +290,13 @@ static void wayland_egl_wait_events(struct ra_ctx *ctx, int64_t until_time_us)
vo_wayland_wait_events(ctx->vo, until_time_us);
}
+static void wayland_egl_update_render_opts(struct ra_ctx *ctx)
+{
+ struct vo_wayland_state *wl = ctx->vo->wl;
+ vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
+ wl_surface_commit(wl->surface);
+}
+
static bool wayland_egl_init(struct ra_ctx *ctx)
{
if (!vo_wayland_init(ctx->vo)) {
@@ -307,12 +308,13 @@ static bool wayland_egl_init(struct ra_ctx *ctx)
}
const struct ra_ctx_fns ra_ctx_wayland_egl = {
- .type = "opengl",
- .name = "wayland",
- .reconfig = wayland_egl_reconfig,
- .control = wayland_egl_control,
- .wakeup = wayland_egl_wakeup,
- .wait_events = wayland_egl_wait_events,
- .init = wayland_egl_init,
- .uninit = wayland_egl_uninit,
+ .type = "opengl",
+ .name = "wayland",
+ .reconfig = wayland_egl_reconfig,
+ .control = wayland_egl_control,
+ .wakeup = wayland_egl_wakeup,
+ .wait_events = wayland_egl_wait_events,
+ .update_render_opts = wayland_egl_update_render_opts,
+ .init = wayland_egl_init,
+ .uninit = wayland_egl_uninit,
};