mirror of
https://github.com/mpv-player/mpv
synced 2025-01-29 19:22:48 +00:00
wayland: conditionally commit surface on resize
It was possible for sway to get incorrectly sized borders if you resized the mpv window in a creative manner (e.g. open a video in a non-floating mode, set window scale to 2, then float it and witness wrong border sizes). This is possibly a sway bug (Plasma doesn't have these border issues at least), but there's a reasonable workaround for this. The reason for the incorrect border size is because it is possible for mpv to ignore the width/height from the toplevel listener and set its own size. This new size can differ from what sway/wlroots believes the size is which is what causes the sever side decorations to be drawn on incorrect dimensions. A simple trick is to just explicitly commit the surface after a resize is performed. This is only done if mpv is not fullscreened or maximized since we always obey the compositor widths/heights in those cases. Sending the commit signals the compositor of the new change in the surface and thus sway/wlroots updates its internal coordinates appropriately and borders are no longer broken.
This commit is contained in:
parent
c9474dc9ed
commit
30dcfbc9cb
@ -128,6 +128,8 @@ static void resize(struct ra_ctx *ctx)
|
||||
if (p->egl_window)
|
||||
wl_egl_window_resize(p->egl_window, width, height, 0, 0);
|
||||
|
||||
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
|
||||
wl_surface_commit(wl->surface);
|
||||
wl->vo->dwidth = width;
|
||||
wl->vo->dheight = height;
|
||||
}
|
||||
|
@ -194,7 +194,10 @@ static int resize(struct vo *vo)
|
||||
p->free_buffers = buf->next;
|
||||
talloc_free(buf);
|
||||
}
|
||||
return mp_sws_reinit(p->sws);
|
||||
int ret = mp_sws_reinit(p->sws);
|
||||
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
|
||||
wl_surface_commit(wl->surface);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int control(struct vo *vo, uint32_t request, void *data)
|
||||
|
@ -198,7 +198,10 @@ static bool resize(struct ra_ctx *ctx)
|
||||
const int32_t height = wl->scaling*mp_rect_h(wl->geometry);
|
||||
|
||||
wl_surface_set_buffer_scale(wl->surface, wl->scaling);
|
||||
return ra_vk_ctx_resize(ctx, width, height);
|
||||
bool ok = ra_vk_ctx_resize(ctx, width, height);
|
||||
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
|
||||
wl_surface_commit(wl->surface);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static bool wayland_vk_reconfig(struct ra_ctx *ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user