Skip to content

Commit

Permalink
vo_dmabuf_wayland: attach solid buffer when using force window
Browse files Browse the repository at this point in the history
e125da2 changed the z order of the
surfaces a bit, but it turns out this has a side effect. If the aspect
ratio of the actual video doesn't match your display, the osd surface
doesn't scale properly and gets clipped. Put the z ordering back where
it used to be. Instead when we have the force window case, simply attach
the already existing solid buffer to the video surface. This allows the
osd surface to actually draw over it instead of always being obscured so
it satisfies the case of not having any real video frames but still
wanting to draw the osd. Also don't mess with any of the viewport source
setting stuff with force window. Weston complains about it, and it's
nonsensical anyway. Fixes mpv-player#12547.
  • Loading branch information
Dudemanguy committed Oct 2, 2023
1 parent 05d7929 commit 47dec1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion video/out/vo_dmabuf_wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ static void set_viewport_source(struct vo *vo, struct mp_rect src)
struct priv *p = vo->priv;
struct vo_wayland_state *wl = vo->wl;

if (p->force_window)
return;

if (wl->video_viewport && !mp_rect_equals(&p->src, &src)) {
wp_viewport_set_source(wl->video_viewport, src.x0 << 8,
src.y0 << 8, mp_rect_w(src) << 8,
Expand Down Expand Up @@ -587,12 +590,18 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame)
struct osd_buffer *osd_buf;
double pts;

if (!vo_wayland_check_visible(vo) && !p->force_window)
if (!vo_wayland_check_visible(vo))
return;

if (p->destroy_buffers)
destroy_buffers(vo);

// Reuse the solid buffer so the osd can be visible
if (p->force_window) {
wl_surface_attach(wl->video_surface, p->solid_buffer, 0, 0);
wl_surface_damage_buffer(wl->video_surface, 0, 0, 1, 1);
}

pts = frame->current ? frame->current->pts : 0;
if (frame->current) {
struct mp_image *src = mp_image_new_ref(frame->current);
Expand Down
2 changes: 1 addition & 1 deletion video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,8 +2239,8 @@ bool vo_wayland_init(struct vo *vo)
goto err;

if (wl->subcompositor) {
wl->osd_subsurface = wl_subcompositor_get_subsurface(wl->subcompositor, wl->osd_surface, wl->video_surface);
wl->video_subsurface = wl_subcompositor_get_subsurface(wl->subcompositor, wl->video_surface, wl->surface);
wl->osd_subsurface = wl_subcompositor_get_subsurface(wl->subcompositor, wl->osd_surface, wl->surface);
}

#if HAVE_WAYLAND_PROTOCOLS_1_27
Expand Down

0 comments on commit 47dec1c

Please sign in to comment.