summaryrefslogtreecommitdiffstats
path: root/video/out/vulkan/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/vulkan/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/vulkan/context_wayland.c')
-rw-r--r--video/out/vulkan/context_wayland.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/video/out/vulkan/context_wayland.c b/video/out/vulkan/context_wayland.c
index 4af0e795ef..7e6beb3bdd 100644
--- a/video/out/vulkan/context_wayland.c
+++ b/video/out/vulkan/context_wayland.c
@@ -205,16 +205,10 @@ static bool resize(struct ra_ctx *ctx)
MP_VERBOSE(wl, "Handling resize on the vk 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);
bool ok = ra_vk_ctx_resize(ctx, width, height);
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
@@ -250,13 +244,21 @@ static void wayland_vk_wait_events(struct ra_ctx *ctx, int64_t until_time_us)
vo_wayland_wait_events(ctx->vo, until_time_us);
}
+static void wayland_vk_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);
+}
+
const struct ra_ctx_fns ra_ctx_vulkan_wayland = {
- .type = "vulkan",
- .name = "waylandvk",
- .reconfig = wayland_vk_reconfig,
- .control = wayland_vk_control,
- .wakeup = wayland_vk_wakeup,
- .wait_events = wayland_vk_wait_events,
- .init = wayland_vk_init,
- .uninit = wayland_vk_uninit,
+ .type = "vulkan",
+ .name = "waylandvk",
+ .reconfig = wayland_vk_reconfig,
+ .control = wayland_vk_control,
+ .wakeup = wayland_vk_wakeup,
+ .wait_events = wayland_vk_wait_events,
+ .update_render_opts = wayland_vk_update_render_opts,
+ .init = wayland_vk_init,
+ .uninit = wayland_vk_uninit,
};